Skip to content

Phalcon datamapper

NOTE

All classes are prefixed with Phalcon

DataMapper\Pdo\Connection

Class Source on GitHub

Provides array quoting, profiling, a new perform() method, new fetch*() methods

Uses Phalcon\DataMapper\Pdo\Connection\AbstractConnection · Phalcon\DataMapper\Pdo\Exception\DriverNotSupported · Phalcon\DataMapper\Pdo\Profiler\Profiler · Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface

Method Summary

Properties

protected array $arguments = []

Methods

Public · 4

__construct()

public function __construct(
    string $dsn,
    string $username = null,
    string $password = null,
    array $options = [],
    array $queries = [],
    ProfilerInterface $profiler = null
);

Constructor.

This overrides the parent so that it can take connection attributes as a constructor parameter, and set them after connection.

__debugInfo()

public function __debugInfo(): array;

The purpose of this method is to hide sensitive data from stack traces.

connect()

public function connect(): void;

Connects to the database.

disconnect()

public function disconnect(): void;

Disconnects from the database.

DataMapper\Pdo\ConnectionLocator

Class Source on GitHub

Manages Connection instances for default, read, and write connections.

Uses Phalcon\DataMapper\Pdo\Connection\ConnectionInterface · Phalcon\DataMapper\Pdo\Exception\ConnectionNotFound

Method Summary

Properties

protected ConnectionInterface $master A default Connection connection factory/instance.
protected array $read = [] A registry of Connection "read" factories/instances.
protected array $write = [] A registry of Connection "write" factories/instances.

Methods

Public · 7

__construct()

public function __construct(
    ConnectionInterface $master,
    array $read = [],
    array $write = []
);

Constructor.

getMaster()

public function getMaster(): ConnectionInterface;

Returns the default connection object.

getRead()

public function getRead( string $name = "" ): ConnectionInterface;

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.

getWrite()

public function getWrite( string $name = "" ): ConnectionInterface;

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.

setMaster()

public function setMaster( ConnectionInterface $callableObject ): static;

Sets the default connection factory.

setRead()

public function setRead(
    string $name,
    callable $callableObject
): static;

Sets a read connection factory by name.

setWrite()

public function setWrite(
    string $name,
    callable $callableObject
): static;

Sets a write connection factory by name.

Protected · 1

getConnection()

protected function getConnection(
    string $type,
    string $name = ""
): ConnectionInterface;

Returns a connection by name.

DataMapper\Pdo\ConnectionLocatorInterface

Interface Source on GitHub

Locates PDO connections for default, read, and write databases.

  • Phalcon\DataMapper\Pdo\ConnectionLocatorInterface

Uses Phalcon\DataMapper\Pdo\Connection\ConnectionInterface

Method Summary

Methods

Public · 6

getMaster()

public function getMaster(): ConnectionInterface;

Returns the default connection object.

getRead()

public function getRead( string $name = "" ): ConnectionInterface;

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.

getWrite()

public function getWrite( string $name = "" ): ConnectionInterface;

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.

setMaster()

public function setMaster( ConnectionInterface $callableObject ): ConnectionLocatorInterface;

Sets the default connection registry entry.

setRead()

public function setRead(
    string $name,
    callable $callableObject
): ConnectionLocatorInterface;

Sets a read connection registry entry by name.

setWrite()

public function setWrite(
    string $name,
    callable $callableObject
): ConnectionLocatorInterface;

Sets a write connection registry entry by name.

DataMapper\Pdo\Connection\AbstractConnection

Abstract Source on GitHub

Provides array quoting, profiling, a new perform() method, new fetch*() methods

Uses BadMethodCallException · Phalcon\DataMapper\Pdo\Exception\UnknownDriverMethod · Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface

Method Summary

public __call(mixed $name,array $arguments) Proxies to PDO methods created for specific drivers; in particular, public bool beginTransaction() Begins a transaction. If the profiler is enabled, the operation will public bool commit() Commits the existing transaction. If the profiler is enabled, the public void connect() Connects to the database. public void disconnect() Disconnects from the database. public string|null errorCode() Gets the most recent error code. public array errorInfo() Gets the most recent error info. public int exec( string $statement ) Executes an SQL statement and returns the number of affected rows. If public int fetchAffected(string $statement,array $values = []) Performs a statement and returns the number of affected rows. public array fetchAll(string $statement,array $values = []) Fetches a sequential array of rows from the database; the rows are public array fetchAssoc(string $statement,array $values = []) Fetches an associative array of rows from the database; the rows are public array fetchColumn(string $statement,array $values = [],int $column = 0) Fetches a column of rows as a sequential array (default first one). public array fetchGroup(string $statement,array $values = [],int $flags = \PDO::FETCH_ASSOC) Fetches multiple from the database as an associative array. The first public object fetchObject(string $statement,array $values = [],string $className = "stdClass",array $arguments = []) Fetches one row from the database as an object where the column values public array fetchObjects(string $statement,array $values = [],string $className = "stdClass",array $arguments = []) Fetches a sequential array of rows from the database; the rows are public array fetchOne(string $statement,array $values = []) Fetches one row from the database as an associative array. public array fetchPairs(string $statement,array $values = []) Fetches an associative array of rows as key-value pairs (first column is public fetchValue(string $statement,array $values = []) Fetches the very first value (i.e., first column of the first row). public \PDO getAdapter() Return the inner PDO (if any) public mixed getAttribute( int $attribute ) Retrieve a database connection attribute public array getAvailableDrivers() Return an array of available PDO drivers (empty array if none available) public string getDriverName() Return the driver name public ProfilerInterface getProfiler() Returns the Profiler instance. public array getQuoteNames( string $driver = "" ) Gets the quote parameters based on the driver public bool inTransaction() Is a transaction currently active? If the profiler is enabled, the public bool isConnected() Is the PDO connection active? public string lastInsertId( string $name = null ) Returns the last inserted autoincrement sequence value. If the profiler public \PDOStatement perform(string $statement,array $values = []) Performs a query with bound values and returns the resulting public \PDOStatement|bool prepare(string $statement,array $options = []) Prepares an SQL statement for execution. public \PDOStatement|bool query( string $statement ) Queries the database and returns a PDOStatement. If the profiler is public string quote(mixed $value,int $type = \PDO::PARAM_STR) Quotes a value for use in an SQL statement. This differs from public bool rollBack() Rolls back the current transaction, and restores autocommit mode. If the public bool setAttribute(int $attribute,mixed $value) Set a database connection attribute public static setProfiler( ProfilerInterface $profiler ) Sets the Profiler instance. protected array fetchData(string $method,array $arguments,string $statement,array $values = []) Helper method to get data from PDO based on the method passed protected void performBind(\PDOStatement $statement,mixed $name,mixed $arguments) Bind a value using the proper PDO::PARAM_* type.

Properties

protected \PDO $pdo
protected ProfilerInterface $profiler

Methods

Public · 34

__call()

public function __call(
    mixed $name,
    array $arguments
);

Proxies to PDO methods created for specific drivers; in particular, sqlite and pgsql.

beginTransaction()

public function beginTransaction(): bool;

Begins a transaction. If the profiler is enabled, the operation will be recorded.

commit()

public function commit(): bool;

Commits the existing transaction. If the profiler is enabled, the operation will be recorded.

connect()

abstract public function connect(): void;

Connects to the database.

disconnect()

abstract public function disconnect(): void;

Disconnects from the database.

errorCode()

public function errorCode(): string|null;

Gets the most recent error code.

errorInfo()

public function errorInfo(): array;

Gets the most recent error info.

exec()

public function exec( string $statement ): int;

Executes an SQL statement and returns the number of affected rows. If the profiler is enabled, the operation will be recorded.

fetchAffected()

public function fetchAffected(
    string $statement,
    array $values = []
): int;

Performs a statement and returns the number of affected rows.

fetchAll()

public function fetchAll(
    string $statement,
    array $values = []
): array;

Fetches a sequential array of rows from the database; the rows are returned as associative arrays.

fetchAssoc()

public function fetchAssoc(
    string $statement,
    array $values = []
): array;

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.

fetchColumn()

public function fetchColumn(
    string $statement,
    array $values = [],
    int $column = 0
): array;

Fetches a column of rows as a sequential array (default first one).

fetchGroup()

public function fetchGroup(
    string $statement,
    array $values = [],
    int $flags = \PDO::FETCH_ASSOC
): array;

Fetches multiple from the database as an associative array. The first column will be the index key. The default flags are PDO::FETCH_ASSOC | PDO::FETCH_GROUP

fetchObject()

public function fetchObject(
    string $statement,
    array $values = [],
    string $className = "stdClass",
    array $arguments = []
): object;

Fetches one row from the database as an object where the column values are mapped to object properties.

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

fetchObjects()

public function fetchObjects(
    string $statement,
    array $values = [],
    string $className = "stdClass",
    array $arguments = []
): array;

Fetches a sequential array of rows from the database; the rows are returned as objects where the column values are mapped to object properties.

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

fetchOne()

public function fetchOne(
    string $statement,
    array $values = []
): array;

Fetches one row from the database as an associative array.

fetchPairs()

public function fetchPairs(
    string $statement,
    array $values = []
): array;

Fetches an associative array of rows as key-value pairs (first column is the key, second column is the value).

fetchValue()

public function fetchValue(
    string $statement,
    array $values = []
);

Fetches the very first value (i.e., first column of the first row).

getAdapter()

public function getAdapter(): \PDO;

Return the inner PDO (if any)

getAttribute()

public function getAttribute( int $attribute ): mixed;

Retrieve a database connection attribute

getAvailableDrivers()

public static function getAvailableDrivers(): array;

Return an array of available PDO drivers (empty array if none available)

getDriverName()

public function getDriverName(): string;

Return the driver name

getProfiler()

public function getProfiler(): ProfilerInterface;

Returns the Profiler instance.

getQuoteNames()

public function getQuoteNames( string $driver = "" ): array;

Gets the quote parameters based on the driver

inTransaction()

public function inTransaction(): bool;

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.

isConnected()

public function isConnected(): bool;

Is the PDO connection active?

lastInsertId()

public function lastInsertId( string $name = null ): string;

Returns the last inserted autoincrement sequence value. If the profiler is enabled, the operation will be recorded.

perform()

public function perform(
    string $statement,
    array $values = []
): \PDOStatement;

Performs a query with bound values and returns the resulting PDOStatement; array values will be passed through quote() and their respective placeholders will be replaced in the query string. If the profiler is enabled, the operation will be recorded.

prepare()

public function prepare(
    string $statement,
    array $options = []
): \PDOStatement|bool;

Prepares an SQL statement for execution.

query()

public function query( string $statement ): \PDOStatement|bool;

Queries the database and returns a PDOStatement. If the profiler is enabled, the operation will be recorded.

quote()

public function quote(
    mixed $value,
    int $type = \PDO::PARAM_STR
): string;

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

rollBack()

public function rollBack(): bool;

Rolls back the current transaction, and restores autocommit mode. If the profiler is enabled, the operation will be recorded.

setAttribute()

public function setAttribute(
    int $attribute,
    mixed $value
): bool;

Set a database connection attribute

setProfiler()

public function setProfiler( ProfilerInterface $profiler ): static;

Sets the Profiler instance.

Protected · 2

fetchData()

protected function fetchData(
    string $method,
    array $arguments,
    string $statement,
    array $values = []
): array;

Helper method to get data from PDO based on the method passed

performBind()

protected function performBind(
    \PDOStatement $statement,
    mixed $name,
    mixed $arguments
): void;

Bind a value using the proper PDO::PARAM_* type.

DataMapper\Pdo\Connection\ConnectionInterface

Interface Source on GitHub

Provides array quoting, profiling, a new perform() method, new fetch*() methods

Uses Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface

Method Summary

public void connect() Connects to the database. public void disconnect() Disconnects from the database. public int fetchAffected(string $statement,array $values = []) Performs a statement and returns the number of affected rows. public array fetchAll(string $statement,array $values = []) Fetches a sequential array of rows from the database; the rows are public array fetchAssoc(string $statement,array $values = []) Fetches an associative array of rows from the database; the rows are public array fetchColumn(string $statement,array $values = [],int $column = 0) Fetches a column of rows as a sequential array (default first one). public array fetchGroup(string $statement,array $values = [],int $flags = \PDO::FETCH_ASSOC) Fetches multiple from the database as an associative array. The first public object fetchObject(string $statement,array $values = [],string $className = "stdClass",array $arguments = []) Fetches one row from the database as an object where the column values public array fetchObjects(string $statement,array $values = [],string $className = "stdClass",array $arguments = []) Fetches a sequential array of rows from the database; the rows are public array fetchOne(string $statement,array $values = []) Fetches one row from the database as an associative array. public array fetchPairs(string $statement,array $values = []) Fetches an associative array of rows as key-value pairs (first column is public mixed fetchValue(string $statement,array $values = []) Fetches the very first value (i.e., first column of the first row). public \PDO getAdapter() Return the inner PDO (if any) public ProfilerInterface getProfiler() Returns the Profiler instance. public bool isConnected() Is the PDO connection active? public \PDOStatement perform(string $statement,array $values = []) Performs a query with bound values and returns the resulting public setProfiler( ProfilerInterface $profiler ) Sets the Profiler instance.

Methods

Public · 17

connect()

public function connect(): void;

Connects to the database.

disconnect()

public function disconnect(): void;

Disconnects from the database.

fetchAffected()

public function fetchAffected(
    string $statement,
    array $values = []
): int;

Performs a statement and returns the number of affected rows.

fetchAll()

public function fetchAll(
    string $statement,
    array $values = []
): array;

Fetches a sequential array of rows from the database; the rows are returned as associative arrays.

fetchAssoc()

public function fetchAssoc(
    string $statement,
    array $values = []
): array;

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.

fetchColumn()

public function fetchColumn(
    string $statement,
    array $values = [],
    int $column = 0
): array;

Fetches a column of rows as a sequential array (default first one).

fetchGroup()

public function fetchGroup(
    string $statement,
    array $values = [],
    int $flags = \PDO::FETCH_ASSOC
): array;

Fetches multiple from the database as an associative array. The first column will be the index key. The default flags are PDO::FETCH_ASSOC | PDO::FETCH_GROUP

fetchObject()

public function fetchObject(
    string $statement,
    array $values = [],
    string $className = "stdClass",
    array $arguments = []
): object;

Fetches one row from the database as an object where the column values are mapped to object properties.

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

fetchObjects()

public function fetchObjects(
    string $statement,
    array $values = [],
    string $className = "stdClass",
    array $arguments = []
): array;

Fetches a sequential array of rows from the database; the rows are returned as objects where the column values are mapped to object properties.

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

fetchOne()

public function fetchOne(
    string $statement,
    array $values = []
): array;

Fetches one row from the database as an associative array.

fetchPairs()

public function fetchPairs(
    string $statement,
    array $values = []
): array;

Fetches an associative array of rows as key-value pairs (first column is the key, second column is the value).

fetchValue()

public function fetchValue(
    string $statement,
    array $values = []
): mixed;

Fetches the very first value (i.e., first column of the first row).

getAdapter()

public function getAdapter(): \PDO;

Return the inner PDO (if any)

getProfiler()

public function getProfiler(): ProfilerInterface;

Returns the Profiler instance.

isConnected()

public function isConnected(): bool;

Is the PDO connection active?

perform()

public function perform(
    string $statement,
    array $values = []
): \PDOStatement;

Performs a query with bound values and returns the resulting PDOStatement; array values will be passed through quote() and their respective placeholders will be replaced in the query string. If the profiler is enabled, the operation will be recorded.

setProfiler()

public function setProfiler( ProfilerInterface $profiler );

Sets the Profiler instance.

DataMapper\Pdo\Connection\Decorated

Class Source on GitHub

Decorates an existing PDO instance with the extended methods.

Uses Phalcon\DataMapper\Pdo\Exception\CannotDisconnect · Phalcon\DataMapper\Pdo\Profiler\Profiler · Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface

Method Summary

Methods

Public · 3

__construct()

public function __construct(
    \PDO $pdo,
    ProfilerInterface $profiler = null
);

Constructor.

This overrides the parent so that it can take an existing PDO instance and decorate it with the extended methods.

connect()

public function connect(): void;

Connects to the database.

disconnect()

public function disconnect(): void;

Disconnects from the database; disallowed with decorated PDO connections.

DataMapper\Pdo\Connection\PdoInterface

Interface Source on GitHub

An interface to the native PDO object.

Method Summary

Methods

Public · 14

beginTransaction()

public function beginTransaction(): bool;

Begins a transaction. If the profiler is enabled, the operation will be recorded.

commit()

public function commit(): bool;

Commits the existing transaction. If the profiler is enabled, the operation will be recorded.

errorCode()

public function errorCode(): null|string;

Gets the most recent error code.

errorInfo()

public function errorInfo(): array;

Gets the most recent error info.

exec()

public function exec( string $statement ): int;

Executes an SQL statement and returns the number of affected rows. If the profiler is enabled, the operation will be recorded.

getAttribute()

public function getAttribute( int $attribute ): mixed;

Retrieve a database connection attribute

getAvailableDrivers()

public static function getAvailableDrivers(): array;

Return an array of available PDO drivers (empty array if none available)

inTransaction()

public function inTransaction(): bool;

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.

lastInsertId()

public function lastInsertId( string $name = null ): string;

Returns the last inserted autoincrement sequence value. If the profiler is enabled, the operation will be recorded.

prepare()

public function prepare(
    string $statement,
    array $options = []
): \PDOStatement|bool;

Prepares an SQL statement for execution.

query()

public function query( string $statement ): \PDOStatement|bool;

Queries the database and returns a PDOStatement. If the profiler is enabled, the operation will be recorded.

quote()

public function quote(
    mixed $value,
    int $type = \PDO::PARAM_STR
): string;

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

rollBack()

public function rollBack(): bool;

Rolls back the current transaction, and restores autocommit mode. If the profiler is enabled, the operation will be recorded.

setAttribute()

public function setAttribute(
    int $attribute,
    mixed $value
): bool;

Set a database connection attribute

DataMapper\Pdo\Exception\CannotDisconnect

Class Source on GitHub

ExtendedPdo could not disconnect; e.g., because its PDO connection was created externally and then injected.

DataMapper\Pdo\Exception\ConnectionNotFound

Class Source on GitHub

Locator could not find a named connection.

DataMapper\Pdo\Exception\DriverNotSupported

Class Source on GitHub

  • InvalidArgumentException
    • Phalcon\DataMapper\Pdo\Exception\DriverNotSupported

Uses InvalidArgumentException

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $driver );

DataMapper\Pdo\Exception\Exception

Class Source on GitHub

Base Exception class

DataMapper\Pdo\Exception\UnknownDriverMethod

Class Source on GitHub

  • BadMethodCallException
    • Phalcon\DataMapper\Pdo\Exception\UnknownDriverMethod

Uses BadMethodCallException

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $message );

DataMapper\Pdo\Exception\UnknownQueryMethod

Class Source on GitHub

  • BadMethodCallException
    • Phalcon\DataMapper\Pdo\Exception\UnknownQueryMethod

Uses BadMethodCallException

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $method );

DataMapper\Pdo\Profiler\MemoryLogger

Class Source on GitHub

A memory-based logger.

Uses Phalcon\Logger\Adapter\AdapterInterface · Phalcon\Logger\Adapter\Noop · Phalcon\Logger\Enum · Phalcon\Logger\LoggerInterface

Method Summary

Properties

protected array $messages = []

Methods

Public · 15

alert()

public function alert(
    string $message,
    array $context = []
): void;

critical()

public function critical(
    string $message,
    array $context = []
): void;

debug()

public function debug(
    string $message,
    array $context = []
): void;

emergency()

public function emergency(
    string $message,
    array $context = []
): void;

error()

public function error(
    string $message,
    array $context = []
): void;

getAdapter()

public function getAdapter( string $name ): AdapterInterface;

Returns an adapter from the stack

getAdapters()

public function getAdapters(): array;

Returns the adapter stack array

getLogLevel()

public function getLogLevel(): int;

Returns the log level

getMessages()

public function getMessages(): array;

Returns the logged messages.

getName()

public function getName(): string;

Returns the name of the logger

info()

public function info(
    string $message,
    array $context = []
): void;

log()

public function log(
    mixed $level,
    string $message,
    array $context = []
): void;

Logs a message.

notice()

public function notice(
    string $message,
    array $context = []
): void;

trace()

public function trace(
    string $message,
    array $context = []
): void;

warning()

public function warning(
    string $message,
    array $context = []
): void;

DataMapper\Pdo\Profiler\Profiler

Class Source on GitHub

Sends query profiles to a logger.

Uses Phalcon\DataMapper\Pdo\Exception\Exception · Phalcon\Logger\Enum · Phalcon\Logger\LoggerInterface · Phalcon\Support\Helper\Json\Encode

Method Summary

Properties

protected bool $active = false
protected array $context = []
protected string $logFormat = ""
protected int|string $logLevel = 0
protected LoggerInterface $logger

Methods

Public · 10

__construct()

public function __construct( LoggerInterface $logger = null );

Constructor.

finish()

public function finish(
    string $statement = null,
    array $values = []
): void;

Finishes and logs a profile entry.

getLogFormat()

public function getLogFormat(): string;

Returns the log message format string, with placeholders.

getLogLevel()

public function getLogLevel(): string;

Returns the level at which to log profile messages.

getLogger()

public function getLogger(): LoggerInterface;

Returns the underlying logger instance.

isActive()

public function isActive(): bool;

Returns true if logging is active.

setActive()

public function setActive( bool $active ): ProfilerInterface;

Enable or disable profiler logging.

setLogFormat()

public function setLogFormat( string $logFormat ): ProfilerInterface;

Sets the log message format string, with placeholders.

setLogLevel()

public function setLogLevel( string $logLevel ): ProfilerInterface;

Level at which to log profile messages.

start()

public function start( string $method ): void;

Starts a profile entry.

DataMapper\Pdo\Profiler\ProfilerInterface

Interface Source on GitHub

Interface to send query profiles to a logger.

  • Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface

Uses Phalcon\Logger\LoggerInterface

Method Summary

Methods

Public · 9

finish()

public function finish(
    string $statement = null,
    array $values = []
): void;

Finishes and logs a profile entry.

getLogFormat()

public function getLogFormat(): string;

Returns the log message format string, with placeholders.

getLogLevel()

public function getLogLevel(): string;

Returns the level at which to log profile messages.

getLogger()

public function getLogger(): LoggerInterface;

Returns the underlying logger instance.

isActive()

public function isActive(): bool;

Returns true if logging is active.

setActive()

public function setActive( bool $active ): ProfilerInterface;

Enable or disable profiler logging.

setLogFormat()

public function setLogFormat( string $logFormat ): ProfilerInterface;

Sets the log message format string, with placeholders.

setLogLevel()

public function setLogLevel( string $logLevel ): ProfilerInterface;

Level at which to log profile messages.

start()

public function start( string $method ): void;

Starts a profile entry.

DataMapper\Query\AbstractConditions

Abstract Source on GitHub

Class AbstractConditions

Method Summary

public AbstractConditions andWhere(string $condition,mixed $value = null,int $type = -1) Sets a AND for a WHERE condition public AbstractConditions appendWhere(string $condition,mixed $value = null,int $type = -1) Concatenates to the most recent WHERE clause public AbstractConditions limit( int $limit ) Sets the LIMIT clause public AbstractConditions offset( int $offset ) Sets the OFFSET clause public AbstractConditions orWhere(string $condition,mixed $value = null,int $type = -1) Sets a OR for a WHERE condition public AbstractConditions orderBy( mixed $orderBy ) Sets the ORDER BY public AbstractConditions where(string $condition,mixed $value = null,int $type = -1) Sets a WHERE condition public AbstractConditions whereEquals( array $columnsValues ) protected void addCondition(string $store,string $andor,string $condition,mixed $value = null,int $type = -1) Appends a conditional protected void appendCondition(string $store,string $condition,mixed $value = null,int $type = -1) Concatenates a conditional protected string buildBy( string $type ) Builds a BY list protected string buildCondition( string $type ) Builds the conditional string protected string buildLimit() Builds the LIMIT clause protected string buildLimitCommon() Builds the LIMIT clause for all drivers protected string buildLimitEarly() Builds the early LIMIT clause - MS SQLServer protected string buildLimitSqlsrv() Builds the LIMIT clause for MSSQLServer protected void processValue(string $store,mixed $data) Processes a value (array or string) and merges it with the store

Methods

Public · 8

andWhere()

public function andWhere(
    string $condition,
    mixed $value = null,
    int $type = -1
): AbstractConditions;

Sets a AND for a WHERE condition

appendWhere()

public function appendWhere(
    string $condition,
    mixed $value = null,
    int $type = -1
): AbstractConditions;

Concatenates to the most recent WHERE clause

limit()

public function limit( int $limit ): AbstractConditions;

Sets the LIMIT clause

offset()

public function offset( int $offset ): AbstractConditions;

Sets the OFFSET clause

orWhere()

public function orWhere(
    string $condition,
    mixed $value = null,
    int $type = -1
): AbstractConditions;

Sets a OR for a WHERE condition

orderBy()

public function orderBy( mixed $orderBy ): AbstractConditions;

Sets the ORDER BY

where()

public function where(
    string $condition,
    mixed $value = null,
    int $type = -1
): AbstractConditions;

Sets a WHERE condition

whereEquals()

public function whereEquals( array $columnsValues ): AbstractConditions;
Protected · 9

addCondition()

protected function addCondition(
    string $store,
    string $andor,
    string $condition,
    mixed $value = null,
    int $type = -1
): void;

Appends a conditional

appendCondition()

protected function appendCondition(
    string $store,
    string $condition,
    mixed $value = null,
    int $type = -1
): void;

Concatenates a conditional

buildBy()

protected function buildBy( string $type ): string;

Builds a BY list

buildCondition()

protected function buildCondition( string $type ): string;

Builds the conditional string

buildLimit()

protected function buildLimit(): string;

Builds the LIMIT clause

buildLimitCommon()

protected function buildLimitCommon(): string;

Builds the LIMIT clause for all drivers

buildLimitEarly()

protected function buildLimitEarly(): string;

Builds the early LIMIT clause - MS SQLServer

buildLimitSqlsrv()

protected function buildLimitSqlsrv(): string;

Builds the LIMIT clause for MSSQLServer

processValue()

protected function processValue(
    string $store,
    mixed $data
): void;

Processes a value (array or string) and merges it with the store

DataMapper\Query\AbstractQuery

Abstract Source on GitHub

Class AbstractQuery

Uses Phalcon\DataMapper\Pdo\Connection

Method Summary

Properties

protected Bind $bind
protected Connection $connection
protected array $store = []

Methods

Public · 18

__construct()

public function __construct(
    Connection $connection,
    Bind $bind
);

AbstractQuery constructor.

bindInline()

public function bindInline(
    mixed $value,
    int $type = -1
): string;

Binds a value inline

bindValue()

public function bindValue(
    string $key,
    mixed $value,
    int $type = -1
): AbstractQuery;

Binds a value - auto-detects the type if necessary

bindValues()

public function bindValues( array $values ): AbstractQuery;

Binds an array of values

getBindValues()

public function getBindValues(): array;

Returns all the bound values

getStatement()

abstract public function getStatement(): string;

Return the generated statement

perform()

public function perform();

Performs a statement in the connection

quoteIdentifier()

public function quoteIdentifier(
    string $name,
    int $type = \PDO::PARAM_STR
): string;

Quotes the identifier

reset()

public function reset(): void;

Resets the internal array

resetColumns()

public function resetColumns(): void;

Resets the columns

resetFlags()

public function resetFlags(): void;

Resets the flags

resetFrom()

public function resetFrom(): void;

Resets the from

resetGroupBy()

public function resetGroupBy(): void;

Resets the group by

resetHaving()

public function resetHaving(): void;

Resets the having

resetLimit()

public function resetLimit(): void;

Resets the limit and offset

resetOrderBy()

public function resetOrderBy(): void;

Resets the order by

resetWhere()

public function resetWhere(): void;

Resets the where

setFlag()

public function setFlag(
    string $flag,
    bool $enable = true
): void;

Sets a flag for the query such as "DISTINCT"

Protected · 3

buildFlags()

protected function buildFlags();

Builds the flags statement(s)

buildReturning()

protected function buildReturning(): string;

Builds the RETURNING clause

indent()

protected function indent(
    array $collection,
    string $glue = ""
): string;

Indents a collection

DataMapper\Query\Bind

Class Source on GitHub

Class Bind

  • Phalcon\DataMapper\Query\Bind

Method Summary

Properties

protected int $inlineCount = 0
protected array $store = []

Methods

Public · 5

bindInline()

public function bindInline(
    mixed $value,
    int $type = -1
): string;

remove()

public function remove( string $key ): void;

Removes a value from the store

setValue()

public function setValue(
    string $key,
    mixed $value,
    int $type = -1
): void;

Sets a value

setValues()

public function setValues(
    array $values,
    int $type = -1
): void;

Sets values from an array

toArray()

public function toArray(): array;

Returns the internal collection

Protected · 2

getType()

protected function getType( mixed $value ): int;

Auto detects the PDO type

inlineArray()

protected function inlineArray(
    array $data,
    int $type
): string;

Processes an array - if passed as an inline parameter

DataMapper\Query\Delete

Class Source on GitHub

Delete Query

Uses Phalcon\DataMapper\Pdo\Connection

Method Summary

Methods

Public · 5

__construct()

public function __construct(
    Connection $connection,
    Bind $bind
);

Delete constructor.

from()

public function from( string $table ): Delete;

Adds table(s) in the query

getStatement()

public function getStatement(): string;

reset()

public function reset(): void;

Resets the internal store

returning()

public function returning( array $columns ): Delete;

Adds the RETURNING clause

DataMapper\Query\Insert

Class Source on GitHub

Insert Query

Uses Phalcon\DataMapper\Pdo\Connection

Method Summary

Methods

Public · 9

__construct()

public function __construct(
    Connection $connection,
    Bind $bind
);

Insert constructor.

column()

public function column(
    string $column,
    mixed $value = null,
    int $type = -1
): Insert;

Sets a column for the INSERT query

columns()

public function columns( array $columns ): Insert;

Mass sets columns and values for the INSERT

getLastInsertId()

public function getLastInsertId( string $name = null ): string;

Returns the id of the last inserted record

getStatement()

public function getStatement(): string;

into()

public function into( string $table ): Insert;

Adds table(s) in the query

reset()

public function reset(): void;

Resets the internal store

returning()

public function returning( array $columns ): Insert;

Adds the RETURNING clause

set()

public function set(
    string $column,
    mixed $value = null
): Insert;

Sets a column = value condition

DataMapper\Query\QueryFactory

Class Source on GitHub

QueryFactory

  • Phalcon\DataMapper\Query\QueryFactory

Uses Phalcon\DataMapper\Pdo\Connection

Method Summary

Properties

protected string $selectClass = ""

Methods

Public · 6

__construct()

public function __construct( string $selectClass = "" );

QueryFactory constructor.

newBind()

public function newBind(): Bind;

Create a new Bind object

newDelete()

public function newDelete( Connection $connection ): Delete;

Create a new Delete object

newInsert()

public function newInsert( Connection $connection ): Insert;

Create a new Insert object

newSelect()

public function newSelect( Connection $connection ): Select;

Create a new Select object

newUpdate()

public function newUpdate( Connection $connection ): Update;

Create a new Update object

DataMapper\Query\Select

Class Source on GitHub

Select Query

Uses BadMethodCallException · Phalcon\DataMapper\Pdo\Exception\UnknownQueryMethod

Method Summary

public __call(string $method,array $params) Proxied methods to the connection public Select andHaving(string $condition,mixed $value = null,int $type = -1) Sets a AND for a HAVING condition public Select appendHaving(string $condition,mixed $value = null,int $type = -1) Concatenates to the most recent HAVING clause public Select appendJoin(string $condition,mixed $value = null,int $type = -1) Concatenates to the most recent JOIN clause public Select asAlias( string $asAlias ) The AS statement for the query - useful in sub-queries public Select columns( array $columns ) The columns to select from. If a key is set in the array element, the public Select distinct( bool $enable = true ) public Select forUpdate( bool $enable = true ) Enable the FOR UPDATE for the query public Select from( string $table ) Adds table(s) in the query public string getStatement() Returns the compiled SQL statement public Select groupBy( mixed $groupBy ) Sets the GROUP BY public bool hasColumns() Whether the query has columns or not public Select having(string $condition,mixed $value = null,int $type = -1) Sets a HAVING condition public Select join(string $join,string $table,string $condition,mixed $value = null,int $type = -1) Sets a 'JOIN' condition public Select orHaving(string $condition,mixed $value = null,int $type = -1) Sets a OR for a HAVING condition public void reset() Resets the internal collections public Select subSelect() Start a sub-select public Select union() Start a UNION public Select unionAll() Start a UNION ALL protected string getCurrentStatement( string $suffix = "" ) Statement builder

Constants

string JOIN_INNER = "INNER"
string JOIN_LEFT = "LEFT"
string JOIN_NATURAL = "NATURAL"
string JOIN_RIGHT = "RIGHT"

Properties

protected string $asAlias = ""
protected bool $forUpdate = false

Methods

Public · 19

__call()

public function __call(
    string $method,
    array $params
);

Proxied methods to the connection

andHaving()

public function andHaving(
    string $condition,
    mixed $value = null,
    int $type = -1
): Select;

Sets a AND for a HAVING condition

appendHaving()

public function appendHaving(
    string $condition,
    mixed $value = null,
    int $type = -1
): Select;

Concatenates to the most recent HAVING clause

appendJoin()

public function appendJoin(
    string $condition,
    mixed $value = null,
    int $type = -1
): Select;

Concatenates to the most recent JOIN clause

asAlias()

public function asAlias( string $asAlias ): Select;

The AS statement for the query - useful in sub-queries

columns()

public function columns( array $columns ): Select;

The columns to select from. If a key is set in the array element, the key will be used as the alias

distinct()

public function distinct( bool $enable = true ): Select;

forUpdate()

public function forUpdate( bool $enable = true ): Select;

Enable the FOR UPDATE for the query

from()

public function from( string $table ): Select;

Adds table(s) in the query

getStatement()

public function getStatement(): string;

Returns the compiled SQL statement

groupBy()

public function groupBy( mixed $groupBy ): Select;

Sets the GROUP BY

hasColumns()

public function hasColumns(): bool;

Whether the query has columns or not

having()

public function having(
    string $condition,
    mixed $value = null,
    int $type = -1
): Select;

Sets a HAVING condition

join()

public function join(
    string $join,
    string $table,
    string $condition,
    mixed $value = null,
    int $type = -1
): Select;

Sets a 'JOIN' condition

orHaving()

public function orHaving(
    string $condition,
    mixed $value = null,
    int $type = -1
): Select;

Sets a OR for a HAVING condition

reset()

public function reset(): void;

Resets the internal collections

subSelect()

public function subSelect(): Select;

Start a sub-select

union()

public function union(): Select;

Start a UNION

unionAll()

public function unionAll(): Select;

Start a UNION ALL

Protected · 1

getCurrentStatement()

protected function getCurrentStatement( string $suffix = "" ): string;

Statement builder

DataMapper\Query\Update

Class Source on GitHub

Update Query

Uses Phalcon\DataMapper\Pdo\Connection

Method Summary

Methods

Public · 9

__construct()

public function __construct(
    Connection $connection,
    Bind $bind
);

Update constructor.

column()

public function column(
    string $column,
    mixed $value = null,
    int $type = -1
): Update;

Sets a column for the UPDATE query

columns()

public function columns( array $columns ): Update;

Mass sets columns and values for the UPDATE

from()

public function from( string $table ): Update;

Adds table(s) in the query

getStatement()

public function getStatement(): string;

hasColumns()

public function hasColumns(): bool;

Whether the query has columns or not

reset()

public function reset(): void;

Resets the internal store

returning()

public function returning( array $columns ): Update;

Adds the RETURNING clause

set()

public function set(
    string $column,
    mixed $value = null
): Update;

Sets a column = value condition