Phalcon contracts
NOTE
All classes are prefixed with Phalcon
Contracts\Db\Adapter\Adapter
¶
-
Namespace
Phalcon\Contracts\Db\Adapter
-
Uses
Phalcon\Db\ColumnInterfacePhalcon\Db\DialectInterfacePhalcon\Db\IndexInterfacePhalcon\Db\RawValuePhalcon\Db\ReferenceInterfacePhalcon\Db\ResultInterface
-
Extends
-
Implements
Canonical contract for Phalcon\Db adapters.
@todo v7 — these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - addCheck() : bool - createMaterializedView() : bool - dropCheck() : bool - dropMaterializedView() : bool - onConflictUpdate() : string - refreshMaterializedView() : bool - returning() : string
Methods¶
Adds a column to a tablepublic function addForeignKey( string $tableName, string $schemaName, ReferenceInterface $reference ): bool;
public function addPrimaryKey( string $tableName, string $schemaName, IndexInterface $index ): bool;
public function delete( mixed $table, string $whereCondition = null, array $placeholders = [], array $dataTypes = [] ): bool;
public function dropForeignKey( string $tableName, string $schemaName, string $referenceName ): bool;
public function dropTable( string $tableName, string $schemaName = null, bool $ifExists = bool ): bool;
public function dropView( string $viewName, string $schemaName = null, bool $ifExists = bool ): bool;
public function execute( string $sqlStatement, array $bindParams = [], array $bindTypes = [] ): bool;
public function fetchAll( string $sqlQuery, int $fetchMode = int, array $bindParams = [], array $bindTypes = [] ): array;
public function fetchColumn( string $sqlQuery, array $placeholders = [], mixed $column = int ): string | bool;
// Getting count of robots
$robotsCount = $connection->fetchColumn("SELECT COUNT(*) FROM robots");
print_r($robotsCount);
// Getting name of last edited robot
$robot = $connection->fetchColumn(
"SELECT id, name FROM robots ORDER BY modified DESC",
1
);
print_r($robot);
public function fetchOne( string $sqlQuery, int $fetchMode = int, array $bindParams = [], array $bindTypes = [] ): array;
modifier appends a row-lock disposition keyword — pass Dialect::LOCK_NOWAIT or Dialect::LOCK_SKIP_LOCKED (or leave as Dialect::LOCK_NONE). Returns the SQL column definition from a column Gets a list of columns Gets the active connection unique identifier Return the default identity value to insert in an identity column Returns the default value to make the RBDM use the default value declared in the table definition // Inserting a new robot with a valid default value for the column 'year'
$success = $connection->insert(
"robots",
[
"Astro Boy",
$connection->getDefaultValue()
],
[
"name",
"year",
]
);
@todo Return NULL if this is not supported by the adapter
Return descriptor used to connect to the active database Returns internal dialect instance Returns the name of the dialect used Return internal PDO handler Returns the savepoint name to use for nested transactions Active SQL statement in the object without replace bound parameters Active SQL statement in the object Active SQL statement in the object Active SQL statement in the object Returns type of database system the adapter is used forpublic function insert( string $table, array $values, mixed $fields = null, mixed $dataTypes = null ): bool;
// Inserting a new robot
$success = $connection->insertAsDict(
"robots",
[
"name" => "Astro Boy",
"year" => 1952,
]
);
// Next SQL sentence is sent to the database system
INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public function modifyColumn( string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null ): bool;
public function query( string $sqlStatement, array $bindParams = [], array $bindTypes = [] ): ResultInterface | bool;
public function setNestedTransactionsWithSavepoints( bool $nestedTransactionsWithSavepoints ): Adapter;
sharedLock() for per-engine semantics. The optional modifier is passed straight through (use Dialect::LOCK_NOWAIT / Dialect::LOCK_SKIP_LOCKED for PostgreSQL). Check whether the database system requires a sequence to produce auto-numeric values SQLite does not support the DEFAULT keyword @deprecated Will re removed in the next version
Generates SQL checking for the existence of a schema.table Gets creation options from a tablepublic function update( string $table, mixed $fields, mixed $values, mixed $whereCondition = null, mixed $dataTypes = null ): bool;
public function updateAsDict( string $table, mixed $data, mixed $whereCondition = null, mixed $dataTypes = null ): bool;
// Updating existing robot
$success = $connection->updateAsDict(
"robots",
[
"name" => "New Astro Boy",
],
"id = 101"
);
// Next SQL sentence is sent to the database system
UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
Contracts\Db\Check
¶
-
Namespace
Phalcon\Contracts\Db
-
Uses
-
Extends
-
Implements
Canonical contract for Phalcon\Db\Check.
Methods¶
Gets the CHECK expression (the SQL boolean predicate). Gets the constraint name. An empty string indicates an unnamed CHECK constraint — the dialect will emit the clause without aCONSTRAINT prefix in that case. Contracts\Db\Column
¶
-
Namespace
Phalcon\Contracts\Db
-
Uses
-
Extends
-
Implements
Canonical contract for Phalcon\Db\Column.
@todo v7 — these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - getGenerationExpression() : string | null - isArray() : bool - isGenerated() : bool - isGenerationStored() : bool - isInvisible() : bool
Methods¶
Check whether field absolute to position in table Returns the type of bind handling Returns default value of column Returns column name Returns column scale Returns column size Returns column type Returns column type reference Returns column type values Check whether column has default value Auto-Increment Check whether column have first position in table Not null Check whether column have an numeric type Column is part of the primary key? Returns true if number column is unsignedContracts\Db\Dialect
¶
-
Namespace
Phalcon\Contracts\Db
-
Uses
Phalcon\Db\ColumnInterfacePhalcon\Db\IndexInterfacePhalcon\Db\ReferenceInterface
-
Extends
-
Implements
Canonical contract for Phalcon\Db dialects.
@todo v7 — these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - addCheck() : string - createMaterializedView() : string - dropCheck() : string - dropMaterializedView() : string - onConflictUpdate() : string - refreshMaterializedView() : string - returning() : string
Constants¶
Methods¶
public function addColumn( string $tableName, string $schemaName, ColumnInterface $column ): string;
public function addForeignKey( string $tableName, string $schemaName, ReferenceInterface $reference ): string;
public function addPrimaryKey( string $tableName, string $schemaName, IndexInterface $index ): string;
public function createView( string $viewName, array $definition, string $schemaName = null ): string;
public function dropForeignKey( string $tableName, string $schemaName, string $referenceName ): string;
public function dropView( string $viewName, string $schemaName = null, bool $ifExists = bool ): string;
modifier appends a row-lock disposition keyword — pass Dialect::LOCK_NOWAIT or Dialect::LOCK_SKIP_LOCKED (or leave as Dialect::LOCK_NONE). Gets the column name in RDBMS Gets a list of columns Returns registered functions public function getSqlExpression( array $expression, string $escapeChar = null, array $bindCounts = [] ): string;
public function modifyColumn( string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null ): string;
public function registerCustomFunction( string $name, callable $customFunction ): \Phalcon\Db\Dialect;
LOCK IN SHARE MODE; PostgreSQL emits FOR SHARE; SQLite returns the original query unchanged. The optional modifier appends a row-lock disposition keyword (Dialect::LOCK_NOWAIT / Dialect::LOCK_SKIP_LOCKED) for PostgreSQL — MySQL's legacy LOCK IN SHARE MODE does not support modifiers, so non-empty values are silently ignored on MySQL. Checks whether the platform supports releasing savepoints. Checks whether the platform supports savepoints Generates SQL checking for the existence of a schema.table Generates the SQL to describe the table creation options Generates SQL checking for the existence of a schema.view Contracts\Db\Index
¶
-
Namespace
Phalcon\Contracts\Db
-
Uses
-
Extends
-
Implements
Canonical contract for Phalcon\Db\Index.
@todo v7 — these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - getDirections() : array - getWhere() : string - isConcurrent() : bool - isInvisible() : bool
Methods¶
Gets the columns that corresponds the index Gets the index name Gets the index typeContracts\Db\Reference
¶
-
Namespace
Phalcon\Contracts\Db
-
Uses
-
Extends
-
Implements
Canonical contract for Phalcon\Db\Reference.
Methods¶
Gets local columns which reference is based Gets the index name Gets the referenced on delete Gets the referenced on update Gets referenced columns Gets the schema where referenced table is Gets the referenced table Gets the schema where referenced table isContracts\Db\Result
¶
-
Namespace
Phalcon\Contracts\Db
-
Uses
-
Extends
-
Implements
Canonical contract for Phalcon\Db result objects.
Methods¶
Moves internal resultset cursor to another position letting us to fetch a certain row Allows to execute the statement again. Some database systems don't support scrollable cursors. So, as cursors are forward only, we need to execute the cursor again to fetch rows from the beginning Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. This method is affected by the active fetch flag set usingPhalcon\Db\Result\Pdo::setFetchMode() Returns an array of arrays containing all the records in the result. This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode() Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode() Gets the internal PDO result object Gets number of rows returned by a resultset Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() Contracts\Encryption\Security\CryptoUtils
¶
-
Namespace
Phalcon\Contracts\Encryption\Security
-
Uses
Phalcon\Encryption\Security\Random
-
Extends
-
Implements
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.
Methods¶
Contracts\Encryption\Security\CsrfProtection
¶
-
Namespace
Phalcon\Contracts\Encryption\Security
-
Uses
-
Extends
-
Implements
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.
Methods¶
public function checkToken( string $tokenKey = null, mixed $tokenValue = null, bool $destroyIfValid = bool ): bool;
Contracts\Encryption\Security\PasswordSecurity
¶
-
Namespace
Phalcon\Contracts\Encryption\Security
-
Uses
-
Extends
-
Implements
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.
Methods¶
public function checkHash( string $password, string $passwordHash, int $maxPassLength = int ): bool;
Contracts\Encryption\Security\Security
¶
-
Namespace
Phalcon\Contracts\Encryption\Security
-
Uses
-
Extends
CryptoUtils -
Implements
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.
Contracts\Events\Event
¶
-
Namespace
Phalcon\Contracts\Events
-
Uses
-
Extends
-
Implements
Canonical contract for Phalcon\Events\Event.
Methods¶
Gets event data Gets event type Check whether the event is cancelable Check whether the event is currently stopped Sets event data Sets event type Stops the event preventing propagationContracts\Events\EventsAware
¶
-
Namespace
Phalcon\Contracts\Events
-
Uses
Phalcon\Events\ManagerInterface
-
Extends
-
Implements
Canonical contract for Phalcon\Events\EventsAwareInterface. Implemented by components that accept an events manager and dispatch through it.
Cross-references the legacy ManagerInterface (not the canonical Manager contract) to preserve LSP for the many AbstractEventsAware subclasses that already type-hint ManagerInterface. ManagerInterface extends Manager, so this remains type-compatible with any code that needs the canonical surface.
Methods¶
Returns the internal events manager Sets the events managerContracts\Events\Manager
¶
-
Namespace
Phalcon\Contracts\Events
-
Uses
-
Extends
-
Implements
Canonical contract for Phalcon\Events\Manager.
Constants¶
Methods¶
Registers an event subscriber. The subscriber's getSubscribedEvents() map is parsed and each entry is attached through the regular listener pipeline. Returns whether priority ordering is currently enabled.public function attach( string $eventType, mixed $handler, int $priority = static-constant-access ): void;
public function fire( string $eventType, object $source, mixed $data = null, bool $cancelable = bool );
Contracts\Events\Stoppable
¶
-
Namespace
Phalcon\Contracts\Events
-
Uses
-
Extends
-
Implements
Phalcon's local mirror of PSR-14 StoppableEventInterface. Identical shape; not extended from the PSR interface because the Zephir extension cannot reference Composer-loaded interfaces at build time. A separate bridge package exposes a PSR-14 adapter.
Methods¶
Returns true when the event must stop propagating to subsequent listeners.Contracts\Events\Subscriber
¶
-
Namespace
Phalcon\Contracts\Events
-
Uses
-
Extends
-
Implements
Contract for event subscriber classes. A subscriber declares the events it wants to listen to via a static map; Events\Manager parses the map and attaches each entry as a regular listener.
Accepted value shapes per event key:
'event:name' => 'methodName' 'event:name' => ['methodName', priority] 'event:name' => [ ['methodName1'], ['methodName2', priority], ]
Keys can be either a Phalcon event string (e.g. "db:beforeQuery") or a fully qualified event class name.
Wildcard subscriptions: Phalcon's manager fires both the prefix queue and the full-name queue (e.g. "db" is fired before "db:beforeQuery"). To subscribe to every event of a component, use the prefix as the key:
'db' => 'onAnyDbEvent' // fires for db:beforeQuery, db:afterQuery, ...
Methods¶
Returns a map of event name => listener config. Called once per Manager::addSubscriber() / removeSubscriber() call.Contracts\Forms\Schema
¶
-
Namespace
Phalcon\Contracts\Forms
-
Uses
-
Extends
-
Implements
Contract for objects that supply a normalized list of form element definitions. Implementations may source the definitions from a PHP array, a JSON document, a YAML file, or any other format.
Each returned definition must be an associative array containing at least: - 'type' (string) — element type key (e.g. 'text', 'select', 'checkgroup') - 'name' (string) — the HTML name attribute value
Optional keys per definition: - 'label' (string) — visible label text - 'default' (mixed) — pre-populated default value - 'attributes' (array) — additional HTML attributes - 'filters' (array|string) — filter names applied on bind() - 'validators' (array) — ValidatorInterface instances - 'options' (array) — choices for select / checkgroup / radiogroup
Methods¶
Returns an ordered list of normalized element definitions.Contracts\Html\Helper\Input\SelectData
¶
-
Namespace
Phalcon\Contracts\Html\Helper\Input
-
Uses
-
Extends
-
Implements
Interface for SELECT option data providers.
Return format: [value => label] for flat options; [groupLabel => [value => label, ...]] for optgroups.
Methods¶
Returns the per-option attribute map.Format: [optionValue => [attrName => stringValue, ...]]. Implementations must return resolved string values; no escaping, ordering, or rendering is performed here.
Contracts\Mvc\Model\Relation\CacheKeyProvider
¶
-
Namespace
Phalcon\Contracts\Mvc\Model\Relation
-
Uses
-
Extends
-
Implements
Interface for models that provide a custom unique key for the reusable records cache in the Model Manager. Implement this interface when the default object-identity based key (unique_key) does not produce stable cache hits across multiple object instances that represent the same database record.
Methods¶
Returns a string that uniquely identifies this model instance for use as the key in the reusable records cache.Contracts\Paginator\Adapter
¶
-
Namespace
Phalcon\Contracts\Paginator
-
Uses
-
Extends
-
Implements
Interface for Phalcon\Paginator adapters
Methods¶
Get current rows limit Returns a slice of the resultset to show in the pagination Set the current page number Set current rows limitContracts\Paginator\Repository
¶
-
Namespace
Phalcon\Contracts\Paginator
-
Uses
-
Extends
-
Implements
Interface for the repository of current state Phalcon\Paginator\AdapterInterface::paginate()
Constants¶
const PROPERTY_CURRENT_PAGE = current;
const PROPERTY_FIRST_PAGE = first;
const PROPERTY_ITEMS = items;
const PROPERTY_LAST_PAGE = last;
const PROPERTY_LIMIT = limit;
const PROPERTY_NEXT_PAGE = next;
const PROPERTY_PREVIOUS_PAGE = previous;
const PROPERTY_TOTAL_ITEMS = total_items;
Methods¶
Gets the aliases for properties repository Gets number of the current page Gets number of the first page Gets the items on the current page Gets number of the last page Gets current rows limit Gets number of the next page Gets number of the previous page Gets the total number of items Sets the aliases for properties repository Sets values for properties of the repositoryContracts\Support\Collection
¶
-
Namespace
Phalcon\Contracts\Support
-
Uses
ArrayAccessIteratorAggregate
-
Extends
ArrayAccess -
Implements
Canonical contract for Phalcon\Support\Collection.
@phpstan-template T
@extends ArrayAccess
Methods¶
Clears the internal collection. Returns the values from a single property/method extracted from every item in the collection, keyed by the original collection key. Invokes the callback for every item in the collection.@phpstan-param callable(T, array-key): mixed $callback
Returns a new collection of items for which the callback returns true.@phpstan-param callable(T, array-key): bool $callback @phpstan-return static
@phpstan-return T|null
Returns an element from the collection. Returns the keys (insensitive or not) of the collection.@deprecated Use {@see self::keys()} instead. Will be removed in a future major release.
Returns the configured runtime type guard, or null when not set. Returns the values of the internal array.@deprecated Use {@see self::values()} instead. Will be removed in a future major release.
Checks whether an element exists in the collection. Initializes the internal array. Returns true when the collection has no entries. Returns the keys (insensitive or not) of the collection. Returns the last value in the collection or null when empty.@phpstan-return T|null
Returns a new collection with the callback applied to every value.@phpstan-param callable(T, array-key): mixed $callback
Reduces the collection to a single value using the callback.@phpstan-param callable(mixed, T, array-key): mixed $callback
Removes the element from the collection. Replaces the collection data with a new array, clearing first. Stores an element in the collection.@phpstan-param T $value
Returns a new collection sorted by value, preserving keys.@phpstan-return static
@phpstan-return array
propertyOrMethod strictly equals $value. @phpstan-return static