<?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;
|
|
}
|
|
}
|