根据ID值删除表数据。可以删除单个或者多个数据,$ids可以是单个数字或者数组。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $ids | String|Array | 是 | 单个id或者多个id |
| $table_name | String | 是 | 数据表名称 |
| $id_key | String | 否 | 主键名称,默认 id |
class testaDao extends Dao {
public function test() {
$this->dao->db->delete(array(1,2,3), 'test', 'id');
}
}
根据条件语句删除表数据。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $field | Array | 是 | 数组条件 array('id'=>1) |
| $table_name | String | 是 | 数据表名称 |
class testaDao extends Dao {
public function test() {
$this->dao->db->delete_by_field(array('id'=>1), 'test');
}
}
根据条件语句删除表数据。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $table_name | String | 是 | 数据表名称 |
| $num | Int | 否 | 分页参数 |
| $offest | Int | 否 | 分页参数 |
| $field | Array | 否 | 条件语句 |
| $key_id | String | 否 | 排序字段 |
| $sort | String | 否 | 排序 |
class testaDao extends Dao {
public function test() {
$this->dao->db->get_all('test');
}
}
根据SQL语句获取全部数据信息。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $sql | String | 是 | 数据库语句 |
class testaDao extends Dao {
public function test() {
$this->dao->db->get_all_sql("SELECT * FROM test");
}
}
根据SQL语句获取全部数据信息。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $table_name | String | 是 | 数据表名称 |
| $field | Array | 否 | 条件语句 |
class testaDao extends Dao {
public function test() {
$this->dao->db->get_count("test");
}
}
根据ID值获取单条数据。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $ids | String|Array | 是 | 单个id或者多个id |
| $table_name | String | 是 | 数据表名称 |
| $id_key | String | 否 | 主键名称,默认 id |
class testaDao extends Dao {
public function test() {
$this->dao->db->get_one(1, 'test', 'id');
}
}
根据ID值获取单条数据。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $ids | String|Array | 是 | 单个id或者多个id |
| $table_name | String | 是 | 数据表名称 |
| $id_key | String | 否 | 主键名称,默认 id |
class testaDao extends Dao {
public function test() {
$this->dao->db->get_one(1, 'test', 'id');
}
}
根据条件获取语句。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $field | Array | 是 | 数组条件 array('id'=>1) |
| $table_name | String | 是 | 数据表名称 |
class testaDao extends Dao {
public function test() {
$this->dao->db->get_one_by_field(array('uid' => 100), 'test');
}
}
根据SQL语句获取单条数据信息。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $sql | String | 是 | 数据库语句 |
class testaDao extends Dao {
public function test() {
$this->dao->db->get_one_sql("SELECT * FROM test WHERE id = 1");
}
}
根据SQL语句获取单条数据信息。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $sql | String | 是 | 数据库语句 |
class testaDao extends Dao {
public function test() {
$this->dao->db->get_one_sql("SELECT * FROM test WHERE id = 1");
}
}
SQL操作-插入多条数据。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $field | Array | 是 | 字段名称数组 |
| $data | Array | 是 | 值数组 |
| $table_name | String | 是 | 数据表名称 |
class testaDao extends Dao {
public function test() {
$this->dao->db->insert_more(array('username'), array(array('init'),array('woshishen')), 'test');
}
}
SQL操作-根据主键id更新数据。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $id | Int | 是 | 主键ID |
| $data | Array | 是 | 参数 array('key'=>'value') |
| $table_name | String | 是 | 数据表名称 |
| $id_key | String | 否 | 主键名称,默认 id |
class testaDao extends Dao {
public function test() {
$this->dao->db->update(1, array('username' => 'test'), 'test');
}
}
SQL操作-根据字段更新数据。在Dao中使用
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| $data | Array | 是 | 参数 array('key'=>'value') |
| $field | Array | 是 | 数组条件 array('id'=>1) |
| $table_name | String | 是 | 数据表名称 |
class testaDao extends Dao {
public function test() {
$this->dao->db->update_by_field(array('username'=>'test'), array('uid' => 100), 'test'); //根据条件更新数据
}
}