Commit bf235793 authored by Alexander Butenko's avatar Alexander Butenko

Merge pull request #332 from avbdr/master

fixes
parents e0153d7f 12c0a1db
......@@ -396,7 +396,7 @@ class MysqliDb
*/
public function query($query, $numRows = null)
{
$this->_query = filter_var($query, FILTER_SANITIZE_STRING);
$this->_query = $query;
$stmt = $this->_buildQuery($numRows);
$stmt->execute();
$this->_stmtError = $stmt->error;
......@@ -694,7 +694,7 @@ class MysqliDb
die ('Wrong JOIN type: '.$joinType);
if (!is_object ($joinTable))
$joinTable = self::$prefix . filter_var($joinTable, FILTER_SANITIZE_STRING);
$joinTable = self::$prefix . $joinTable;
$this->_join[] = Array ($joinType, $joinTable, $joinCondition);
......
......@@ -11,6 +11,9 @@
* @version 2.2
*
* @method int count ()
* @method dbObject ArrayBuilder()
* @method dbObject JsonBuilder()
* @method dbObject ObjectBuilder()
* @method mixed byId (string $id, mixed $fields)
* @method mixed get (mixed $limit, mixed $fields)
* @method mixed getOne (mixed $fields)
......@@ -181,10 +184,9 @@ class dbObject {
*
* @return dbObject
*/
public static function JsonBuilder () {
$obj = new static;
$obj->returnType = 'Json';
return $obj;
private function JsonBuilder () {
$this->returnType = 'Json';
return $return;
}
/**
......@@ -192,10 +194,9 @@ class dbObject {
*
* @return dbObject
*/
public static function ArrayBuilder () {
$obj = new static;
$obj->returnType = 'Array';
return $obj;
private function ArrayBuilder () {
$this->returnType = 'Array';
return $this;
}
/**
......@@ -204,8 +205,9 @@ class dbObject {
*
* @return dbObject
*/
public static function ObjectBuilder () {
return new static;
private function ObjectBuilder () {
$this->returnType = 'Object';
return $this;
}
/**
......@@ -297,7 +299,7 @@ class dbObject {
*
* @return dbObject|array
*/
private function byId ($id, $fields = null) {
protected function byId ($id, $fields = null) {
$this->db->where (MysqliDb::$prefix . $this->dbTable . '.' . $this->primaryKey, $id);
return $this->getOne ($fields);
}
......@@ -310,7 +312,7 @@ class dbObject {
*
* @return dbObject
*/
private function getOne ($fields = null) {
protected function getOne ($fields = null) {
$this->processHasOneWith ();
$results = $this->db->ArrayBuilder()->getOne ($this->dbTable, $fields);
if ($this->db->count == 0)
......@@ -340,7 +342,7 @@ class dbObject {
*
* @return array Array of dbObjects
*/
private function get ($limit = null, $fields = null) {
protected function get ($limit = null, $fields = null) {
$objects = Array ();
$this->processHasOneWith ();
$results = $this->db->ArrayBuilder()->get ($this->dbTable, $limit, $fields);
......@@ -409,9 +411,11 @@ class dbObject {
*
* @return int
*/
private function count () {
protected function count () {
$res = $this->db->ArrayBuilder()->getValue ($this->dbTable, "count(*)");
return $res['cnt'];
if (!$res)
return 0;
return $res;
}
/**
......@@ -608,6 +612,9 @@ class dbObject {
case "int":
$regexp = "/^[0-9]*$/";
break;
case "double":
$regexp = "/^[0-9\.]*$/";
break;
case "bool":
$regexp = '/^[yes|no|0|1|true|false]$/i';
break;
......
......@@ -141,6 +141,12 @@ if (!is_array ($products[0]['userId']) || !is_array ($products[1]['userId'])) {
exit;
}
$products = product::with('userId')->ArrayBuilder()->get(2);
if (!is_array ($products[0]['userId']) || !is_array ($products[1]['userId'])) {
echo "Error in with processing in get";
exit;
}
$depts = product::join('user')->orderBy('`products`.id', 'desc')->get(5);
foreach ($depts as $d) {
if (!is_object($d)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment