Welcome Guest, Not a member yet? Register   Sign In
Using MYSQL functions in CI Database Library.
#1

[eluser]Rey Philip Regis[/eluser]
Hi guys,

Ive browsed the user guide for CI database library and I was looking for an active record function that can execute a mysql function using CI's database library. An example of the query is

"Select group_concat(lead_id) from list where phone = '2552200'"

I need an active record function that can execute the group_concat function of MYSQL. Does anybody know how to do it in CI? Or I will just have to settle using custom query.

Thanks in advance.

Good day.
#2

[eluser]Thorpe Obazee[/eluser]
Code:
$this->db->select("SELECT group_concat(lead_id) FROM list WHERE phone = '2552200'",  FALSE);

I think this will be it. I don't think you can use some of the functions in AR. You will have to build your own.
#3

[eluser]Developer13[/eluser]
$this->db->select('group_concat(lead_id)', FALSE);
$this->db->where('phone', '2552200');
$query = $this->db->get('list');
#4

[eluser]Thorpe Obazee[/eluser]
[quote author="Developer13" date="1227684798"]$this->db->select('group_concat(lead_id)', FALSE);
$this->db->where('phone', '2552200');
$query = $this->db->get('list');[/quote]

Tongue
#5

[eluser]Rey Philip Regis[/eluser]
Thanks for the reponse..
#6

[eluser]soupdragon[/eluser]
thanks had the same problem with Count

$this->db->select('sellers.id, sellers.firmname,sellers.city,COUNT(records2sellers.recordid)');

gave errors !

Whereas this works fine
$this->db->select('sellers.id, sellers.firmname,sellers.city');
$this->db->select(' COUNT(records2sellers.recordid)',FALSE);




Theme © iAndrew 2016 - Forum software by © MyBB