Welcome Guest, Not a member yet? Register   Sign In
convert value from routes/uri to string
#9

(04-15-2019, 06:26 PM)DELE Wrote: if you are willing to help me to change it to a query builder I am very happy.
PHP Code:
   public function user_campaign($key$value)
 
   {
 
       return $this->db->query("
            SELECT *
            FROM (
                SELECT *
                FROM users
                WHERE 
$key = $value
            ) users_campaigns
            INNER JOIN campaigns
            ON users_campaigns.id = campaigns.id
        "
)->row();
 
   

I don't see why you are using the sub-select. Here is how to do the above using Query Builder, but without the sub-select.

PHP Code:
   public function user_campaign($key$value)
 
   {
 
       return $this->db
            
->where($key$value)
 
           ->join('campaigns''users_campaigns.id = campaigns.id''inner')
 
           ->get('users')
 
           ->row();
 
   
Reply


Messages In This Thread
convert value from routes/uri to string - by DELE - 04-13-2019, 01:42 AM
RE: convert value from routes/uri to string - by dave friend - 04-16-2019, 07:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB