public function schema($query, $resource = null, $context = null) { if (isset($this->return['schema'])) { return $this->return['schema']; } return parent::schema($query, $resource = null, $context = null); }
public function value($value, array $schema = array()) { if (($result = parent::value($value, $schema)) !== null) { return $result; } return "'{$value}'"; }
/** * Provide an associative array of Closures to be used as the "formatter" key inside of the * `Database::$_columns` specification. * * @see lithium\data\source\Database::_formatters() */ protected function _formatters() { $self = $this; $datetime = $timestamp = function ($format, $value) use($self) { if ($format && ($time = strtotime($value)) !== false) { $val = date($format, $time); if (!preg_match('/^' . preg_quote($val) . '\\.\\d+$/', $value)) { $value = $val; } } return $self->connection->quote($value); }; return compact('datetime', 'timestamp') + array('boolean' => function ($value) use($self) { return $self->connection->quote($value ? 't' : 'f'); }) + parent::_formatters(); }
/** * In cases where the query is a raw string (as opposed to a `Query` object), to database must * determine the correct column names from the result resource. * * @param mixed $query * @param resource $resource * @param object $context * @return array */ public function schema($query, $resource = null, $context = null) { if (is_object($query)) { return parent::schema($query, $resource, $context); } $result = array(); $count = $resource->numColumns(); for ($i = 0; $i < $count; $i++) { $result[] = $resource->columnName($i); } return $result; }
/** * @todo Eventually, this will need to rewrite aliases for DELETE and UPDATE queries, same with * order(). * @param string $conditions * @param string $context * @param array $options * @return void */ public function conditions($conditions, $context, array $options = array()) { return parent::conditions($conditions, $context, $options); }
public function __construct($config = array()) { parent::__construct($config); }
public function value($value, array $schema = array()) { if (is_array($value)) { return parent::value($value, $schema); } return $value; }
public function alias($alias, $context) { if ($context->type() === 'update' || $context->type() === 'delete') { return; } return parent::alias($alias, $context); }
/** * Connects to the database using options provided to the class constructor. * * @return boolean True if the database could be connected, else false */ public function connect() { if (!$this->_config['database']) { throw new ConfigException('No Database configured'); } if (empty($this->_config['dsn'])) { $this->_config['dsn'] = sprintf("sqlite:%s", $this->_config['database']); } return parent::connect(); }
/** * In cases where the query is a raw string (as opposed to a `Query` object), to database must * determine the correct column names from the result resource. * * @param mixed $query * @param resource $resource * @param object $context * @return array */ public function schema($query, $resource = null, $context = null) { if (is_object($query)) { return parent::schema($query, $resource, $context); } $result = array(); $count = mysql_num_fields($resource); for ($i = 0; $i < $count; $i++) { $result[] = mysql_field_name($resource, $i); } return $result; }
/** * * @param string $type * @param object $mysqliResult * @param unknown_type $context * @return array|null */ public function result($type, $mysqliResult, $context) { if (!$mysqliResult instanceof \mysqli_result) { return null; } switch ($type) { case 'next': $result = $mysqliResult->fetch_row(); break; case 'close': $mysqliResult->close(); $result = null; break; default: $result = parent::result($type, $mysqliResult, $context); break; } return $result; }
public function result($type, $resource, $context) { if (!is_object($resource)) { return null; } $result = null; switch ($type) { case 'next': if ($resource instanceof \Iterator) { $row = $resource->next(); if ($row !== false) { $result = $row[0]; } } else { $result = $resource; } if ($result) { $this->getEntityManager()->detach($result); } break; case 'close': unset($resource); break; default: $result = parent::result($type, $resource, $context); break; } return $result; }