Welcome Guest, Not a member yet? Register   Sign In
Multiple update in single query.
#2

[eluser]sunny.by[/eluser]
[quote author="Arun Joshi" date="1285161527"]I have to update multiple rows of my photos table. I have a dynamic built query like this.

Code:
$query    =    "
UPDATE photos SET description='des one' WHERE photo_id='4';
UPDATE photos SET description='des two'' WHERE photo_id='5';
UPDATE photos SET description='des 3' WHERE photo_id='6';
";
But when I tried this with $this->db->query($query); it shows error. When I copied this query to phpmyadmin, it executed successfully.

Any reason there for this?

Thanks
Arun[/quote]

Hello, Arun.
I think error in next:
For execute your query CI in file mysql_driver.php use next function:
Code:
/**
     * Execute the query
     *
     * @access    private called by the base class
     * @param    string    an SQL query
     * @return    resource
     */    
    function _execute($sql)
    {
        $sql = $this->_prep_query($sql);
        return @mysql_query($sql, $this->conn_id);
    }
but mysql_query don't can work correct with your multiple query.

PS: sorry for my english


Messages In This Thread
Multiple update in single query. - by El Forum - 09-22-2010, 02:18 AM
Multiple update in single query. - by El Forum - 09-22-2010, 04:41 AM
Multiple update in single query. - by El Forum - 09-22-2010, 04:49 AM
Multiple update in single query. - by El Forum - 09-22-2010, 04:52 AM
Multiple update in single query. - by El Forum - 09-22-2010, 05:08 AM
Multiple update in single query. - by El Forum - 09-22-2010, 05:29 AM
Multiple update in single query. - by El Forum - 09-22-2010, 05:35 AM
Multiple update in single query. - by El Forum - 09-22-2010, 03:05 PM
Multiple update in single query. - by El Forum - 04-13-2012, 02:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB