• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySQL Query using ?deprecated? syntax

#1
[eluser]AIM-andrew[/eluser]
I'm having trouble adapting existing code to new requirements.
Furthermore, I do not know which version of codeigniter I'm supporting.

Here is the existing code:
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 method is called from the model layer to add $new_to_user_id to the To: array of addresses of an email.

Our email system has changed and this is the troublesome code:
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;
}


My predecessor's SELECT statement is bizarre in how they have used multiple lines. I have attempted to follow their syntax. All I need from the database is instead of username I want the corresponding firstname and lastname of the $new_to_user_id.

I'd posted previously, but the talk of Active Record was whizzing over my head.

Any advise is greatly appreciated.
Thanx in advance.


Messages In This Thread
MySQL Query using ?deprecated? syntax - by El Forum - 08-22-2009, 06:55 AM
MySQL Query using ?deprecated? syntax - by El Forum - 08-22-2009, 10:47 AM
MySQL Query using ?deprecated? syntax - by El Forum - 08-22-2009, 12:24 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.