public function select($part)
{
$this->selectLang[] = 'select '.$part;
return $this;
}
public function from($part)
{
$this->selectLang[] = 'from '.$part;
$this->RES = mysqli_query($this->CONN, implode(' ', $this->selectLang));
return $this;
}
public function where($part)
{
$this->selectLang[] = 'where '.$part;
$this->RES = mysqli_query($this->CONN, implode(' ', $this->selectLang));
return $this;
}
public function fetchArrayOne()
{
return mysqli_fetch_array($this->RES, MYSQLI_ASSOC);
}
public function fetchArrayAll()
{
$rows = array();
while($row = mysqli_fetch_array($this->RES, MYSQLI_ASSOC)) $rows[] = $row;
return $rows;
}
public function fetchObjOne()
{
return mysqli_fetch_object($this->RES);
}
public function update($part)
{
$this->updateLang[] = 'update '.$part;
return $this;
}
public function set($part)
{
$this->updateLang[] = 'set '.$part;
return $this;
}
public function uWhere($part)
{
$this->updateLang[] = 'where '.$part;
return $this;
}
public function execute()
{
mysqli_query($this->CONN, implode(' ', $this->updateLang));
}
public function insert($part)
{
$this->insertLang[] = 'insert into '.$part;
return $this;
}
public function fields($part)
{
$this->insertLang[] = '('.$part.')';
return $this;
}
public function values($part)
{
$this->insertLang[] = 'values'.'('.$part.')';
mysqli_query($this->CONN, implode(' ', $this->insertLang));
}
public function delete()
{
$this->deleteLang[] = 'delete ';
return $this;
}
public function dForm($part)
{
$this->deleteLang[] = 'from '.$part;
return $this;
}
public function dWhere($part)
{
$this->deleteLang[] = 'where '.$part;
mysqli_query($this->CONN, implode(' ', $this->deleteLang));
}
}
/*
* example
* include DB select,update,insert,datele operation demo.
* must has database table and configure connect database user with password.
*/
$a = new db_class();
//select example
$a->select('*')->from('test')->where("name = 'joan'")->fetchArrayAll();
//update example
$a->update('test')->set("name = Evans")->uWhere("id = '5'");
//insert example
$a->insert('test')->fields('name,text')->values("'Alex', 'hello Alex'");