Welcome Guest, Not a member yet? Register   Sign In
Multiple MySQLi queries - Codeigniter
#1

[eluser]1cookie[/eluser]
Hi, multiple query advice:

In CI, I would love to use:

Code:
$query  = "SELECT CURRENT_USER();";
$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";

/* execute multi query */
if ($mysqli->multi_query($query)

I've seen something dating back to 2011: http://stackoverflow.com/questions/40591...odeigniter

What's changed? Anything.

What's my best bet? Transactions maybe:


http://ellislab.com/codeigniter/user-gui...tions.html



advice...
#2

[eluser]1cookie[/eluser]
I think I answered my own question. This seemed to work for me off the cuff:

Code:
function setClient() {
      
        $this->db->trans_start();

        $data = array(
            'postcode' => 'PR3 6TY' ,
            'city' => 'Preston' ,
            'line_1' => '32 Brook St',
            'line_2' => 'Penwortham',
         );

         $this->db->insert('client_address', $data);
        
        $address_id = $this->db->insert_id();

        $data = array(
                "type" => 1,
                "address" => $address_id,
                "phone" => '0772 65487678',
                "firstname" => 'Roger',
                "lastname" => 'Daltry',
                "email" => '[email protected]',
                "created" => '2014-03-02 12:12:32'
        );
        
        $this->db->insert('client', $data);

        $this->db->trans_complete();
      
    }




Theme © iAndrew 2016 - Forum software by © MyBB