MysqlModel Mysql 數(shù)據(jù)庫(kù)服務(wù)模塊類 > MysqlQueryResult
?? MysqlQueryResult 構(gòu)造函數(shù)已私有,無(wú)法通過(guò) new 方式實(shí)例化,僅通過(guò) MysqlModel 的
query方法獲得
$result = $mysqlModel->query('SELECT * FROM `table`', null, false);
MysqlQueryResult::all
獲取結(jié)果集數(shù)組
array MysqlQueryResult::all ( void )
參數(shù)
無(wú)返回值
結(jié)果集數(shù)組范例
$result->all();
MysqlQueryResult::allWithKey
獲取結(jié)果集數(shù)組,并以某字段為鍵
array MysqlResult::allWithKey ( mixed $key )
參數(shù)
$key - 鍵字段索引,如果是數(shù)字,則以按順序的字段為字段名;如果是字符串,則表明為字段名返回值
結(jié)果集數(shù)組范例
$result->allWithKey(0); // 以第一個(gè)字段為鍵
$result->allWithKey('pid'); // 以字段 pid 為鍵
MysqlQueryResult::column
獲取結(jié)果列數(shù)組
array MysqlQueryResult::column ( [mixed $index = 0] )
參數(shù)
$index - 列字段索引,默認(rèn)為0,如果是數(shù)字,則以按順序的字段為字段名;如果是字符串,則表明為字段名返回值
結(jié)果列數(shù)組范例
$result->column(1);
$result->column('name');
MysqlQueryResult::columnWithKey
獲取結(jié)果列數(shù)組
array MysqlQueryResult::columnWithKey ( mixed $key [, mixed $index = 0] )
參數(shù)
$key - 鍵字段索引,如果是數(shù)字,則以按順序的字段為字段名;如果是字符串,則表明為字段名
$index - 列字段索引,默認(rèn)為0,如果是數(shù)字,則以按順序的字段為字段名;如果是字符串,則表明為字段名返回值
結(jié)果列數(shù)組范例
$result->columnWithKey('id', 'name');
MysqlQueryResult::row
獲取結(jié)果行
object MysqlQueryResult::row ( [int $row = 0] )
參數(shù)
$row - 行數(shù),默認(rèn)首行返回值
結(jié)果行對(duì)象范例
$result->row();
MysqlQueryResult::field
獲取結(jié)果值
mixed MysqlQueryResult::field ( [mixed $index = 0] )
參數(shù)
$index - 列字段索引,默認(rèn)為0,如果是數(shù)字,則以按順序的字段為字段名;如果是字符串,則表明為字段名返回值
結(jié)果值范例
$result = $mysqlModel->query('SELECT COUNT(*) FROM `table`');
$result->field();
MysqlQueryResult::fields
獲取字段列表數(shù)組
array MysqlQueryResult::fields ( void )
獲取字段列表時(shí),結(jié)果集必須至少包含一行結(jié)果
參數(shù)
無(wú)返回值
字段數(shù)組范例
$result->fields();