Skip to main content
Version: Fegg 5.x (next)

Pdo::all

Get all the result of executed select query

Description​

public array Pdo::all( [ string $index = '' ] )

Returns the rows of the last SELECT or PRAGMA run with execute, as associative arrays. With $index, the rows are keyed by that column.

Arguments​

NameData typeDefaultRemarks
$indexstring''Column to use as the array key

Example​

Controller
$db = new \Fegg\Database\Pdo();

$rows = $db->setItem('news_id, title')->select('cms_news')->execute()->all();
// -> array(0 => array('news_id' => 1, 'title' => 'A'), 1 => array('news_id' => 2, 'title' => 'B'), ...)

$rows = $db->setItem('news_id, title')->select('cms_news')->execute()->all('news_id');
// -> array(1 => array('news_id' => 1, 'title' => 'A'), 2 => array('news_id' => 2, 'title' => 'B'), ...)