How to select a MAX value from column in Query Builder in Kohana framework?
- by Victor Czechov
I need to INSERT a data to table, but before a query I must to know the MAX value from column position, than to INSERT a data WHERE my SELECTED before position+1. Is it possible with query builder?
following my first comment I did query:
$p = DB::select(array(DB::expr('MAX(`position`)', 'p')))->from('supercategories')->execute();
echo $p;
the error:
ErrorException [ Notice ]: Undefined offset: 1
MODPATH\database\classes\kohana\database.php [ 505 ]
500 */
501 public function quote_column($column)
502 {
503 if (is_array($column))
504 {
505 list($column, $alias) = $column;
506 }
507
508 if ($column instanceof Database_Query)
509 {
510 // Create a sub-query