数据库MySQL返回对象
API - Driver_Database_Driver_MySQL_Result
- Database_Driver_MySQL_Result::__destruct - Result destruction cleans up all open result sets.
- Database_Driver_MySQL_Result::seek
继承自父类的方法和变量
- Database_Result::__construct - Sets the total number of rows and stores the result locally.
- Database_Result::result - 返回当前返回对象
- Database_Result::current - 获取当前行数据
- Database_Result::as_array - Return all of the rows in the result as an array.
- Database_Result::get - Return the named column from the current row.
- Database_Result::count - Implements [Countable::count], returns the total number of rows.
- Database_Result::offsetExists - Implements [ArrayAccess::offsetExists], determines if row exists.
- Database_Result::offsetGet - Implements [ArrayAccess::offsetGet], gets a given row.
- Database_Result::offsetSet - Implements [ArrayAccess::offsetSet], throws an error.
- Database_Result::offsetUnset - Implements [ArrayAccess::offsetUnset], throws an error.
- Database_Result::key - Implements [Iterator::key], returns the current row number.
- Database_Result::next - Implements [Iterator::next], moves to the next row.
- Database_Result::prev - Implements [Iterator::prev], moves to the previous row.
- Database_Result::rewind - Implements [Iterator::rewind], sets the current row to zero.
- Database_Result::valid - Implements [Iterator::valid], checks if the current row exists.
- Database_Result::fetch_array
- Database_Result::is_bin - 设置指定的key是二进制数据
Result destruction cleans up all open result sets.
void
统计当前查询返回数据
int
返回当前行数据
Sets the total number of rows and stores the result locally.
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$result |
mixed |
Query result | |
$sql |
string |
SQL query | |
$as_object |
unknown |
||
$config |
unknown |
void
返回当前返回对象
获取当前行数据
Return all of the rows in the result as an array.
// Indexed array of all rows $rows = $result->as_array();
// Associative array of rows by "id" $rows = $result->as_array('id');
// Associative array of rows, "id" => "name" $rows = $result->as_array('id', 'name');
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
Column for associative keys | null |
$value |
string |
Column for values | null |
array
Return the named column from the current row.
// Get the "id" value $id = $result->get('id');
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$name |
string |
Column to get | |
$default |
mixed |
Default value if the column does not exist | null |
mixed
Implements [Countable::count], returns the total number of rows.
echo count($result);
integer
Implements [ArrayAccess::offsetExists], determines if row exists.
if (isset($result[10])) { // Row 10 exists }
boolean
Implements [ArrayAccess::offsetGet], gets a given row.
$row = $result[10];
mixed
Implements [ArrayAccess::offsetSet], throws an error.
void
Implements [ArrayAccess::offsetUnset], throws an error.
void
Implements [Iterator::key], returns the current row number.
echo key($result);
integer
Implements [Iterator::next], moves to the next row.
next($result);
$this
Implements [Iterator::prev], moves to the previous row.
prev($result);
$this
Implements [Iterator::rewind], sets the current row to zero.
rewind($result);
$this
Implements [Iterator::valid], checks if the current row exists.
boolean
对数组或字符串进行编码转换
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$data |
array/string |
$data |
设置指定的key是二进制数据
此方法必须在as_array或current等前面执行 当启用自动编码转换后,获取的数据会自动转码,通过此设置后可以避免对应的字段被转码
$this->is_bin('key1');
$this->is_bin('key1' , 'key2');
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
$key |
$this