<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 1\. 框架 ## 1.1. 引言 1. 定義及縮略語 | key | value | | --- | --- | | Zero框架 | 提供框架、公共基礎組件、公共業務組件加速業務的日常研發工作 | 2. 目的 本規范由編程原則組成,融合并提煉了開發人員長時間積累下來的成熟經驗,意在幫助形成良好一致的編程風格。以達到事半功倍的效果,如果有需要本文檔會不定期更新。 3. 適用范圍 如無特殊說明,以下規則要求完全適用于基于Zero框架框架開發的應用,同時也可大部分適用于部門其他PHP項目。 4. 標準化作用 當一個軟件項目嘗試著遵守公共一致的標準時,可以使參與項目的開發人員更容易了解項目中的代碼、弄清程序的狀況。使新的參與者可以很快的適應環境,防止部分參與者出于節省時間的需要,自創一套風格并養成終生的習慣,導致其它人在閱讀時浪費過多的時間和精力。而且在一致的環境下,也可以減少編碼出錯的機會。 缺陷是由于每個人的標準不同,所以需要一段時間來適應和改變自己的編碼風格,暫時性的降底了工作效率。從使項目長遠健康的發展以及后期更高的團隊工作效率來考慮暫時的工作效率降低是值得的,也是必須要經過的一個過程。標準不是項目成功的關鍵,但可以幫助我們在團隊協作中有更高的效率并且更加順利的完成既定的任務。 1) 程序員可以了解任何代碼,弄清程序的狀況 2) 新人可以很快的適應環境 3) 防止新接觸PHP的開發出于節省時間的需要,自創一套風格并養成終生的習慣 4) 防止新接觸PHP的開發一次次的犯同樣的錯誤 5) 在一致的環境下,可以減少犯錯的機會 ## 1.2. 目錄結構規范 ### 1.2.1. 框架路徑 ### 1.2.2. 應用目錄結構 #### 1.2.2.1. 配置configs 存放配置文件 默認$\_GET變量經過了 htmlspecialchars #### 1.2.2.2. 公用類庫 libraries 框架及公用類庫,不允許修改 #### 1.2.2.3. 控制器controllers 所有控制器都繼承Controller, 類名以Ctl結尾, 寫法如下: 例如控制器 /$app\_name/controllers/IndexCtl.php ~~~php <?php class IndexCtl extends Zero_Controller { public function __construct(&$ctl, $met, $typ) { parent::__construct($ctl, $met, $typ); } public function test() { $this->render('default'); /* $this->render('default', $data, $msg, $status); $this->render($name='default', $data=array(), $msg='success', $status=200) */ /** * @param string $name layoutname, 對應文件在views/layouts/{$name}.php * @param array $data 渲染數據 * @param string $msg 消息提示 * @param int $status 狀態 */ } } ?> ~~~ #### 1.2.2.4. 模型models 模型 每一個表都對應的一個模型, 例如user\_base 表 對應的模型為 /models/User/BaseModel.php , 對表user\_base的操作,必須經過 User\_BaseModel. ~~~php <?php if (!defined('ROOT_PATH')) exit('No Permission'); /** * 用戶基本信息模型 * * @category Framework * @package Model * @copyright Copyright (c) 2016-10-14 * @version 1.0 * @todo */ class User_BaseModel extends Zero_Model { public $_cacheName = 'user'; public $_tableName = 'user_base'; public $_tablePrimaryKey = 'user_id'; public $_useCache = false; //代表存入數據庫的數據格式, DOT為英文逗號分割 public $fieldType = array('user_state'=>'DOT', 'user_json'=>'JSON', 'user_html'=>'HTML'); /** * 默認key = $this->_tableName . '_cond' * @access public */ public $_multiCond = array( 'user_base_cond'=>array( 'user_account'=>null, 'user_token'=>null, ) ); public $_validateRules = array('integer'=>array('user_id', 'user_state')); public $_validateLabels= array(); /** * @param string $user User Object * @var string $db_id 指定需要連接的數據庫Id * @return void */ public function __construct(&$db_id='account', &$user=null) { $this->_useCache = CHE; $this->_tabelPrefix = TABLE_ACCOUNT_PREFIX; parent::__construct($db_id, $user); } /** * 讀取分頁列表 * * @param array $column_row where查詢條件 * @param array $sort 排序條件order by * @param int $page 當前頁碼 * @param int $rows 每頁顯示記錄數 * @return array $data 返回的查詢內容 * @access public */ public function getLists($column_row=array(), $sort=array(), $page=1, $rows=500) { //修改值 $column_row $data = $this->lists($column_row, $sort, $page, $rows); return $data; } } ?> ~~~ 模型中可用方法: ~~~php <?php add //insert, 可以傳入二維數據一次添加多條記錄 save //保存內容,insert|update , 可以傳入二維數據一次添加或者編輯多條記錄, 如果有主鍵則編輯,否則添加 remove removeCond //根據條件刪除操作 edit editInc //是否增量更新 edit 別名 editCond //根據條件edit操作 get getOne getFoundRows lists //根據條件讀取分頁列表 listKey find //根據條件讀取列表 findOne findKey //查找主鍵 $_tableName 決定了這個模型操作表 user_base /** * 插入 - 可以傳入二維數據一次添加多條記錄 插入多條記錄 實現批量插入數據 * @param array $field_row 信息 * @param bool $return_insert_id 是否返回自增主鍵 * @param bool $replace 是否數據覆蓋 * @return bool 是否成功 * @access public */ public function add($field_row, $return_insert_id=false, $replace=false) { } /** * 保存內容,insert|update 可以傳入二維數據一次添加或者編輯多條記錄, 如果有主鍵則編輯,否則添加 * @param array $field_row key=>value數組 * @param bool $return_insert_id 自增主鍵 * @param bool $flag 是否增量更新 * @return bool $update_flag 是否成功 * @access public */ public function save($field_rows, $return_insert_id=false, $flag=false) { } /** * 傳入主鍵刪除操作 * @param mix $table_primary_key_value * @return bool $del_flag 是否成功 * @access public */ public function remove($table_primary_key_value) { } /** * 根據條件刪除操作, 如果存在主鍵,使用remove * @param mix $table_primary_key_value * @return bool $del_flag 是否成功 * @access public */ public function removeCond($column_row=array()) { } /** * 根據主鍵更新表內容 * @param mix $table_primary_key_value 主鍵 * @param array $field_row key=>value數組 * @param bool $flag 是否增量更新 * @param array $field_old_row key=>value數組 * @return bool $update_flag 是否成功 * @access public */ public function edit($table_primary_key_value=null, $field_row, $flag=null, $field_old_row=null) { } /** * 是否增量更新 edit 別名 * @param mix $table_primary_key_value * @param array $field_value_new * @param array $field_value_old * @return bool $update_flag 是否成功 * @access public */ public function editInc($table_primary_key_value=null, $field_row, $field_old_row=null) { } /** * 根據條件更新表內容 * * @param array $column_row 條件 * @param array $field_row key=>value數組 * @param bool $flag 是否增量更新 * @param array $field_old_row key=>value數組 * @return bool $update_flag 是否成功 * @access public */ public function editCond($column_row=array(), $field_row, $inc_flag=null, $field_old_row=null) { } /** * 只獲取一條記錄 * * @param int $table_primary_key_value 主鍵值 * @return array $rows 返回的查詢內容 * @access public */ public function getOne($table_primary_key_value=null, $key_row=null, $sort_row=array()) { $row = array(); $rows = $this->get($table_primary_key_value, $key_row, $sort_row); if ($rows) { $row = reset($rows); } return $row; } /** * 根據主鍵值,從數據庫讀取數據, 必須獲取主鍵后再讀取數據 * * @param int $table_primary_key_value 主鍵值 * @return array $rows 返回的查詢內容 * @access public */ public function get($table_primary_key_value=null, $key_row=null, $sort_row=array()) { } /** * 取得影響的行數 * * @return int $num 行數 * @access public */ public function getFoundRows() { $num = $this->_selectFoundRows(); return $num; } /** * 獲取數據記錄行數, cache 清除太多,不合理. 組名稱,是否根據用戶id來處理.特列下允許使用, 正常通過數據庫來存儲冗余統計數據 * * @param array $cond_row * @param string $group * @param bool $cache_flag 是否啟用cache * @return int * @access public */ public function getNum($cond_row, $group=null, $cache_flag=false) { } /** * 讀取分頁列表, find根據條件獲取數據, 而get根據id獲取數據 * * @param int $column_row where查詢條件, 需要設置在multiCond中, 方便處理為group名字,用來通過組更新緩存 * @param string $group 組名稱 * @param int $page 當前頁碼 * @param int $rows 每頁顯示記錄數 * @param int $sort_row 排序方式 * @return array $rows 返回的查詢內容 * @access public */ public function find($column_row=array(), $sort_row=array(), $page=1, $page_num=500, $group=null, $cache_flag=false) { } public function findOne($column_row=array(), $sort_row=array(), $page=1, $page_num=1, $group=null, $cache_flag=false) { } /** * 根據where條件取得主鍵 * * @param array $cond_row * @param array $sort_row * @param int $page * @param string $group * @param bool $cache_flag * @return array $rows 信息 * @access public */ public function findKey($cond_row=array(), $sort_row=array(), $page=1, $page_num=500, $group=null, &$total=0, $cache_flag=false) { } /** * 讀取分頁列表Id * * @param int $column_row where查詢條件, 需要設置在multiCond中 * @param int $sort_row array('key'=>'ASC|DESC')排序方式 * @param int $page 當前頁碼 * @param int $rows 每頁顯示記錄數 * @param string $group 組名稱 * @param bool $cache_flag 是否緩存 * @param bool $array_flag 是否使用array_value處理返回的items * @return array $rows 返回的查詢內容 * @access public */ public function listKey($column_row=array(), $sort_row=array(), $page=1, $page_num=500, $group=null, $cache_flag=false, $array_flag=true) { $data = array(); $data['page'] = $page; $data['total'] = $total; //total page $data['records'] = $records; $data['items'] = $array_flag ? array_values($data['items']) : $data['items']; return $data; } /** * 讀取分頁列表 * * @param int $column_row where查詢條件, 需要設置在multiCond中, 方便處理為group名字 * @param int $sort_row 排序方式 * @param int $page 當前頁碼 * @param int $rows 每頁顯示記錄數 * @param string $group 組名稱 * @param bool $cache_flag 是否緩存 * @param bool $array_flag 是否使用array_value處理返回的items * @return array $rows 返回的查詢內容 * @access public */ public function lists($column_row=array(), $sort_row=array(), $page=1, $page_num=500, $group=null, $cache_flag=false, $array_flag=true) { $data = array(); $data['page'] = $page; $data['total'] = ceil_r($total / $page_num); //total page $data['records'] = $total; $data['items'] = $array_flag ? array_values($data['items']) : $data['items']; return $data; } ?> ~~~ #### 1.2.2.5. 視圖views 例如控制器 /$app\_name/controllers/IndexCtl.php中, test方法,$this->render('default'); 會調用到文件/$app\_name/views/default/layouts/default.php /$app\_name/views/default/IndexCtl/test.php #### 1.2.2.6. 路由規則 默認入口文件為index.php, 例如請求URL為 /index.php?ctl=Index&met=test 程序會運行文件 /$app\_name/controllers/IndexCtl.php 中 Class 為 IndexCtl 中的 test 方法. ### 1.2.3. 前端要求 #### 1.2.3.1. 不得隨意構造URL, 必須通過配置來調用URL, 見config.js #### 1.2.3.2. pjax data-pjax="#page-container" lazyload fancybox tips
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看