/** * @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; }
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; }
/** * @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; }
/** * @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; }