Welcome Guest, Not a member yet? Register   Sign In
Executing This Kind of SQL
#1

[eluser]IanMcQ[/eluser]
I'd like execute this kind of SQL code in a CodeIgniter method:

Code:
SET @uids := '';

UPDATE table_name
   SET some_col= 'some_val'
WHERE some_col= 'some_val'
   AND ( SELECT @uids := CONCAT_WS(',', @uids, id) );

SELECT TRIM(LEADING ',' FROM @uids);

The issue is that $this->db->query() doesn't play friendly with this kind of SQL (for obvious reasons). How might I go about executing this "routine" through CodeIgniter's database library? I'm not familiar enough with CodeIgniter's Active Record to know myself.

Thanks in advanced. Smile I love CodeIgniter.
#2

[eluser]jmadsen[/eluser]
You can't send multiple sql statements via a single query in php, so you will need to write a stored procedure & execute that. Otherwise your @uids variable is "stateless" and will never be available for the later queries.




Theme © iAndrew 2016 - Forum software by © MyBB