Esempio n. 1
0
 /**
  * Erzeugt eine Anfrage, die mehrere Datensätze in die database schreiben soll.
  * @param  array  $querystate Assoziatives Array, welches die Spezifikationen der Anfrage bereitstellt.
  * @return string             MySQL-Anfragenstring
  */
 public function generateMultipleInsertQuery($querystate, $values)
 {
     $this->pushpopState($querystate);
     $db = $this->prepareIdentifier($this->db);
     $table = $this->prepareIdentifier($this->table);
     $fields = $this->fields === '*' ? $this->getColumns() : $this->prepareFields();
     // Sanity check
     if (!count($fields) or !count($values)) {
         $this->popState();
         return '';
     }
     // Query erzeugen
     $query = "INSERT INTO `{$db}`.`{$table}` (" . implode(', ', $fields) . ') VALUES ';
     $rows = array();
     foreach ($values as $row) {
         $rows[] = '(' . implode(',', array_fill(0, count($fields), '?')) . ')';
     }
     $query .= implode(',', $rows);
     // Join anhängen.
     if ($this->join) {
         $query .= ' ' . $this->join->str($db);
     }
     $this->popState();
     return $query;
 }
Esempio n. 2
0
 /**
  * Konvertiert diesen Join in einen String.
  * @param  string $db Name der database, die die Tabelle beinhaltet.
  * @return string     Join-String
  */
 public function str($db)
 {
     // TODO: Erwartet Filter-Klasse zur sichereren Abstrahierung der Anfragen für sowohl den Server als auch den Entwickler.
     $condition = $this->condition;
     if (Config::main()->get('DBO_ENFORCE_COL_DELETED') and !$this->ignoreDeleted) {
         $condition .= ' AND `' . $this->tabname . '`.`DELETED`=0';
     }
     return implode(' ', array($this->jointype, 'JOIN', "`{$db}`.`" . $this->tabname . '`', $condition)) . (!empty($this->more) ? ' ' . $this->more->str($db) : '');
 }