PHP Class PDO_MySQL, zhihuSpider

Show file Open project: hoohack/zhihuSpider Class Usage Examples

Public Methods

Method Description
__construct ( )
count ( $table, $conditions = [] ) : integer 根据条件返回数据的数量
delete ( $table, $conditions ) : integer 删除操作
getAll ( $table, $conditions ) : array 返回多行数据
getInstance ( ) 程序对外统一入口
getOneRow ( $table, $conditions = [], $field = '*' ) : array 返回一行数据
insert ( $table, $data ) : integer 插入一行数据到数据库中
insertAll ( $table, $fields, $datas, $check_duplicate ) : integer 插入多行数据到数据库中
update ( $table, $conditions, $data ) : integer 更新操作

Private Methods

Method Description
bind ( $params, &$stmt ) 为一个PDO占位符绑定值
bindMulti ( $params_array, &$stmt ) 为多个PDO占位符绑定值
biuldMultiWhere ( $conditions, &$params ) 根据参数构造多个where条件
buildWhere ( $conditions, &$params ) 根据参数构造where条件
multiLastInsertId ( $stmt ) 返回执行多行插入的最后插入行的ID

Method Details

__construct() public method

public __construct ( )

count() public method

根据条件返回数据的数量
public count ( $table, $conditions = [] ) : integer
$table string 数据表名
$conditions array 检索条件
return integer 数量的结果

delete() public method

删除操作
public delete ( $table, $conditions ) : integer
$table string 数据表名
$conditions array 执行条件
return integer 影响行数

getAll() public method

返回多行数据
public getAll ( $table, $conditions ) : array
$table string 数据表名
$conditions array 检索条件
return array 返回数据组成的数组

getInstance() public static method

程序对外统一入口
public static getInstance ( )

getOneRow() public method

返回一行数据
public getOneRow ( $table, $conditions = [], $field = '*' ) : array
$table string 表名
$conditions array 检索条件
return array 检索结果组成的一维数组

insert() public method

插入一行数据到数据库中
public insert ( $table, $data ) : integer
$table string 数据表名
$data array 需要插入的数据
return integer 插入新行的ID

insertAll() public method

插入多行数据到数据库中
public insertAll ( $table, $fields, $datas, $check_duplicate ) : integer
$table string 数据表名
$fields array 插入的字段
$datas array 插入的数据
return integer 插入的最后一行的ID

update() public method

更新操作
public update ( $table, $conditions, $data ) : integer
$table string 数据表名
$conditions array 执行条件
$data array 更新的数据
return integer 影响行数