Codeigniter error using mysql set variable

Hey guy i have a little problem with codeigniter, i dont know how. If you have any solution regarding this then please answer me

SET @weekVideoCount := (SELECT COUNT(*) FROM videos v 
);

SELECT @weekVideoCount;

      

When I execute this query on Sqlyog, the result is shown successfully, but if I call this query on a model like this,

function getWeeklyUserData(){
        $query= $this->db->query("SET @weekVideoCount := (SELECT COUNT(*) FROM videos v);
                                SELECT @weekVideoCount;
                                ");
        return $query->result();
    }

      

error spawned

enter image description here

+3


source to share


2 answers


Try to separate the request



 $this->db->query("SET @weekVideoCount := (SELECT COUNT(*) FROM videos v)");
 $query= $this->db->query("SELECT @weekVideoCount");

      

+10


source


you should know that $ this-> db-> query () only executes one SQL query like mysql_query.



+2


source







All Articles