A new, object-oriented, better vesion of μForum
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
971 B

  1. <?php
  2. /**
  3. * @package uForum2
  4. * @file inc/model.class.php
  5. * @copyright 2007-2015 (c) PioDer
  6. * @link http://www.pioder.pl/
  7. * @license see LICENSE.txt
  8. **/
  9. abstract class Model extends AskModel
  10. {
  11. protected $db;
  12. function __construct(&$db)
  13. {
  14. $this->db = $db;
  15. }
  16. public function select($table, $what='*', $where = '', $sorting = '', $limit = '')
  17. {
  18. $sql="SELECT $what FROM $table";
  19. if ($where != '')
  20. $sql .= " WHERE $where";
  21. if($sorting != '')
  22. $sql .= " ORDER BY $sorting";
  23. if($limit != '')
  24. $sql .= " LIMIT $limit";
  25. $result = $this->db->query($sql);
  26. $out = array();
  27. if ($result->num_rows > 0)
  28. {
  29. while ($row = $result->fetch_assoc())
  30. {
  31. $out[]=$row;
  32. }
  33. }
  34. return $out;
  35. }
  36. public function select_query($sql)
  37. {
  38. $result = $this->db->query($sql);
  39. $out = array();
  40. if ($result->num_rows > 0)
  41. {
  42. while ($row = $result->fetch_assoc())
  43. {
  44. $out[]=$row;
  45. }
  46. }
  47. return $out;
  48. }
  49. }
  50. ?>