Zend framework2 zf2如何var_转储select的结果
我正在尝试var_转储select查询的结果(仅数据库行) 我有一个简单的TableGateway(工厂服务经理) 我的控制器:Zend framework2 zf2如何var_转储select的结果,zend-framework2,zend-db,zend-db-table,Zend Framework2,Zend Db,Zend Db Table,我正在尝试var_转储select查询的结果(仅数据库行) 我有一个简单的TableGateway(工厂服务经理) 我的控制器: public function fooAction() { $test = $this->contactFormTable->shwoContactFormMessages(); var_dump($test); // This will show the results the column and it is wo
public function fooAction()
{
$test = $this->contactFormTable->shwoContactFormMessages();
var_dump($test);
// This will show the results the column and it is working
while ($item = $test->current())
{
echo $item->messageFrom . "<br>";
}
return $view;
}
我只想var_转储数据库行,而不是上面的对象。这是因为ResultSet旨在“按需”为您提供每个项目,而不是一次加载所有项目,如果ResultSet很大,这可能会导致您使用大量内存 如果需要,您可以将完整结果集作为项目数组获取:
var_dump($test->toArray()):
非常感谢,我使用它来检查结果并使用列名。
object(Zend\Db\ResultSet\ResultSet)#327 (8) {
["allowedReturnTypes":protected]=>
array(2) {
[0]=>
string(11) "arrayobject"
[1]=>
string(5) "array"
}
["arrayObjectPrototype":protected]=>
object(ArrayObject)#302 (1) {
["storage":"ArrayObject":private]=>
array(0) {
}
}
["returnType":protected]=>
string(11) "arrayobject"
["buffer":protected]=>
NULL
["count":protected]=>
int(5)
["dataSource":protected]=>
object(Zend\Db\Adapter\Driver\Pdo\Result)#326 (8) {
["statementMode":protected]=>
string(7) "forward"
["resource":protected]=>
object(PDOStatement)#307 (1) {
["queryString"]=>
string(49) "SELECT `hw_contact_form`.* FROM `hw_contact_form`"
}
["options":protected]=>
NULL
["currentComplete":protected]=>
bool(false)
["currentData":protected]=>
NULL
["position":protected]=>
int(-1)
["generatedValue":protected]=>
string(1) "0"
["rowCount":protected]=>
int(5)
}
["fieldCount":protected]=>
int(8)
["position":protected]=>
int(0)
}
var_dump($test->toArray()):