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

#2
[eluser]steelaz[/eluser]
Is there a reason why you don't want to join firstname and lastname strings after you get them from database (below)?

Code:
public function addToUserId($email, $new_to_user_id)
{
     $this->db->select('firstname', 'lastname');
     $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]->firstname .'.'. $results[0]->lastname;
}

Also, if you're expecting just one result, instead of using result(), you can use row():

Code:
public function addToUserId($email, $new_to_user_id)
{
     $this->db->select('firstname', 'lastname');
     $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);
     $result = $this->db->get()->row();

     $email_to = $email->getTo();
     $email_to[] = $result->firstname .'.'. $result->lastname;
}


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.