setting mysql user-defined variable with query-builder
codeigniter, mysql, php, variables
Solution
Try separate the query
$this->db->query("SET @weekVideoCount := (SELECT COUNT(*) FROM videos v)");
$query= $this->db->query("SELECT @weekVideoCount");
Problem
I have an issue with setting mysql user-defined variables with codeigniter. How am I able to use SET with CI query builder? ``` SET @weekVideoCount := (SELECT COUNT(*) FROM videos v ); SELECT @weekVideoCount; ``` When I execute this Query on Sqlyog the result will be successfully shown but if I call this Query in the model like this ``` function getWeeklyUserData(){ $query= $this->db->query("SET @weekVideoCount := (SELECT COUNT(*) FROM videos v); SELECT @weekVideoCount; "); return $query->result(); } ``` the error has generated