Esempio n. 1
0
 /**
  * Reset all objects
  */
 public function reset()
 {
     $this->CommonQuery->reset();
     $this->SelectQuery->reset();
     $this->UpdateQuery->reset();
     $this->InsertQuery->reset();
     $this->DeleteQuery->reset();
 }
Esempio n. 2
0
 /**
  * @return string
  */
 public function parse()
 {
     $this->sql = "INSERT INTO " . $this->getTableName();
     $this->sql .= " (" . $this->implodeValues($this->columns);
     $this->sql .= ") VALUES (" . $this->implodeApostropheValues($this->values);
     $this->sql .= ")";
     parent::parse();
     return $this->sql;
 }
Esempio n. 3
0
 public function parse()
 {
     $this->sql = "UPDATE ";
     $this->sql .= sprintf("\n%s \n\t", ltrim($this->parseFrom()->from, "FROM "));
     if (!empty($this->join)) {
         $this->sql .= $this->join;
     }
     $this->sql .= "SET ";
     foreach ($this->columns as $k => &$clm) {
         $this->sql .= sprintf("%s='%s'", $clm, addslashes($this->set[$k]));
         $this->sql .= ", ";
     }
     $this->sql = trim($this->sql, ", ");
     //WHERE
     $this->sql = $this->concatValues($this->sql, $this->parseWhere()->where);
     parent::parse();
     return $this->sql;
 }
Esempio n. 4
0
 /**
  * @param CommonQuery $Common
  * @param bool|true $all
  * @return array|bool
  */
 public function execute(CommonQuery $Common, $all = true)
 {
     $sql = $Common->parse();
     $pdo = $this->Connection->getPDO()->prepare($sql);
     $ex = $pdo->execute();
     if ($Common->type == $Common::TYPE_ACTION_SELECT) {
         $ret = [];
         if ($ex) {
             if ($all) {
                 while ($l = $pdo->fetch($this->fetch)) {
                     $ret[] = new Fields($l);
                 }
             } else {
                 $ret = $pdo->fetch($this->fetch);
             }
         }
         return $ret;
     }
     return $ex;
 }
Esempio n. 5
0
 /**
  * @return string
  */
 public function parse()
 {
     //SELECT
     $this->sql = sprintf("%s \n\t", $this->getSelectType());
     $this->sql .= $this->fields;
     //FROM
     $this->sql .= sprintf("\n%s \n\t", $this->parseFrom()->from);
     //JOIN
     //$this->sql .= sprintf("\n%s \n\t", $this->join);
     $this->sql = $this->concatValues($this->sql, $this->join);
     //WHERE
     //$this->sql .= sprintf("\n%s \n\t", $this->parseWhere()->where);
     $this->sql = $this->concatValues($this->sql, $this->parseWhere()->where);
     //GROUP
     //$this->sql .= sprintf("\n%s \n\t", $this->group);
     $this->sql = $this->concatValues($this->sql, $this->group);
     //HAVING
     //$this->sql .= sprintf("\n%s \n\t", $this->having);
     $this->sql = $this->concatValues($this->sql, $this->having);
     //LIMIT
     //$this->sql .= sprintf("\n%s \n\t", $this->limit);
     $this->sql = $this->concatValues($this->sql, $this->limit);
     //ORDER
     $this->sql = $this->concatValues($this->sql, $this->order);
     $this->sql = trim($this->sql);
     parent::parse();
     return $this->sql;
 }