• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database queries

#1
[eluser]ozy123[/eluser]
I have a general question regarding model functions.

So I have some data I want to present in two tables. Right now I've coded a new function everytime I need slightly different data from the same table. I'm just wondering if this is the right way to do things or if there is a better way? I know that's a vague question but I get the feeling I'm doing something wrong.

// Retrieves bookings where status: 2/3/4
public function get_bookings($userid)
{
$query = $this->db->query("select * from booking where (status = 2 or status = 3 or status = 4) and uid = '$userid' and date >= CURDATE() order by Date");
return $query->result_array();
}

// Retrieves bookings where status 3 limit to three

public function get_bookingsl($userid)
{
$query = $this->db->query("select * from booking where status = 3 and uid = '$userid' order by Date LIMIT 3");
return $query->result_array();
}

// Retrieves bookings where status 3 and date < current date

public function get_complete_bookings($userid)
{
$query = $this->db->query("select * from booking where status = 3 and date < CURDATE() and uid = '$userid' order by Date DESC");
return $query->result_array();
}


Messages In This Thread
Database queries - by El Forum - 07-09-2012, 05:28 AM
Database queries - by El Forum - 07-09-2012, 08:06 AM
Database queries - by El Forum - 07-10-2012, 12:27 AM
Database queries - by El Forum - 07-10-2012, 12:39 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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