/** * {@inheritdoc} */ public function toString(Quoter $quoter) { return E::interpolate($this->expr, $this->vars, $quoter); }
/** * Interpolate variables. * See {@see Condition::interpolate}. * * @param string $query * Query. * @param array $vars * Variables. * @return string Interpolated query. */ protected function escapeQuery($query, $vars = array()) { return E::interpolate($query, $vars, $this->owner); }
/** * Convert a schema type to an SQLite type * * @param DataType $type * Type. * @param bool $isPrimaryKey * True if primary key. * @return string SQLite type. */ public function fromDataType(DataType $type, $isPrimaryKey = false) { $primaryKey = ''; if ($isPrimaryKey) { $primaryKey = ' PRIMARY KEY'; } switch ($type->type) { case DataType::INTEGER: if ($type->size == DataType::BIG) { $column = 'INTEGER(8)'; } elseif ($type->size == DataType::SMALL) { $column = 'INTEGER(2)'; } elseif ($type->size == DataType::TINY) { $column = 'INTEGER(1)'; } else { $column = 'INTEGER'; } if ($isPrimaryKey and $type->serial) { $primaryKey .= ' AUTOINCREMENT'; } break; case DataType::FLOAT: $column = 'REAL'; break; case DataType::STRING: $column = 'TEXT(' . $type->length . ')'; break; case DataType::BOOLEAN: $column = 'INTEGER(1)'; break; case DataType::BINARY: $column = 'BLOB'; break; case DataType::DATE: $column = 'INTEGER'; break; case DataType::DATETIME: $column = 'INTEGER'; break; case DataType::TEXT: case DataType::ENUM: case DataType::OBJECT: default: $column = 'TEXT'; break; } $column .= $primaryKey; if ($type->notNull) { $column .= ' NOT'; } $column .= ' NULL'; if (isset($type->default)) { $column .= E::interpolate(' DEFAULT %_', array($type, $type->default), $this->db); } return $column; }