<?php
class DBQuery extends go\DB\DB {
private $sSelected='SELECT ?col FROM ?table WHERE ?where';
private $sMultiSelected='SELECT * FROM ?table WHERE ?where';
private $sMultiSelectedLim='SELECT * FROM ?table WHERE ?where LIMIT 1';
private $sInsertInto='INSERT INTO ?table SET ?set';
private $sDeleted='DELETE FROM ?table WHERE ?where';
private $sUpdated='UPDATE FROM ?table SET ?set WHERE ?where';
private $sInnerJoin='SELECT ?col FROM ?table INNER JOIN ?table ON ?where';
private $aWhere;
private $sTable;
private $sTableInnerJoin;
private $sCol;
private $aSet;
function __construct($sTable,$aWhere=0,$sCol=0,$aSet=0,$sTableInnerJoin=0) {
$this->sTable=$sTable;
$this->aWhere=$aWhere;
$this->sCol=$sCol;
$this->aSet=$aSet;
$this->sTableInnerJoin=$sTableInnerJoin;
}
protected function dbcreated(){
return go\DB\DB::create(Core::$params);
}
private function selected(){
return $this->dbcreated()->query($this->sSelected, array($this->sCol, $this->sTable, $this->aWhere));
}
private function multiSelected($lim=0){
if($lim==0){
return $this->dbcreated()->query($this->sMultiSelected,array($this->sTable, $this->aWhere));
}else{
return $this->dbcreated()->query($this->sMultiSelectedLim,array($this->sTable, $this->aWhere));
}
}
private function inserinto(){
return $this->dbcreated()->query($this->sInsertInto,array($this->sTable, $this->aSet));
}
private function update(){
return $this->dbcreated()->query($this->sUpdated,array($this->sTable, $this->aSet, $this->aWhere));
}
private function delete(){
return $this->dbcreated()->query($this->sDeleted,array($this->sTable, $this->aWhere));
}
private function innerjoin(){
return $this->dbcreated()->query($this->sInnerJoin,array($this->sCol, $this->sTable, $this->sTableInnerJoin, $this->aWhere));
}
/*
* $lim - переменная добавляет в запрос select LIMIT 1
*/
public function readyquery($condition,$limit=0){
if($condition=='SELECT'){
return $this->selected();
}elseif ($condition=='MULTISELECT') {
if($limit==0){
return $this->multiSelected();
} else {
return $this->multiSelected($lim=1);
}
}elseif ($condition=='INSERT INTO') {
return $this->inserinto();
}elseif ($condition=='DELETE') {
return $this->delete();
} elseif($condition=='UPDATE'){
return $this->update();
}elseif ($condition=='INNER JOIN') {
return $this->innerjoin();
}else {
echo 'Not the correct inquiry';
}
}
}
@artoodetoo, ошибка где то вот здесь, но я её ни как не могу найти. Если вам не трудно, могли бы вы посмотреть ?