initial commit with snapshot 20140213
This commit is contained in:
56
inc/model.class.php
Normal file
56
inc/model.class.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user