Hi All,
I just wanna do an update {table} set {field} = {value} where {condition} LIMIT 10
Post::model()->updateAll($attributes,$condition,$params);
If I use like this, it will update all the record meeting the condition, I dont wanna update all records only a few by specifying limit
Thnx in advance
mikl
(Mike)
2
See here: instead of a condition you can also supply a CDbCriteria and use its limit property.
Its got resolved. But its not working the way as I expected.
What it doing is,
if the limit is 10, its looking the first 10 record which satisfy the condition and update those records.
I just want how exactly 'update with limit' work in mysql
mikl
(Mike)
4
Doesn't this work?
<?php
$c=new CDbCriteria;
$c->condition='something=1';
$c->limit=10;
$a=array('name'=>'NewName');
Post::model()->updateAll($a, $c);
You can also turn on logging e.g. with CWebLogRoute and look at the created SQL to maybe find out what's wrong.