Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. public function getAllbyLink($table, $what, $url)
  2. {
  3. $link=mysql_real_escape_string($url);
  4. $query = $this->db->query("SELECT * FROM ".$table." WHERE ".$what." = '{$link}' LIMIT 0 , 1");
  5.  
  6. if ($query->num_rows() > 0)
  7. {
  8. return $query->result();
  9. }
  10. else redirect('');
  11. }
  12.  
  13. public function getTable($table, $where = array(), $select = '*', $order_by = '', $limit = '', $offset = '') {
  14.  
  15. if ($order_by !== '' && $order_by != 'RANDOM') $this->db->order_by($order_by);
  16. if ($order_by == 'RANDOM') $this->db->order_by('id', 'RANDOM');
  17. if ($limit !== '') $this->db->limit($limit, $offset);
  18. $this->db->select($select);
  19. $q = $this->db->get_where($table, $where);
  20.  
  21. return ($q->num_rows() > 0) ? $q->result() : FALSE;
  22.  
  23. }
  24.  
  25. getTable($talbe, array('what' => $link));
  26. //returns FALSE if no data are selected,
  27. //or returns object with data,
  28.  
  29. public function getTable2($table, $where = array(), $limit = '', $offset = '') {
  30.  
  31. if ($limit !== '') $this->db->limit($limit, $offset);
  32. $q = $this->db->get_where($table, $where);
  33.  
  34. return ($q->num_rows() > 0) ? $q->result() : FALSE;
  35.  
  36. }
  37.  
  38. if (!$my_data = getTable2('table', array('where' => $link))) {
  39. //there is some DATA to work with
  40. echo "<pre>";
  41. var_dump($my_data);
  42. echo "</pre>";
  43.  
  44. } else {
  45. //no DATA do redirect or tell user that there is no DATA
  46. redirect(); //redirect to default_controller
  47. }
  48.  
  49. public function getAllbyLink($table,$url,$what)
  50. {
  51. $query = $this->db->query("
  52. SELECT *
  53. FROM `".$table."`
  54. WHERE `".$what."` = '".mysql_real_escape_string($linkurl)."'
  55. ORDER BY RAND()
  56. LIMIT 1
  57. ");
  58. if( !$query) return redirect('');
  59. $result = $query->result();
  60. if( !$result) return redirect('');
  61. return $result;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement