/** Fetch all row
*
* @param string $index specify index column
* @param string $selectOnly select columns which could be fetched
*
* @return array of fetched rows
*/
public function fetchAll($index = '', $selectOnly = '')
{
if ($selectOnly) {
$this->select(null)->select($index . ', ' . $selectOnly);
}
if ($index) {
$data = array();
foreach ($this as $row) {
if (is_object($row)) {
$data[$row->{$index}] = $row;
} else {
$data[$row[$index]] = $row;
}
}
return $data;
} else {
if (($s = $this->execute()) !== false) {
if ($this->convertTypes) {
return FluentUtils::convertToNativeTypes($s, $s->fetchAll());
} else {
return $s->fetchAll();
}
}
return $s;
}
}