2009年8月12日星期三

Re: [fw-db] update more rows at ones

I'm not sure about other dbs, but in MySQL I don't think you can update multiple rows at once. So, in the end, ZF will need to create separate update queries.

MySQL UPDATE Syntax

There may be a way around this by using MySQL's INSERT ... ON DUPLICATE KEY UPDATE syntax. I've used it in the past to perform bulk inserts/updates and is much faster than single queries. In your case, you'll want to make sure to pass in the primary key value so that it always invokes the "update" portion of the query instead of the "insert".

MySQL INSERT ... ON DUPLICATE KEY UPDATE Syntax

As far as I know, ZF doesn't support this out of the box (it's not standard SQL), but you should be able to add this into your own custom DB adapter.

--
Hector


On Wed, Aug 12, 2009 at 3:29 AM, PHPScriptor <contact@phpscriptor.com> wrote:

Ok in this example everything becomes the same. But in reality every row has
a different value...


Denis Baklikov wrote:
>
> Hi,
>
> Could you explain, why you update every row separately instead of using
> one
> SQL query to update all rows?
>
> Regards,
>
> Denis
>


View this message in context: http://www.nabble.com/update-more-rows-at-ones-tp24932410p24933724.html
Sent from the Zend DB mailing list archive at Nabble.com.


没有评论: