<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、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 基本方法 DbModel封裝了一些基本方法來操作數據庫。 * * * * * #### getOne 根據條件獲取表中一行數據的一個字段的值 ~~~ DbModel::getOne($field) ~~~ 根據條件獲取表中一行數據的一個字段的值。 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | field | 是 | string | 字段名 | 用例: ~~~ /** * 測試根據條件獲取一個字段值 * * @return mixed|string */ public function testGetOne() { $query = $this->where('id', '=', 1)->andWhere('id', '<', 2); return $query->getOne('name'); } ~~~ * * * * * #### getRow 根據條件獲取表中一行數據 ~~~ DbModel::getRow($fields = '*') ~~~ 根據條件獲取表中一行數據 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | fields | 否 | string,array | 字段名列表,默認所有字段 | fields可以是逗號(,)分隔的字符串,也可以是數組。形如:'id, name, email, age' 或 ['id', 'name', 'email', 'age'] 均可,默認是全部。 用例: ~~~ /** * 測試根據條件獲取一行數據 * * @return array|mixed */ public function testGetRow() { $fields = 'name, email'; $query = $this->where('id', '=', 1)->andWhere('id', '<', 2); return $query->getRow($fields); } ~~~ * * * * * #### getRows 根據條件獲取表中多行數據 ~~~ DbModel::getRows($fields = '*', $sort = null, $limit = null, $primkey = false) ~~~ 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | fields | 否 | string,array | 字段名列表,默認所有字段 | | sort | 否 | string | 排序方式,形如:“id asc” | | limit | 否 | string | 獲取區間,形如:"0, 50" | | primkey | 否 | boolean | 是否返回以主鍵為下標的二位數組,默認為否 | fields可以是逗號(,)分隔的字符串,也可以是數組。形如:'id, name, email, age' 或 ['id', 'name', 'email', 'age'] 均可,默認是全部。 用例: ~~~ /** * 測試根據條件獲取多行數據 * * @return array */ public function testGetRows() { $fields = 'id, name, email'; $sort = 'id asc'; $limit = '0, 10'; $primkey = false; $query = $this->where('id', '>', 10)->andWhere('id', '<', 20); return $query->getRows($fields, $sort, $limit, $primkey); } ~~~ * * * * * #### lastInsertId 獲取最后插入的ID ~~~ DbModel::lastInsertId() ~~~ 參數表 無 用例: ~~~ /** * 測試獲取最后插入的id * * @return int */ public function testGetLastInsertId() { return $this->lastInsertId(); } ~~~ * * * * * #### getLastSql 獲取最后執行的SQL語句 ~~~ DbModel::getLastSql() ~~~ 參數表 無 用例: ~~~ /** * 測試獲取最后執行的SQL語句 * * @return string */ public function testGetLastSql() { return $this->getLastSql(); } ~~~ * * * * * #### insert 插入一條記錄 ~~~ DbModel::insert($row) ~~~ 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | row | 是 | array | 要插入的數據數組,必須是鍵值對數組 | row必須是鍵值對數組,以字段名為鍵名,以字段值為鍵值,一維數組。 用例: ~~~ /** * 測試插入數據 * * @return int 返回影響行數 */ public function testInsert() { $row = [ 'name' => '張三', 'age' => 20, 'email' => 'zs@qq.com', 'create_at' => '2016-12-06 12:00:00' ]; return $this->insert($row); } ~~~ * * * * * #### replace 替換或插入一條記錄 ~~~ DbModel::replace($row) ~~~ 該方法類似于insert方法,不同的是,如果插入的數據和已有數據的主鍵、unique字段、聯合unique索引沖突時,會進行替換而不是插入。 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | row | 是 | array | 要插入或替換的數據數組,必須是鍵值對數組 | row必須是鍵值對數組,以字段名為鍵名,以字段值為鍵值,一維數組。 用例: ~~~ /** * 測試替換數據 * * @return int 返回影響行數 */ public function testReplace() { $row = [ 'id' => 6, 'name' => '張三', 'age' => 23, 'email' => '223@qq.com', 'create_at' => '2016-12-06 12:00:00' ]; return $this->replace($row); } ~~~ * * * * * #### insertIgnore 插入或忽略一條記錄 ~~~ DbModel::insertIgnore($row) ~~~ 該方法類似于insert方法,不同的是,如果插入的數據和已有數據的主鍵、unique字段、聯合unique索引沖突時,會忽略此插入操作。 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | row | 是 | array | 要插入的數據數組,必須是鍵值對數組 | row必須是鍵值對數組,以字段名為鍵名,以字段值為鍵值,一維數組。 用例: ~~~ /** * 測試插入數據,如果主鍵重復或唯一索引沖突則忽略 * * @return int 返回影響行數 */ public function testInsertIgnore() { $row = [ 'id' => 3, 'name' => '張三', 'age' => 36, 'email' => '223@qq.com', 'create_at' => '2016-12-06 12:00:00' ]; return $this->insertIgnore($row); } ~~~ * * * * * #### delete 刪除記錄 ~~~ DbModel::delete() ~~~ 刪除滿足查詢條件的記錄。 參數表 無 用例: ~~~ /** * 測試根據條件刪除數據 * * @return int 返回影響行數 */ public function testDelete() { $query = $this->where('id', '=', 21); return $query->delete(); } ~~~ * * * * * #### update 更新一條記錄 ~~~ DbModel::update($row) ~~~ 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | row | 是 | array | 要更新的數據數組,必須是鍵值對數組 | row必須是鍵值對數組,以字段名為鍵名,以字段值為鍵值,一維數組。 用例: ~~~ /** * 測試根據條件更新數據 * * @return int 返回影響行數 */ public function testUpdate() { $row = [ 'name' => '張三他媽', 'age' => 36, 'email' => '223@qq.com', 'create_at' => '2016-12-06 12:00:00' ]; $query = $this->where('id', '=', 19); return $query->update($row); } ~~~ * * * * * #### increase 字段值自增 ~~~ DbModel::increase($id, $field, $incValue = 1) ~~~ 字段值自增。 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | id | 是 | int | 要自增數據行的主鍵id | | field | 是 | string | 要自增數據的字段名 | | incValue | 否 | int | 要自增的值,默認1 | 用例: ~~~ /** * 測試自增一個字段的值 * * @return int 返回影響行數 */ public function testInc() { $id = 1; return $this->increase($id, 'click', 1); } ~~~ * * * * * #### decrease 字段值自減 ~~~ DbModel::decrease($id, $field, $decValue = 1) ~~~ 字段值自減。 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | id | 是 | int | 要自減數據行的主鍵id | | field | 是 | string | 要自減數據的字段名 | | decValue | 否 | int | 要自減的值,默認1 | 用例: ~~~ /** * 測試自減一個字段的值 * * @return int 返回影響行數 */ public function testDec() { $id = 1; return $this->decrease($id, 'click', 1); } ~~~ * * * * * #### getFields 獲取表字段名列表 ~~~ DbModel::getFields($excepts = []) ~~~ 字段值自減。 參數表 | 參數名稱 | 必選 | 類型 | 說明 | | --- | --- | --- | --- | | excepts | 否 | array | 要忽略的字段數組 | 用例: ~~~ /** * 測試獲取一個表的字段列表 * * @return array */ public function testGetFields() { $excepts = ['id', 'name']; return $this->getFields($excepts); } ~~~ * * * * * #### beginTransaction 開啟事務 ~~~ DbModel::beginTransaction() ~~~ 開啟事務。 參數表 無 用例: ~~~ /** * 測試開啟事務 * * @return boolean */ public function testBeginTransaction() { return $this->beginTransaction(); } ~~~ * * * * * #### rollBack 回滾事務 ~~~ DbModel::rollBack() ~~~ 回滾事務。 參數表 無 用例: ~~~ /** * 測試回滾事務 * * @return boolean */ public function testRollBack() { return $this->rollBack(); } ~~~ * * * * * #### commit 提交事務 ~~~ DbModel::commit() ~~~ 提交事務。 參數表 無 用例: ~~~ /** * 測試提交事務 * * @return boolean */ public function testCommit() { return $this->commit(); } ~~~
                  <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>

                              哎呀哎呀视频在线观看