method getColumnValues documentation in bbn\Db\Languages\Sql
Return a numeric indexed array with the values of the unique column ($field) from the selected $table
Example
X::dump($db->getColumnValues('table_users','surname',['id','>',1]));
/*
array [
"Smith",
"Jones",
"Williams",
"Taylor"
]
function($table, string $field = NULL, array $where = [], array $order = [], int $limit = 0, int $start = 0)
{
$res = null;
if ($this->check()) {
$res = [];
if (\is_array($table) && isset($table['fields']) && \is_array($table['fields']) && !empty($table['fields'][0])) {
array_splice($table['fields'], 0, 1, 'DISTINCT '.(string)$table['fields'][0]);
}
elseif (\is_string($table) && \is_string($field) && (stripos($field, 'DISTINCT') !== 0)) {
$field = 'DISTINCT '.$field;
}
if ($rows = $this->iselectAll($table, $field, $where, $order, $limit, $start)) {
foreach ($rows as $row){
$res[] = $row[0];
}
}
}
return $res;
}
Return a numeric indexed array with the values of the unique column ($field) from the selected $table BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions