1
我該如何創建一個多維數組?目前該查詢返回我:Zend Db Sql Sql行數組
Array
(
[id] => 1
[name] => Samsung galaxy S4
[homepage] => 1
)
,但我希望我回到這樣的數據:
Array
(
[0] => Array
(
[id] => 1
[name] => Samsung galaxy S4
[homepage] => 1
)
[1] => Array
(
[id] => 3
[name] => Iphone 5
[homepage] => 1
)
[2] => Array
(
[id] => 3
[name] => Samsung galaxy S3
[homepage] => 1
)
)
型號:
<?php
namespace Application\Model;
use Zend\Db\Adapter\Adapter;
use Zend\Db\Sql\Sql;
class News
{
const TABLE = 'news';
public function __construct(Adapter $adapter)
{
$this->adapter = $adapter;
$this->sql = new Sql($adapter);
}
public function getNews()
{
$select = $this->sql->select();
$select->from(self::TABLE)
->where(array('homepage' => 1));
$statement = $this->sql->prepareStatementForSqlObject($select);
return $statement->execute()->current();
}
}
問題並不在查詢反過來它全部變成了多維陣列。 如何從數據庫創建一個數組。
將返回' - >電流()'是你選擇的多的第一項維數組,將由'$ statement-> execute()'返回 - 切斷' - > current()',並且你得到了你想要的 – Sam