Welcome Guest, Not a member yet? Register   Sign In
Using CONCAT() in active record
#10

[eluser]AIM-andrew[/eluser]
I have a similar problem but I'm struggling with syntax.
This is my predecessor's code (which works-if the wrong way now):
Code:
public function addToUserId($email, $new_to_user_id) {
     $this->db->select('username');
     $this->db->from('fa_user');
     $this->db->from('user');
     $this->db->where('fa_user_id = id');
     $this->db->where('user_id', $new_to_user_id);
     $results = $this->db->get()->result();

     $email_to = $email->getTo();
     $email_to[] = $results[0]->username;
}
This is the code I wish to implement:
Code:
public function addToUserId($email, $new_to_user_id) {
     // SFPD uses [email protected] format
     // $this->db->select('username');
     $this->db->select('CONCAT (firstname, \'.\', lastname) AS full_name');
     $this->db->from('fa_user');
     $this->db->from('user');
     $this->db->where('fa_user_id = id');
     $this->db->where('user_id', $new_to_user_id);
     $results = $this->db->get()->result();

     $email_to = $email->getTo();
     // $email_to[] = $results[0]->username;
     $email_to[] = $results[0]->full_name;
}
This method retrieved the username based on the user_id currently logged in and appends a static domain (another method). Now we want to retrieve the firstname(dot)lastname combination as per the new email address format.

Any advise?
thx in advance


Messages In This Thread
Using CONCAT() in active record - by El Forum - 02-13-2009, 02:19 PM
Using CONCAT() in active record - by El Forum - 02-13-2009, 03:15 PM
Using CONCAT() in active record - by El Forum - 02-13-2009, 03:51 PM
Using CONCAT() in active record - by El Forum - 02-13-2009, 07:06 PM
Using CONCAT() in active record - by El Forum - 05-14-2009, 12:44 PM
Using CONCAT() in active record - by El Forum - 05-14-2009, 01:03 PM
Using CONCAT() in active record - by El Forum - 05-14-2009, 01:25 PM
Using CONCAT() in active record - by El Forum - 05-14-2009, 01:48 PM
Using CONCAT() in active record - by El Forum - 08-13-2009, 02:38 AM
Using CONCAT() in active record - by El Forum - 08-14-2009, 11:05 AM
Using CONCAT() in active record - by El Forum - 08-18-2009, 03:33 AM
Using CONCAT() in active record - by El Forum - 08-18-2009, 02:49 PM
Using CONCAT() in active record - by El Forum - 08-18-2009, 03:03 PM
Using CONCAT() in active record - by El Forum - 08-26-2013, 09:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB