method countFieldValues documentation in bbn\Db\Languages\Sql

Return a count of identical values in a field as array, Reporting a structure type 'num' - 'val'.

Example

X::dump($db->countFieldValues('table_users','surname',[['name','=','John']])); // (array) ["num" => 2, "val" => "John"] function($table, string $field = NULL, array $where = [], array $order = []) { if (\is_array($table) && \is_array($table['fields']) && count($table['fields'])) { $args = $table; $field = array_values($table['fields'])[0]; } else{ $args = [ 'tables' => [$table], 'where' => $where, 'order' => $order ]; } $args = array_merge( $args, [ 'kind' => 'SELECT', 'fields' => [ 'val' => $field, 'num' => 'COUNT(*)' ], 'group_by' => [$field] ] ); return $this->rselectAll($args); }

Return a count of identical values in a field as array, Reporting a structure type 'num' - 'val'. 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.