Phalcon datamapper
NOTE
All classes are prefixed with Phalcon
DataMapper\Pdo\Connection¶
-
Namespace
Phalcon\DataMapper\Pdo
-
Uses
InvalidArgumentException
Phalcon\DataMapper\Pdo\Connection\AbstractConnection
Phalcon\DataMapper\Pdo\Profiler\Profiler
Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface
-
Extends
AbstractConnection
-
Implements
Provides array quoting, profiling, a new perform()
method, new fetch*()
methods
Properties¶
Methods¶
public function __construct( string $dsn, string $username = null, string $password = null, array $options = [], array $queries = [], ProfilerInterface $profiler = null );
This overrides the parent so that it can take connection attributes as a constructor parameter, and set them after connection.
The purpose of this method is to hide sensitive data from stack traces. Connects to the database. Disconnects from the database.DataMapper\Pdo\Connection\AbstractConnection ¶
-
Namespace
Phalcon\DataMapper\Pdo\Connection
-
Uses
BadMethodCallException
Phalcon\DataMapper\Pdo\Exception\CannotBindValue
Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface
-
Extends
-
Implements
ConnectionInterface
Provides array quoting, profiling, a new perform()
method, new fetch*()
methods
Properties¶
Methods¶
Proxies to PDO methods created for specific drivers; in particular,sqlite
and pgsql
. Begins a transaction. If the profiler is enabled, the operation will be recorded. Commits the existing transaction. If the profiler is enabled, the operation will be recorded. Connects to the database. Disconnects from the database. Gets the most recent error code. Gets the most recent error info. Executes an SQL statement and returns the number of affected rows. If the profiler is enabled, the operation will be recorded. Performs a statement and returns the number of affected rows. Fetches a sequential array of rows from the database; the rows are returned as associative arrays. Fetches an associative array of rows from the database; the rows are returned as associative arrays, and the array of rows is keyed on the first column of each row. If multiple rows have the same first column value, the last row with that value will overwrite earlier rows. This method is more resource intensive and should be avoided if possible.
Fetches a column of rows as a sequential array (default first one).public function fetchGroup( string $statement, array $values = [], int $flags = static-constant-access ): array;
public function fetchObject( string $statement, array $values = [], string $className = string, array $arguments = [] ): object;
Since PDO injects property values before invoking the constructor, any initializations for defaults that you potentially have in your object's constructor, will override the values that have been injected by fetchObject
. The default object returned is \stdClass
public function fetchObjects( string $statement, array $values = [], string $className = string, array $arguments = [] ): array;
Since PDO injects property values before invoking the constructor, any initializations for defaults that you potentially have in your object's constructor, will override the values that have been injected by fetchObject
. The default object returned is \stdClass
quote()
and their respective placeholders will be replaced in the query string. If the profiler is enabled, the operation will be recorded. Prepares an SQL statement for execution. Queries the database and returns a PDOStatement. If the profiler is enabled, the operation will be recorded. Quotes a value for use in an SQL statement. This differs from PDO::quote()
in that it will convert an array into a string of comma-separated quoted values. The default type is PDO::PARAM_STR
Rolls back the current transaction, and restores autocommit mode. If the profiler is enabled, the operation will be recorded. Set a database connection attribute Sets the Profiler instance. protected function fetchData( string $method, array $arguments, string $statement, array $values = [] ): array;
DataMapper\Pdo\Connection\ConnectionInterface ¶
-
Namespace
Phalcon\DataMapper\Pdo\Connection
-
Uses
Phalcon\DataMapper\Pdo\Exception\CannotBindValue
Phalcon\DataMapper\Pdo\Parser\ParserInterface
Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface
-
Extends
PdoInterface
-
Implements
Provides array quoting, profiling, a new perform()
method, new fetch*()
methods
Methods¶
Connects to the database. Disconnects from the database. Performs a statement and returns the number of affected rows. Fetches a sequential array of rows from the database; the rows are returned as associative arrays. Fetches an associative array of rows from the database; the rows are returned as associative arrays, and the array of rows is keyed on the first column of each row.If multiple rows have the same first column value, the last row with that value will overwrite earlier rows. This method is more resource intensive and should be avoided if possible.
Fetches a column of rows as a sequential array (default first one).public function fetchGroup( string $statement, array $values = [], int $flags = static-constant-access ): array;
public function fetchObject( string $statement, array $values = [], string $className = string, array $arguments = [] ): object;
Since PDO injects property values before invoking the constructor, any initializations for defaults that you potentially have in your object's constructor, will override the values that have been injected by fetchObject
. The default object returned is \stdClass
public function fetchObjects( string $statement, array $values = [], string $className = string, array $arguments = [] ): array;
Since PDO injects property values before invoking the constructor, any initializations for defaults that you potentially have in your object's constructor, will override the values that have been injected by fetchObject
. The default object returned is \stdClass
quote()
and their respective placeholders will be replaced in the query string. If the profiler is enabled, the operation will be recorded. Sets the Profiler instance. DataMapper\Pdo\Connection\Decorated¶
-
Namespace
Phalcon\DataMapper\Pdo\Connection
-
Uses
Phalcon\DataMapper\Pdo\Exception\CannotDisconnect
Phalcon\DataMapper\Pdo\Profiler\Profiler
Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface
-
Extends
AbstractConnection
-
Implements
Decorates an existing PDO instance with the extended methods.
Methods¶
Constructor.This overrides the parent so that it can take an existing PDO instance and decorate it with the extended methods.
Connects to the database. Disconnects from the database; disallowed with decorated PDO connections.@throws CannotDisconnect
DataMapper\Pdo\Connection\PdoInterface ¶
-
Namespace
Phalcon\DataMapper\Pdo\Connection
-
Uses
-
Extends
-
Implements
An interface to the native PDO object.
Methods¶
Begins a transaction. If the profiler is enabled, the operation will be recorded. Commits the existing transaction. If the profiler is enabled, the operation will be recorded. Gets the most recent error code. Gets the most recent error info. Executes an SQL statement and returns the number of affected rows. If the profiler is enabled, the operation will be recorded. Retrieve a database connection attribute Return an array of available PDO drivers (empty array if none available) Is a transaction currently active? If the profiler is enabled, the operation will be recorded. If the profiler is enabled, the operation will be recorded. Returns the last inserted autoincrement sequence value. If the profiler is enabled, the operation will be recorded. Prepares an SQL statement for execution. Queries the database and returns a PDOStatement. If the profiler is enabled, the operation will be recorded. Quotes a value for use in an SQL statement. This differs fromPDO::quote()
in that it will convert an array into a string of comma-separated quoted values. The default type is PDO::PARAM_STR
Rolls back the current transaction, and restores autocommit mode. If the profiler is enabled, the operation will be recorded. Set a database connection attribute DataMapper\Pdo\ConnectionLocator¶
-
Namespace
Phalcon\DataMapper\Pdo
-
Uses
Phalcon\DataMapper\Pdo\Connection\ConnectionInterface
Phalcon\DataMapper\Pdo\Exception\ConnectionNotFound
-
Extends
-
Implements
ConnectionLocatorInterface
Manages Connection instances for default, read, and write connections.
Properties¶
/**
* A default Connection connection factory/instance.
*
* @var ConnectionInterface
*/
protected $master;
/**
* A registry of Connection "read" factories/instances.
*
* @var array
*/
protected $read;
/**
* A registry of Connection "write" factories/instances.
*
* @var array
*/
protected $write;
/**
* A collection of resolved instances
*
* @var array
*/
private $instances;
Methods¶
Constructor. Returns the default connection object. Returns a read connection by name; if no name is given, picks a random connection; if no read connections are present, returns the default connection. Returns a write connection by name; if no name is given, picks a random connection; if no write connections are present, returns the default connection. Sets the default connection factory. Sets a read connection factory by name. Sets a write connection factory by name. Returns a connection by name.DataMapper\Pdo\ConnectionLocatorInterface ¶
-
Namespace
Phalcon\DataMapper\Pdo
-
Uses
Phalcon\DataMapper\Pdo\Connection\ConnectionInterface
-
Extends
-
Implements
Locates PDO connections for default, read, and write databases.
Methods¶
Returns the default connection object. Returns a read connection by name; if no name is given, picks a random connection; if no read connections are present, returns the default connection. Returns a write connection by name; if no name is given, picks a random connection; if no write connections are present, returns the default connection. Sets the default connection registry entry. Sets a read connection registry entry by name. Sets a write connection registry entry by name.DataMapper\Pdo\Exception\CannotDisconnect¶
-
Namespace
Phalcon\DataMapper\Pdo\Exception
-
Uses
-
Extends
Exception
-
Implements
ExtendedPdo could not disconnect; e.g., because its PDO connection was created externally and then injected.
DataMapper\Pdo\Exception\ConnectionNotFound¶
-
Namespace
Phalcon\DataMapper\Pdo\Exception
-
Uses
-
Extends
Exception
-
Implements
Locator could not find a named connection.
DataMapper\Pdo\Exception\Exception¶
-
Namespace
Phalcon\DataMapper\Pdo\Exception
-
Uses
-
Extends
\Exception
-
Implements
Base Exception class
DataMapper\Pdo\Profiler\MemoryLogger¶
-
Namespace
Phalcon\DataMapper\Pdo\Profiler
-
Uses
Phalcon\Logger\Adapter\AdapterInterface
Phalcon\Logger\Adapter\Noop
Phalcon\Logger\Enum
Phalcon\Logger\LoggerInterface
-
Extends
-
Implements
LoggerInterface
A memory-based logger.
Properties¶
Methods¶
Returns an adapter from the stack Returns the adapter stack array Returns the log level Returns the logged messages. Returns the name of the logger Logs a message.DataMapper\Pdo\Profiler\Profiler¶
-
Namespace
Phalcon\DataMapper\Pdo\Profiler
-
Uses
Phalcon\DataMapper\Pdo\Exception\Exception
Phalcon\Logger\Enum
Phalcon\Logger\LoggerInterface
Phalcon\Helper\Json\Encode
-
Extends
-
Implements
ProfilerInterface
Sends query profiles to a logger.
Properties¶
/**
* @var bool
*/
protected $active = false;
/**
* @var array
*/
protected $context;
/**
* @var string
*/
protected $logFormat = ;
/**
* @var int
*/
protected $logLevel = ;
/**
* @var LoggerInterface
*/
protected $logger;
/**
* @var Encode
*/
private $encode;
Methods¶
Constructor. Finishes and logs a profile entry. Returns the log message format string, with placeholders. Returns the level at which to log profile messages. Returns the underlying logger instance. Returns true if logging is active. Enable or disable profiler logging. Sets the log message format string, with placeholders. Level at which to log profile messages. Starts a profile entry.DataMapper\Pdo\Profiler\ProfilerInterface ¶
-
Namespace
Phalcon\DataMapper\Pdo\Profiler
-
Uses
Phalcon\Logger\LoggerInterface
-
Extends
-
Implements
Interface to send query profiles to a logger.
Methods¶
Finishes and logs a profile entry. Returns the log message format string, with placeholders. Returns the level at which to log profile messages. Returns the underlying logger instance. Returns true if logging is active. Enable or disable profiler logging. Sets the log message format string, with placeholders. Level at which to log profile messages. Starts a profile entry.DataMapper\Query\AbstractConditions ¶
-
Namespace
Phalcon\DataMapper\Query
-
Uses
-
Extends
AbstractQuery
-
Implements
Class AbstractConditions
Methods¶
public function andWhere( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
AND
for a WHERE
condition public function appendWhere( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
WHERE
clause Sets the LIMIT
clause Sets the OFFSET
clause public function orWhere( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
OR
for a WHERE
condition Sets the ORDER BY
public function where( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
WHERE
condition protected function addCondition( string $store, string $andor, string $condition, mixed $value = null, int $type = int ): void;
protected function appendCondition( string $store, string $condition, mixed $value = null, int $type = int ): void;
BY
list Builds the conditional string Builds the LIMIT
clause Builds the LIMIT
clause for all drivers Builds the early LIMIT
clause - MS SQLServer Builds the LIMIT
clause for MSSQLServer Processes a value (array or string) and merges it with the store DataMapper\Query\AbstractQuery ¶
-
Namespace
Phalcon\DataMapper\Query
-
Uses
Phalcon\DataMapper\Pdo\Connection
-
Extends
-
Implements
Class AbstractQuery
Properties¶
/**
* @var Bind
*/
protected $bind;
/**
* @var Connection
*/
protected $connection;
/**
* @var array
*/
protected $store;
Methods¶
AbstractQuery constructor. Binds a value inline Binds a value - auto-detects the type if necessary Binds an array of values Returns all the bound values Return the generated statement Performs a statement in the connection Quotes the identifier Resets the internal array Sets a flag for the query such as "DISTINCT" Builds the flags statement(s) Builds theRETURNING
clause Indents a collection DataMapper\Query\Bind¶
-
Namespace
Phalcon\DataMapper\Query
-
Uses
-
Extends
-
Implements
Class Bind
Properties¶
Methods¶
Removes a value from the store Sets a value Sets values from an array Returns the internal collection Auto detects the PDO type Processes an array - if passed as aninline
parameter DataMapper\Query\Delete¶
-
Namespace
Phalcon\DataMapper\Query
-
Uses
Phalcon\DataMapper\Pdo\Connection
-
Extends
AbstractConditions
-
Implements
Delete Query
Methods¶
Delete constructor. Adds table(s) in the query Resets the internal store Adds theRETURNING
clause DataMapper\Query\Insert¶
-
Namespace
Phalcon\DataMapper\Query
-
Uses
Phalcon\DataMapper\Pdo\Connection
-
Extends
AbstractQuery
-
Implements
Insert Query
Methods¶
Insert constructor. Sets a column for theINSERT
query Mass sets columns and values for the INSERT
Returns the id of the last inserted record Adds table(s) in the query Resets the internal store Adds the RETURNING
clause Sets a column = value condition DataMapper\Query\QueryFactory¶
-
Namespace
Phalcon\DataMapper\Query
-
Uses
Phalcon\DataMapper\Pdo\Connection
-
Extends
-
Implements
QueryFactory
Properties¶
Methods¶
QueryFactory constructor. Create a new Bind object Create a new Delete object Create a new Insert object Create a new Select object Create a new Update objectDataMapper\Query\Select¶
-
Namespace
Phalcon\DataMapper\Query
-
Uses
BadMethodCallException
-
Extends
AbstractConditions
-
Implements
Select Query
Constants¶
const JOIN_INNER = INNER;
const JOIN_LEFT = LEFT;
const JOIN_NATURAL = NATURAL;
const JOIN_RIGHT = RIGHT;
Properties¶
Methods¶
Proxied methods to the connection Sets aAND
for a HAVING
condition Concatenates to the most recent HAVING
clause Concatenates to the most recent JOIN
clause The AS
statement for the query - useful in sub-queries The columns to select from. If a key is set in the array element, the key will be used as the alias Enable the FOR UPDATE
for the query Adds table(s) in the query Returns the compiled SQL statement Sets the GROUP BY
Whether the query has columns or not Sets a HAVING
condition public function join( string $join, string $table, string $condition, mixed $value = null, int $type = int ): Select;
OR
for a HAVING
condition Resets the internal collections Start a sub-select Start a UNION
Start a UNION ALL
Statement builder DataMapper\Query\Update¶
-
Namespace
Phalcon\DataMapper\Query
-
Uses
Phalcon\DataMapper\Pdo\Connection
-
Extends
AbstractConditions
-
Implements
Update Query
Methods¶
Update constructor. Sets a column for theUPDATE
query Mass sets columns and values for the UPDATE
Adds table(s) in the query Whether the query has columns or not Resets the internal store Adds the RETURNING
clause Sets a column = value condition