CodeIgniter Forums
need help with sql query using Active Record plz - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: need help with sql query using Active Record plz (/showthread.php?tid=27319)



need help with sql query using Active Record plz - El Forum - 02-07-2010

[eluser]Abu eldahab[/eluser]
Hello All, when i'm testing this query in phpmyadmin it's work fine
Code:
SELECT  `tariffdesc` , SUM(  `duration` ) AS duration, SUM(  `cost` ) AS cost, COUNT(  `id_call` ) AS id_call
FROM  `calls`
WHERE  `caller_id` =  'moh'
GROUP BY  `tariffdesc`


the problem i tried to use Active Recored to get same data from my table i failed to make it work


any help with this query ?

Regards


need help with sql query using Active Record plz - El Forum - 02-07-2010

[eluser]davidbehler[/eluser]
Code:
$this->db->select('tariffdesc');
$this->db->select('SUM(duration) AS duration', FALSE);
$this->db->select('COUNT(id_call) AS id_call', FALSE);
$this->db->from('calls');
$this->db->where('caller_id', 'moh');
$this->db->group_by('tariffdesc');

have fun Smile


need help with sql query using Active Record plz - El Forum - 02-07-2010

[eluser]Abu eldahab[/eluser]
[quote author="waldmeister" date="1265584630"]
Code:
$this->db->select('tariffdesc');
$this->db->select('SUM(duration) AS duration', FALSE);
$this->db->select('COUNT(id_call) AS id_call', FALSE);
$this->db->from('calls');
$this->db->where('caller_id', 'moh');
$this->db->group_by('tariffdesc');

have fun Smile[/quote]


Dear waldmeister ,

Thank you very much for your help

Best Regards


need help with sql query using Active Record plz - El Forum - 06-29-2011

[eluser]mineass[/eluser]
[quote author="waldmeister" date="1265584630"]
Code:
$this->db->select('tariffdesc');
$this->db->select('SUM(duration) AS duration', FALSE);
$this->db->select('COUNT(id_call) AS id_call', FALSE);
$this->db->from('calls');
$this->db->where('caller_id', 'moh');
$this->db->group_by('tariffdesc');

have fun Smile[/quote]

if u use false in select once, AR will not escape any of other lines in this query