query in codeIgniter style
- by troy
I have below query:
SET @sql = NULL ;
SELECT GROUP_CONCAT( DISTINCT CONCAT( 'select latitude,longitude,max(serverTime) as serverTime,', deviceID, ' AS device from d', deviceID, '_gps' )
SEPARATOR ' UNION ALL ' )
INTO @sql
FROM devices
WHERE accountID =2;
PREPARE stmt FROM @sql ;
EXECUTE stmt;
Can someone help me to write the above query in codeIgniter style....
ANd another thing is :What is the difference between writing the query in 1 and 2 formats
1. $query = $this->db->query('YOUR QUERY HERE');
2. $this->db->select("...");
$this->db->from();
$this->db->where();
Will it have any effect on performance if we use 2nd style... Thank You