How to select a MAX value from column in Query Builder in Kohana framework?
Posted
by
Victor Czechov
on Stack Overflow
See other posts from Stack Overflow
or by Victor Czechov
Published on 2012-09-10T03:22:46Z
Indexed on
2012/09/10
3:38 UTC
Read the original article
Hit count: 453
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
© Stack Overflow or respective owner