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.

55 lines
855 B

  1. <?php
  2. require_once('./inc/askModel.class.php');
  3. abstract class Model extends AskModel
  4. {
  5. protected $db;
  6. function __construct(&$db)
  7. {
  8. $this->db = $db;
  9. }
  10. public function select($table, $what='*', $where = '', $sorting = '', $limit = '')
  11. {
  12. $sql="SELECT $what FROM $table";
  13. if ($where != '')
  14. $sql .= " WHERE $where";
  15. if($sorting != '')
  16. $sql .= " ORDER BY $sorting";
  17. if($limit != '')
  18. $sql .= " LIMIT $limit";
  19. $result = $this->db->query($sql);
  20. $out = array();
  21. if ($result->num_rows > 0)
  22. {
  23. while ($row = $result->fetch_assoc())
  24. {
  25. $out[]=$row;
  26. }
  27. }
  28. return $out;
  29. }
  30. public function select_query($sql)
  31. {
  32. $result = $this->db->query($sql);
  33. $out = array();
  34. if ($result->num_rows > 0)
  35. {
  36. while ($row = $result->fetch_assoc())
  37. {
  38. $out[]=$row;
  39. }
  40. }
  41. return $out;
  42. }
  43. }