【问题标题】:how to create below mysql query in kohana query builder如何在 kohana 查询生成器中创建下面的 mysql 查询
【发布时间】:2014-01-12 13:01:53
【问题描述】:

如何在 Kohana Db Builder 中创建以下查询

SELECT @i:=0;
UPDATE `table_name` 
SET `order` = @i:=@i+1 
where `column_name`= '3337' 

【问题讨论】:

  • 你已经尝试了什么?

标签: kohana


【解决方案1】:

尝试分离查询!

$q1 = DB::query(NULL, "SELECT @i:=0");
$q2 = DB::update('table_name')
        ->set(array('order','=',DB::expr('@i:=@i+1')))
        ->where('column_name','=','3337');

$q1->execute();
$q2->execute();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    • 2017-02-02
    • 2015-12-13
    • 2015-11-30
    • 2021-02-20
    相关资源
    最近更新 更多