public function constraint($type, $columnName, $options = array()) { $index = $this->indexOfConstraint($type, $columnName); if ($index > -1) { $constraint = $this->constraints[$index]; } else { $string = new Midori_String($type); $class = "Midori_Data_" . $string->camelize() . "Constraint"; $tableAlias = is_null($this->tableAlias) ? $this->tableName : $this->tableAlias; $constraint = new $class($this->tableName, $tableAlias, $columnName); } $constraint->send($options); if ($index == -1) { $this->constraints->add($constraint); } }
public function insert($table, $values) { $transaction = $this->beginTransaction(); $id = null; try { $sql = new \Midori\String("INSERT INTO {$this->quoteIdentifier($table)} "); $columns = new Midori_String(" ("); $fields = new Midori_String(" VALUES ("); foreach ($values as $column => $field) { $columns->append($this->quoteIdentifier($column) . ","); $temp = $this->quote($field); $fields->append($temp . ","); } $sql->append($columns->trimEnd(",")->append(")")); $sql->append($fields->trimEnd(",")->append(");")); $query = $sql->__toString(); $this->log->sql($query); //echo "inserting: $query <br />"; $stmt = $this->driver->exec($query); if ($this->supportsLastId) { $id = $this->selectOne($this->getLastInsertId()); } if ($transaction) { $this->commit(); } } catch (Exception $ex) { //if($transaction) // $this->rollback(); throw $ex; } return $id; }
public function getErrorMessage() { $string = new Midori_String($this->propertyName); return sprintf($this->message, $string->titleize(true), $this->min, $this->max); }
private static function _load($fixture) { $string = new Midori_String($fixture); if ($string->startsWith("_config.")) { $class = ""; $path = self::$fixturesFilePath . "{$string->toString(false)}.php"; } else { $class = $string->camelize(); $path = self::$fixturesFilePath . $fixture . ".php"; } self::parse($path); }