CodeIgniter Forums
Database: Mutliple consecutive queries in same thread? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database: Mutliple consecutive queries in same thread? (/showthread.php?tid=47456)



Database: Mutliple consecutive queries in same thread? - El Forum - 12-09-2011

[eluser]Rob Corley[/eluser]
Hello,

I am wondering if multiple consecutive $db->query() calls are always going to be called in the same MYSQL thread?

For example if I execute the following code, will it always work:-

Code:
$this->db->query('SET @var=1');
$this->db->query('SELECT @var');

The reason for doing this is I want to setup record versioning using MYSQL triggers, but I want to be able to include the user id in the trigger. So I need to save this in a mysql user variable each time I run a query on the versioned tables.

I guess if the answer is no, then I will need to use transactions.