Skip to content

Class Phalcon\DataMapper\Pdo\Connection

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo | | Uses | InvalidArgumentException, Phalcon\DataMapper\Pdo\Connection\AbstractConnection, Phalcon\DataMapper\Pdo\Profiler\Profiler, Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface | | Extends | AbstractConnection |

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

@property array $arguments @property PDO $pdo @property ProfilerInterface $profiler

Properties

/**
 * @var array
 */
protected arguments;

Methods

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.

public function __debugInfo(): array;
The purpose of this method is to hide sensitive data from stack traces.

public function connect(): void;
Connects to the database.

public function disconnect(): void;
Disconnects from the database.

Abstract Class Phalcon\DataMapper\Pdo\Connection\AbstractConnection

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Connection | | Uses | BadMethodCallException, Phalcon\DataMapper\Pdo\Exception\CannotBindValue, Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface | | Implements | ConnectionInterface |

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

@property PDO $pdo @property ProfilerInterface $profiler

Properties

/**
 * @var PDO
 */
protected pdo;

/**
 * @var ProfilerInterface
 */
protected profiler;

Methods

public function __call( mixed $name, array $arguments );
Proxies to PDO methods created for specific drivers; in particular, sqlite and pgsql.

public function beginTransaction(): bool;
Begins a transaction. If the profiler is enabled, the operation will be recorded.

public function commit(): bool;
Commits the existing transaction. If the profiler is enabled, the operation will be recorded.

abstract public function connect(): void;
Connects to the database.

abstract public function disconnect(): void;
Disconnects from the database.

public function errorCode(): string | null;
Gets the most recent error code.

public function errorInfo(): array;
Gets the most recent error info.

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.

public function fetchAffected( string $statement, array $values = [] ): int;
Performs a statement and returns the number of affected rows.

public function fetchAll( string $statement, array $values = [] ): array;
Fetches a sequential array of rows from the database; the rows are returned as associative arrays.

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.

public function fetchColumn( string $statement, array $values = [], int $column = int ): array;
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;
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

public function fetchObject( string $statement, array $values = [], string $className = string, 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

public function fetchObjects( string $statement, array $values = [], string $className = string, 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

public function fetchOne( string $statement, array $values = [] ): array;
Fetches one row from the database as an associative array.

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).

public function fetchValue( string $statement, array $values = [] );
Fetches the very first value (i.e., first column of the first row).

public function getAdapter(): \PDO;
Return the inner PDO (if any)

public function getAttribute( int $attribute ): mixed;
Retrieve a database connection attribute

public static function getAvailableDrivers(): array;
Return an array of available PDO drivers (empty array if none available)

public function getDriverName(): string;
Return the driver name

public function getProfiler(): ProfilerInterface;
Returns the Profiler instance.

public function getQuoteNames( string $driver = string ): array;
Gets the quote parameters based on the driver

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.

public function isConnected(): bool;
Is the PDO connection active?

public function lastInsertId( string $name = null ): string;
Returns the last inserted autoincrement sequence value. If the profiler is enabled, the operation will be recorded.

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.

public function prepare( string $statement, array $options = [] ): \PDOStatement | bool;
Prepares an SQL statement for execution.

public function query( string $statement ): \PDOStatement | bool;
Queries the database and returns a PDOStatement. If the profiler is enabled, the operation will be recorded.

public function quote( mixed $value, int $type = static-constant-access ): 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

public function rollBack(): bool;
Rolls back the current transaction, and restores autocommit mode. If the profiler is enabled, the operation will be recorded.

public function setAttribute( int $attribute, mixed $value ): bool;
Set a database connection attribute

public function setProfiler( ProfilerInterface $profiler );
Sets the Profiler instance.

protected function fetchData( string $method, array $arguments, string $statement, array $values = [] ): array;
Helper method to get data from PDO based on the method passed

protected function performBind( \PDOStatement $statement, mixed $name, mixed $arguments ): void;
Bind a value using the proper PDO::PARAM_* type.

Interface Phalcon\DataMapper\Pdo\Connection\ConnectionInterface

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Connection | | Uses | Phalcon\DataMapper\Pdo\Exception\CannotBindValue, Phalcon\DataMapper\Pdo\Parser\ParserInterface, Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface | | Extends | PdoInterface |

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

@property array $args @property PDO $pdo @property ProfilerInterface $profiler @property array $quote

Methods

public function connect(): void;
Connects to the database.

public function disconnect(): void;
Disconnects from the database.

public function fetchAffected( string $statement, array $values = [] ): int;
Performs a statement and returns the number of affected rows.

public function fetchAll( string $statement, array $values = [] ): array;
Fetches a sequential array of rows from the database; the rows are returned as associative arrays.

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.

public function fetchColumn( string $statement, array $values = [], int $column = int ): array;
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;
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

public function fetchObject( string $statement, array $values = [], string $className = string, 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

public function fetchObjects( string $statement, array $values = [], string $className = string, 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

public function fetchOne( string $statement, array $values = [] ): array;
Fetches one row from the database as an associative array.

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).

public function fetchValue( string $statement, array $values = [] ): mixed;
Fetches the very first value (i.e., first column of the first row).

public function getAdapter(): \PDO;
Return the inner PDO (if any)

public function getProfiler(): ProfilerInterface;
Returns the Profiler instance.

public function isConnected(): bool;
Is the PDO connection active?

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.

public function setProfiler( ProfilerInterface $profiler );
Sets the Profiler instance.

Class Phalcon\DataMapper\Pdo\Connection\Decorated

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Connection | | Uses | Phalcon\DataMapper\Pdo\Exception\CannotDisconnect, Phalcon\DataMapper\Pdo\Profiler\Profiler, Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface | | Extends | AbstractConnection |

Decorates an existing PDO instance with the extended methods.

Methods

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.

public function connect(): void;
Connects to the database.

public function disconnect(): void;
Disconnects from the database; disallowed with decorated PDO connections.

@throws CannotDisconnect

Interface Phalcon\DataMapper\Pdo\Connection\PdoInterface

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Connection |

An interface to the native PDO object.

Methods

public function beginTransaction(): bool;
Begins a transaction. If the profiler is enabled, the operation will be recorded.

public function commit(): bool;
Commits the existing transaction. If the profiler is enabled, the operation will be recorded.

public function errorCode(): null | string;
Gets the most recent error code.

public function errorInfo(): array;
Gets the most recent error info.

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.

public function getAttribute( int $attribute ): mixed;
Retrieve a database connection attribute

public static function getAvailableDrivers(): array;
Return an array of available PDO drivers (empty array if none available)

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.

public function lastInsertId( string $name = null ): string;
Returns the last inserted autoincrement sequence value. If the profiler is enabled, the operation will be recorded.

public function prepare( string $statement, array $options = [] ): \PDOStatement | bool;
Prepares an SQL statement for execution.

public function query( string $statement ): \PDOStatement | bool;
Queries the database and returns a PDOStatement. If the profiler is enabled, the operation will be recorded.

public function quote( mixed $value, int $type = static-constant-access ): 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

public function rollBack(): bool;
Rolls back the current transaction, and restores autocommit mode. If the profiler is enabled, the operation will be recorded.

public function setAttribute( int $attribute, mixed $value ): bool;
Set a database connection attribute

Class Phalcon\DataMapper\Pdo\ConnectionLocator

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo | | Uses | Phalcon\DataMapper\Pdo\Connection\ConnectionInterface, Phalcon\DataMapper\Pdo\Exception\ConnectionNotFound | | Implements | ConnectionLocatorInterface |

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

@property callable $master @property array $read @property array $write

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

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

public function getMaster(): ConnectionInterface;
Returns the default connection object.

public function getRead( string $name = string ): 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.

public function getWrite( string $name = string ): 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.

public function setMaster( ConnectionInterface $callableObject ): ConnectionLocatorInterface;
Sets the default connection factory.

public function setRead( string $name, callable $callableObject ): ConnectionLocatorInterface;
Sets a read connection factory by name.

public function setWrite( string $name, callable $callableObject ): ConnectionLocatorInterface;
Sets a write connection factory by name.

protected function getConnection( string $type, string $name = string ): ConnectionInterface;
Returns a connection by name.

Interface Phalcon\DataMapper\Pdo\ConnectionLocatorInterface

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo | | Uses | Phalcon\DataMapper\Pdo\Connection\ConnectionInterface |

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

Methods

public function getMaster(): ConnectionInterface;
Returns the default connection object.

public function getRead( string $name = string ): 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.

public function getWrite( string $name = string ): 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.

public function setMaster( ConnectionInterface $callableObject ): ConnectionLocatorInterface;
Sets the default connection registry entry.

public function setRead( string $name, callable $callableObject ): ConnectionLocatorInterface;
Sets a read connection registry entry by name.

public function setWrite( string $name, callable $callableObject ): ConnectionLocatorInterface;
Sets a write connection registry entry by name.

Class Phalcon\DataMapper\Pdo\Exception\CannotDisconnect

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Exception | | Extends | Exception |

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

Class Phalcon\DataMapper\Pdo\Exception\ConnectionNotFound

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Exception | | Extends | Exception |

Locator could not find a named connection.

Class Phalcon\DataMapper\Pdo\Exception\Exception

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Exception | | Extends | \Exception |

Base Exception class

Class Phalcon\DataMapper\Pdo\Profiler\MemoryLogger

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Profiler | | Uses | Psr\Log\AbstractLogger | | Extends | AbstractLogger |

A naive memory-based logger.

@property array $messages

Properties

/**
 * @var array
 */
protected messages;

Methods

public function getMessages();
Returns the logged messages.

public function log( mixed $level, mixed $message, array $context = [] );
Logs a message.

Class Phalcon\DataMapper\Pdo\Profiler\Profiler

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Profiler | | Uses | Phalcon\DataMapper\Pdo\Exception\Exception, Phalcon\Helper\Json, Psr\Log\LoggerInterface, Psr\Log\LogLevel | | Implements | ProfilerInterface |

Sends query profiles to a logger.

@property bool $active @property array $context @property string $logFormat @property string $logLevel @property LoggerInterface $logger

Properties

/**
 * @var bool
 */
protected active = false;

/**
 * @var array
 */
protected context;

/**
 * @var string
 */
protected logFormat = ;

/**
 * @var int
 */
protected logLevel = 0;

/**
 * @var LoggerInterface
 */
protected logger;

Methods

public function __construct( LoggerInterface $logger = null );
Constructor.

public function finish( string $statement = null, array $values = [] ): void;
Finishes and logs a profile entry.

public function getLogFormat(): string;
Returns the log message format string, with placeholders.

public function getLogLevel(): string;
Returns the level at which to log profile messages.

public function getLogger(): LoggerInterface;
Returns the underlying logger instance.

public function isActive(): bool;
Returns true if logging is active.

public function setActive( bool $active ): ProfilerInterface;
Enable or disable profiler logging.

public function setLogFormat( string $logFormat ): ProfilerInterface;
Sets the log message format string, with placeholders.

public function setLogLevel( string $logLevel ): ProfilerInterface;
Level at which to log profile messages.

public function start( string $method ): void;
Starts a profile entry.

Interface Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface

Source on GitHub

| Namespace | Phalcon\DataMapper\Pdo\Profiler | | Uses | Psr\Log\LoggerInterface |

Interface to send query profiles to a logger.

Methods

public function finish( string $statement = null, array $values = [] ): void;
Finishes and logs a profile entry.

public function getLogFormat(): string;
Returns the log message format string, with placeholders.

public function getLogLevel(): string;
Returns the level at which to log profile messages.

public function getLogger(): LoggerInterface;
Returns the underlying logger instance.

public function isActive(): bool;
Returns true if logging is active.

public function setActive( bool $active ): ProfilerInterface;
Enable or disable profiler logging.

public function setLogFormat( string $logFormat ): ProfilerInterface;
Sets the log message format string, with placeholders.

public function setLogLevel( string $logLevel ): ProfilerInterface;
Level at which to log profile messages.

public function start( string $method ): void;
Starts a profile entry.

Abstract Class Phalcon\DataMapper\Query\AbstractConditions

Source on GitHub

| Namespace | Phalcon\DataMapper\Query | | Uses | Phalcon\Helper\Arr | | Extends | AbstractQuery |

Class AbstractConditions

Methods

public function andWhere( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
Sets a AND for a WHERE condition

public function appendWhere( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
Concatenates to the most recent WHERE clause

public function limit( int $limit ): AbstractConditions;
Sets the LIMIT clause

public function offset( int $offset ): AbstractConditions;
Sets the OFFSET clause

public function orWhere( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
Sets a OR for a WHERE condition

public function orderBy( mixed $orderBy ): AbstractConditions;
Sets the ORDER BY

public function where( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
Sets a WHERE condition

public function whereEquals( array $columnsValues ): AbstractConditions;

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

protected function appendCondition( string $store, string $condition, mixed $value = null, int $type = int ): void;
Concatenates a conditional

protected function buildBy( string $type ): string;
Builds a BY list

protected function buildCondition( string $type ): string;
Builds the conditional string

protected function buildLimit(): string;
Builds the LIMIT clause

protected function buildLimitCommon(): string;
Builds the LIMIT clause for all drivers

protected function buildLimitEarly(): string;
Builds the early LIMIT clause - MS SQLServer

protected function buildLimitSqlsrv(): string;
Builds the LIMIT clause for MSSQLServer

protected function processValue( string $store, mixed $data ): void;
Processes a value (array or string) and merges it with the store

Abstract Class Phalcon\DataMapper\Query\AbstractQuery

Source on GitHub

| Namespace | Phalcon\DataMapper\Query | | Uses | Phalcon\DataMapper\Pdo\Connection |

Class AbstractQuery

@property Bind $bind @property Connection $connection @property array $store

Properties

/**
 * @var Bind
 */
protected bind;

/**
 * @var Connection
 */
protected connection;

/**
 * @var array
 */
protected store;

Methods

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

public function bindInline( mixed $value, int $type = int ): string;
Binds a value inline

public function bindValue( string $key, mixed $value, int $type = int ): AbstractQuery;
Binds a value - auto-detects the type if necessary

public function bindValues( array $values ): AbstractQuery;
Binds an array of values

public function getBindValues(): array;
Returns all the bound values

abstract public function getStatement(): string;
Return the generated statement

public function perform();
Performs a statement in the connection

public function quoteIdentifier( string $name, int $type = static-constant-access ): string;
Quotes the identifier

public function reset();
Resets the internal array

public function setFlag( string $flag, bool $enable = bool ): void;
Sets a flag for the query such as "DISTINCT"

protected function buildFlags();
Builds the flags statement(s)

protected function buildReturning(): string;
Builds the RETURNING clause

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

Class Phalcon\DataMapper\Query\Bind

Source on GitHub

| Namespace | Phalcon\DataMapper\Query |

Class Bind

@property int $inlineCount @property array $store

Properties

/**
 * @var int
 */
protected inlineCount = 0;

/**
 * @var array
 */
protected store;

Methods

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

public function remove( string $key ): void;
Removes a value from the store

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

public function setValues( array $values, int $type = int ): void;
Sets values from an array

public function toArray(): array;
Returns the internal collection

protected function getType( mixed $value ): int;
Auto detects the PDO type

protected function inlineArray( array $data, int $type ): string;
Processes an array - if passed as an inline parameter

Class Phalcon\DataMapper\Query\Delete

Source on GitHub

| Namespace | Phalcon\DataMapper\Query | | Uses | Phalcon\DataMapper\Pdo\Connection | | Extends | AbstractConditions |

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Implementation of this file has been influenced by AtlasPHP

@link https://github.com/atlasphp/Atlas.Query @license https://github.com/atlasphp/Atlas.Qyert/blob/1.x/LICENSE.md

Methods

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

public function from( string $table ): Delete;
Adds table(s) in the query

public function getStatement(): string;

public function reset(): void;
Resets the internal store

public function returning( array $columns ): Delete;
Adds the RETURNING clause

Class Phalcon\DataMapper\Query\Insert

Source on GitHub

| Namespace | Phalcon\DataMapper\Query | | Uses | Phalcon\DataMapper\Pdo\Connection | | Extends | AbstractQuery |

Class Insert

Methods

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

public function column( string $column, mixed $value = null, int $type = int ): Insert;
Sets a column for the INSERT query

public function columns( array $columns ): Insert;
Mass sets columns and values for the INSERT

public function getLastInsertId( string $name = null ): string;
Returns the id of the last inserted record

public function getStatement(): string;

public function into( string $table ): Insert;
Adds table(s) in the query

public function reset(): void;
Resets the internal store

public function returning( array $columns ): Insert;
Adds the RETURNING clause

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

Class Phalcon\DataMapper\Query\QueryFactory

Source on GitHub

| Namespace | Phalcon\DataMapper\Query | | Uses | Phalcon\DataMapper\Pdo\Connection |

Class QueryFactory

@property string $class

Properties

/**
 * @var string
 */
protected selectClass = ;

Methods

public function __construct( string $selectClass = string );
QueryFactory constructor.

public function newBind(): Bind;
Create a new Bind object

public function newDelete( Connection $connection ): Delete;
Create a new Delete object

public function newInsert( Connection $connection ): Insert;
Create a new Insert object

public function newSelect( Connection $connection ): Select;
Create a new Select object

public function newUpdate( Connection $connection ): Update;
Create a new Update object

Class Phalcon\DataMapper\Query\Select

Source on GitHub

| Namespace | Phalcon\DataMapper\Query | | Uses | BadMethodCallException, Phalcon\Helper\Arr | | Extends | AbstractConditions |

Class Select

@property string $asAlias @property bool $forUpdate

@method int fetchAffected() @method array fetchAll() @method array fetchAssoc() @method array fetchColumn(int $column = 0) @method array fetchGroup(int $flags = PDO::FETCH_ASSOC) @method object fetchObject(string $class = 'stdClass', array $arguments = []) @method array fetchObjects(string $class = 'stdClass', array $arguments = []) @method array fetchOne() @method array fetchPairs() @method mixed fetchValue()

Constants

const JOIN_INNER = INNER;
const JOIN_LEFT = LEFT;
const JOIN_NATURAL = NATURAL;
const JOIN_RIGHT = RIGHT;

Properties

/**
 * @var string
 */
protected asAlias = ;

/**
 * @var bool
 */
protected forUpdate = false;

Methods

public function __call( string $method, array $params );
Proxied methods to the connection

public function andHaving( string $condition, mixed $value = null, int $type = int ): Select;
Sets a AND for a HAVING condition

public function appendHaving( string $condition, mixed $value = null, int $type = int ): Select;
Concatenates to the most recent HAVING clause

public function appendJoin( string $condition, mixed $value = null, int $type = int ): Select;
Concatenates to the most recent JOIN clause

public function asAlias( string $asAlias ): Select;
The AS statement for the query - useful in sub-queries

public function columns(): Select;
The columns to select from. If a key is set in an array element, the key will be used as the alias

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

public function forUpdate( bool $enable = bool ): Select;
Enable the FOR UPDATE for the query

public function from( string $table ): Select;
Adds table(s) in the query

public function getStatement(): string;
Returns the compiled SQL statement

public function groupBy( mixed $groupBy ): Select;
Sets the GROUP BY

public function hasColumns(): bool;
Whether the query has columns or not

public function having( string $condition, mixed $value = null, int $type = int ): Select;
Sets a HAVING condition

public function join( string $join, string $table, string $condition, mixed $value = null, int $type = int ): Select;
Sets a 'JOIN' condition

public function orHaving( string $condition, mixed $value = null, int $type = int ): Select;
Sets a OR for a HAVING condition

public function reset(): Select;
Resets the internal collections

public function subSelect(): Select;
Start a sub-select

public function union(): Select;
Start a UNION

public function unionAll(): Select;
Start a UNION ALL

protected function getCurrentStatement( string $suffix = string ): string;
Statement builder

Class Phalcon\DataMapper\Query\Update

Source on GitHub

| Namespace | Phalcon\DataMapper\Query | | Uses | Phalcon\DataMapper\Pdo\Connection | | Extends | AbstractConditions |

Class Update

Methods

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

public function column( string $column, mixed $value = null, int $type = int ): Update;
Sets a column for the UPDATE query

public function columns( array $columns ): Update;
Mass sets columns and values for the UPDATE

public function from( string $table ): Update;
Adds table(s) in the query

public function getStatement(): string;

public function hasColumns(): bool;
Whether the query has columns or not

public function reset(): void;
Resets the internal store

public function returning( array $columns ): Update;
Adds the RETURNING clause

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