set sql variable before main query |
Is it possible to set sql variable before other queries?(not $this->db->query())
I'd like to do something like this. PHP Code: $this->db->query("SET @min_id := (SELECT min_id FROM shop_parameter)");
@ash-f,
Yes, it is possible to set sql variable before other queries. The catch is...not the way you have it in your example. There are a couple of ways that you could do it but you would have to use $this->db->query(). With one of those ways, you could actually do it in one query but again it is using the $this->db-query(); PHP Code: $this->db->where('(item_id > @min_id',NULL,FALSE); Are you missing a parentheses / bracket here? What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(02-08-2019, 05:46 PM)php_rocs Wrote: @ash-f, Thanks. I saw something similar and they are using transaction with multiple $this->db-query(). So is that the standard way?
02-12-2019, 11:33 PM
(This post was last modified: 02-13-2019, 09:57 AM by ash-f. Edit Reason: wrong code )
Ok, I've used two successive $this->db->query()
Code: $randomitem=array();
@ash-f,
Documentation for future reference (of query results)... https://codeigniter.com/user_guide/datab...ry-results (02-13-2019, 09:27 PM)php_rocs Wrote: @ash-f, Thank you |
Welcome Guest, Not a member yet? Register Sign In |