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.
 
 
 

56 lines
855 B

<?php
require_once('./inc/askModel.class.php');
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;
}
}