Welcome Guest, Not a member yet? Register   Sign In
MySQL - Multiple Queries - Any way to chain queries together / execute all in one statement?
#2

[eluser]Cristian Gilè[/eluser]
Hi tedtoy, for complicated queries AR is not a good choice. For maintainance and code readibiity using standard SQL queries is the best way.

To reduce the number of $this->db you could use an array:
Code:
$sql = array();
$sql['query1'] = "Create temp table... ; ";
$sql['query2'] = "insert into temp table
             select something, count(*), sum(blah)
             from something
             ...
              ; " ;
$sql['query3'] = " update table a, temp table b
          set a.X = ....... " ;

$sql['query4'] = " drop temp table... ";

$result = array();
foreach($sql as $key => $value)
{
}
    $result[$key] = $this->db->query($value);
}

At least partly, query bindings let you separate the SQL from PHP

Cristian Gilè


Messages In This Thread
MySQL - Multiple Queries - Any way to chain queries together / execute all in one statement? - by El Forum - 01-08-2011, 06:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB