mirror of
https://github.com/idanoo/nzart-exam-generator
synced 2025-07-03 14:52:17 +00:00
User login progress
This commit is contained in:
parent
4b01dc70ec
commit
0c6a5f3833
7 changed files with 158 additions and 51 deletions
|
@ -2,12 +2,6 @@
|
|||
|
||||
class DataItem {
|
||||
|
||||
protected $_db;
|
||||
|
||||
function __construct() {
|
||||
$this->_db = new db(); //Will optimise this to get existing conn at some point.
|
||||
}
|
||||
|
||||
public static function getById($id) {
|
||||
$db = new db();
|
||||
$db->query("SELECT * FROM `".static::_getType()."` WHERE ".static::_getType()."_id = :id");
|
||||
|
@ -22,15 +16,14 @@ class DataItem {
|
|||
return $obj;
|
||||
}
|
||||
|
||||
private function _getAllWhere($where = false, $orderBy = false, $join = false, $limit = false) {
|
||||
$Objarr = array();
|
||||
$typeName = static::_getType();
|
||||
$className = static::_getClass();
|
||||
$this->_db->query("SELECT * FROM `".$typeName."` ".($join?$join:"").($where?" WHERE ".$where."":"")." ".($orderBy?" ".$orderBy." ":" ").($limit?"LIMIT ".$limit:""));
|
||||
$results = $this->_db->resultset();
|
||||
public static function getAllWhere($where = false, $orderBy = false, $join = false, $limit = false) {
|
||||
$Objarr = [];
|
||||
$db = new db();
|
||||
$db->query("SELECT * FROM `".static::_getType()."` ".($join?$join:"").($where?" WHERE ".$where."":"")." ".($orderBy?" ".$orderBy." ":" ").($limit?"LIMIT ".$limit:""));
|
||||
$results = $db->resultset();
|
||||
if(!$results) return false;
|
||||
foreach ($results as $result) {
|
||||
$obj = new $className();
|
||||
$obj = new static();
|
||||
foreach ($result as $key=>$val) {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
|
@ -39,30 +32,18 @@ class DataItem {
|
|||
return $Objarr;
|
||||
}
|
||||
|
||||
public static function getAllWhere($where = false, $orderBy = false, $join = false, $limit = false) {
|
||||
$me = new static();
|
||||
return $me->_getAllWhere($where, $orderBy, $join, $limit);
|
||||
}
|
||||
|
||||
private function _getWhere($where = false, $orderBy = false, $join = false, $limit = false) {
|
||||
$typeName = static::_getType();
|
||||
$className = static::_getClass();
|
||||
$this->_db = new db();
|
||||
$this->_db->query("SELECT * FROM `".$typeName."` ".($join?$join:"").($where?" WHERE ".$where."":"")." ".($orderBy?" ".$orderBy."":"").($limit?"LIMIT ".$limit:""));
|
||||
$result = $this->_db->single();
|
||||
public static function getWhere($where = false, $orderBy = false, $join = false, $limit = false) {
|
||||
$db = new db();
|
||||
$db->query("SELECT * FROM `".static::_getType()."` ".($join?$join:"").($where?" WHERE ".$where."":"")." ".($orderBy?" ".$orderBy."":"").($limit?"LIMIT ".$limit:""));
|
||||
$result = $db->single();
|
||||
if(!$result) return false;
|
||||
$obj = new $className();
|
||||
$obj = new static();
|
||||
foreach ($result as $key=>$val) {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function getWhere($where = false, $orderBy = false, $join = false, $limit = false) {
|
||||
$me = new static();
|
||||
return $me->_getWhere($where, $orderBy, $join, $limit);
|
||||
}
|
||||
|
||||
public function getId() {
|
||||
$typeName = static::_getType();
|
||||
$id = $typeName."_id";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue