|
|
- <?php
- /**
- * @package uForum2
- * @file inc/model.class.php
- * @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
- * @link http://www.pioder.pl/
- * @license see LICENSE.txt
- **/
-
- abstract class Model extends AskModel
- {
- protected $db;
-
- function __construct(&$db)
- {
- $this->db = $db;
- }
-
- public function select($table, $what='*', $where = '', $sorting = '', $limit = '')
- {
- $sql="SELECT $what FROM $table";
-
- if ($where != '')
- $sql .= " WHERE $where";
-
- if($sorting != '')
- $sql .= " ORDER BY $sorting";
-
- if($limit != '')
- $sql .= " LIMIT $limit";
-
- $result = $this->db->query($sql);
-
- $out = array();
- if ($result->num_rows > 0)
- {
- while ($row = $result->fetch_assoc())
- {
- $out[]=$row;
- }
- }
-
- return $out;
- }
-
- public function select_query($sql)
- {
- $result = $this->db->query($sql);
-
- $out = array();
- if ($result->num_rows > 0)
- {
- while ($row = $result->fetch_assoc())
- {
- $out[]=$row;
- }
- }
-
- return $out;
- }
- }
- ?>
|