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.
 
 
 

62 lines
971 B

<?php
/**
* @package uForum2
* @file inc/model.class.php
* @copyright 2007-2015 (c) PioDer
* @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;
}
}
?>