Phalcon datamapper
DataMapper\Pdo\Connection
GitHub上的源码
-
命名空间
-
使用
InvalidArgumentException
Phalcon\DataMapper\Pdo\Connection\AbstractConnection
Phalcon\DataMapper\Pdo\Profiler\Profiler
Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface
-
继承
AbstractConnection
-
实现
提供数组引用、性能分析以及新的方法perform()
方法fetch*()
新方法
属性
/**
* @var array
*/
protected $arguments;
方法
public function __construct( string $dsn, string $username = null, string $password = null, array $options = [], array $queries = [], ProfilerInterface $profiler = null );
构造函数。 此方法重写了父类,以便可以将连接属性作为构造函数参数传入,并在连接后设置它们。
public function __debugInfo(): array;
该方法的目的是从堆栈跟踪中隐藏敏感数据。 public function connect(): void;
连接到数据库。 public function disconnect(): void;
从数据库断开连接。 DataMapper\Pdo\Connection\AbstractConnection
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Connection
-
使用
BadMethodCallException
Phalcon\DataMapper\Pdo\Exception\CannotBindValue
Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface
-
继承
-
实现
提供数组引用、性能分析以及新的方法perform()
方法fetch*()
新方法
属性
/**
* @var \PDO
*/
protected $pdo;
/**
* @var ProfilerInterface
*/
protected $profiler;
方法
public function __call( mixed $name, array $arguments );
代理到特定驱动程序创建的 PDO 方法;特别是:sqlite
和pgsql
. public function beginTransaction(): bool;
开始一个事务。如果启用了性能分析器,操作将被记录。 public function commit(): bool;
提交当前事务。如果启用了性能分析器,操作将被记录。 abstract public function connect(): void;
连接到数据库。 abstract public function disconnect(): void;
从数据库断开连接。 public function errorCode(): string | null;
获取最近的错误代码。 public function errorInfo(): array;
获取最近的错误信息。 public function exec( string $statement ): int;
执行一条 SQL 语句并返回受影响的行数。如果启用了性能分析器,操作将被记录。 public function fetchAffected( string $statement, array $values = [] ): int;
执行一个语句并返回受影响的行数。 public function fetchAll( string $statement, array $values = [] ): array;
从数据库获取一连串的行;这些行以关联数组的形式返回。 public function fetchAssoc( string $statement, array $values = [] ): array;
从数据库中获取一个关联数组的行;这些行作为关联数组返回,并且行的数组以每行的第一个列为键。 如果多行具有相同的第一个列值,则具有该值的最后一行将覆盖之前的行。此方法资源消耗更大,应尽可能避免使用。
public function fetchColumn( string $statement, array $values = [], int $column = int ): array;
将一列数据作为顺序数组(默认为第一列)进行获取。 public function fetchGroup( string $statement, array $values = [], int $flags = static-constant-access ): array;
从数据库中获取多个数据并作为关联数组返回。第一列将作为索引键。默认标志为 PDO::FETCH_ASSOC | PDO::FETCH_GROUP。 public function fetchObject( string $statement, array $values = [], string $className = string, array $arguments = [] ): object;
从数据库中获取一行并作为对象返回,其中列的值映射到对象属性。 由于 PDO 在调用构造函数之前会注入属性值,因此如果你的对象构造函数中存在任何可能的默认初始化,将会覆盖由 PDO 注入的值。fetchObject
返回的默认对象是\stdClass
public function fetchObjects( string $statement, array $values = [], string $className = string, array $arguments = [] ): array;
从数据库中获取一个顺序数组的行;每一行作为对象返回,列的值被映射到对象属性。 由于 PDO 在调用构造函数之前会注入属性值,因此如果你的对象构造函数中存在任何可能的默认初始化,将会覆盖由 PDO 注入的值。fetchObject
返回的默认对象是\stdClass
public function fetchOne( string $statement, array $values = [] ): array;
从数据库中获取一行并作为关联数组返回。 public function fetchPairs( string $statement, array $values = [] ): array;
将行作为一个键值对的关联数组来获取(第一列是键,第二列是值)。 public function fetchValue( string $statement, array $values = [] );
获取第一个值(即第一行的第一列)。 public function getAdapter(): \PDO;
返回内部的 PDO(如果存在的话)。 public function getAttribute( int $attribute ): mixed;
检索数据库连接属性。 public static function getAvailableDrivers(): array;
返回可用 PDO 驱动程序的数组(如果没有可用驱动程序则返回空数组)。 public function getDriverName(): string;
返回驱动名称 public function getProfiler(): ProfilerInterface;
返回 Profiler 实例。 public function getQuoteNames( string $driver = string ): array;
根据驱动获取引用参数 public function inTransaction(): bool;
当前是否有活跃的事务?如果启用了性能分析器,操作将被记录。如果启用了性能分析器,操作将被记录。 public function isConnected(): bool;
PDO 连接是否处于活动状态? public function lastInsertId( string $name = null ): string;
返回最后插入的自增序列值。如果启用了性能分析器,操作将被记录。 public function perform( string $statement, array $values = [] ): \PDOStatement;
使用绑定值执行查询并返回生成的 PDOStatement;数组值将通过quote()
它们的相应占位符将在查询字符串中替换。如果启用了性能分析器,操作将被记录。 public function prepare( string $statement, array $options = [] ): \PDOStatement | bool;
准备一个 SQL 语句用于执行。 public function query( string $statement ): \PDOStatement | bool;
查询数据库并返回一个 PDOStatement。如果启用了性能分析器,操作将被记录。 public function quote( mixed $value, int $type = static-constant-access ): string;
对一个值进行引用处理,以便用于 SQL 语句中。这与PDO::quote()
不同之处在于它会将数组转换为逗号分隔的带引用的字符串。默认类型为PDO::PARAM_STR
public function rollBack(): bool;
回滚当前事务,并恢复自动提交模式。如果启用了性能分析器,操作将被记录。 public function setAttribute( int $attribute, mixed $value ): bool;
设置数据库连接属性。 public function setProfiler( ProfilerInterface $profiler );
设置 Profiler 实例。 protected function fetchData( string $method, array $arguments, string $statement, array $values = [] ): array;
基于传递的方法获取 PDO 数据的帮助方法 protected function performBind( \PDOStatement $statement, mixed $name, mixed $arguments ): void;
使用合适的 PDO::PARAM_* 类型绑定一个值。 DataMapper\Pdo\Connection\ConnectionInterface
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Connection
-
使用
Phalcon\DataMapper\Pdo\Exception\CannotBindValue
Phalcon\DataMapper\Pdo\Parser\ParserInterface
Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface
-
继承
PdoInterface
-
实现
提供数组引用、性能分析以及新的方法perform()
方法fetch*()
新方法
方法
public function connect(): void;
连接到数据库。 public function disconnect(): void;
从数据库断开连接。 public function fetchAffected( string $statement, array $values = [] ): int;
执行一个语句并返回受影响的行数。 public function fetchAll( string $statement, array $values = [] ): array;
从数据库获取一连串的行;这些行以关联数组的形式返回。 public function fetchAssoc( string $statement, array $values = [] ): array;
从数据库中获取一个关联数组的行;这些行作为关联数组返回,并且行的数组以每行的第一个列为键。 如果多行具有相同的第一个列值,则具有该值的最后一行将覆盖之前的行。此方法资源消耗更大,应尽可能避免使用。
public function fetchColumn( string $statement, array $values = [], int $column = int ): array;
将一列数据作为顺序数组(默认为第一列)进行获取。 public function fetchGroup( string $statement, array $values = [], int $flags = static-constant-access ): array;
从数据库中获取多个数据并作为关联数组返回。第一列将作为索引键。默认标志为 PDO::FETCH_ASSOC | PDO::FETCH_GROUP。 public function fetchObject( string $statement, array $values = [], string $className = string, array $arguments = [] ): object;
从数据库中获取一行并作为对象返回,其中列的值映射到对象属性。 由于 PDO 在调用构造函数之前会注入属性值,因此如果你的对象构造函数中存在任何可能的默认初始化,将会覆盖由 PDO 注入的值。fetchObject
返回的默认对象是\stdClass
public function fetchObjects( string $statement, array $values = [], string $className = string, array $arguments = [] ): array;
从数据库中获取一个顺序数组的行;每一行作为对象返回,列的值被映射到对象属性。 由于 PDO 在调用构造函数之前会注入属性值,因此如果你的对象构造函数中存在任何可能的默认初始化,将会覆盖由 PDO 注入的值。fetchObject
返回的默认对象是\stdClass
public function fetchOne( string $statement, array $values = [] ): array;
从数据库中获取一行并作为关联数组返回。 public function fetchPairs( string $statement, array $values = [] ): array;
将行作为一个键值对的关联数组来获取(第一列是键,第二列是值)。 public function fetchValue( string $statement, array $values = [] ): mixed;
获取第一个值(即第一行的第一列)。 public function getAdapter(): \PDO;
返回内部的 PDO(如果存在的话)。 public function getProfiler(): ProfilerInterface;
返回 Profiler 实例。 public function isConnected(): bool;
PDO 连接是否处于活动状态? public function perform( string $statement, array $values = [] ): \PDOStatement;
使用绑定值执行查询并返回生成的 PDOStatement;数组值将通过quote()
它们的相应占位符将在查询字符串中替换。如果启用了性能分析器,操作将被记录。 public function setProfiler( ProfilerInterface $profiler );
设置 Profiler 实例。 DataMapper\Pdo\Connection\Decorated
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Connection
-
使用
Phalcon\DataMapper\Pdo\Exception\CannotDisconnect
Phalcon\DataMapper\Pdo\Profiler\Profiler
Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface
-
继承
AbstractConnection
-
实现
使用扩展的方法装饰一个现有的 PDO 实例。
方法
public function __construct( \PDO $pdo, ProfilerInterface $profiler = null );
构造函数。 此方法重写了父类,以便接受一个已有的 PDO 实例,并为其添加扩展方法。
public function connect(): void;
连接到数据库。 public function disconnect(): void;
断开与数据库的连接;在使用装饰过的 PDO 连接时不允许断开。 @throws CannotDisconnect
DataMapper\Pdo\Connection\PdoInterface
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Connection
-
使用
-
继承
-
实现
原生 PDO 对象的接口。
方法
public function beginTransaction(): bool;
开始一个事务。如果启用了性能分析器,操作将被记录。 public function commit(): bool;
提交当前事务。如果启用了性能分析器,操作将被记录。 public function errorCode(): null | string;
获取最近的错误代码。 public function errorInfo(): array;
获取最近的错误信息。 public function exec( string $statement ): int;
执行一条 SQL 语句并返回受影响的行数。如果启用了性能分析器,操作将被记录。 public function getAttribute( int $attribute ): mixed;
检索数据库连接属性。 public static function getAvailableDrivers(): array;
返回可用 PDO 驱动程序的数组(如果没有可用驱动程序则返回空数组)。 public function inTransaction(): bool;
当前是否有活跃的事务?如果启用了性能分析器,操作将被记录。如果启用了性能分析器,操作将被记录。 public function lastInsertId( string $name = null ): string;
返回最后插入的自增序列值。如果启用了性能分析器,操作将被记录。 public function prepare( string $statement, array $options = [] ): \PDOStatement | bool;
准备一个 SQL 语句用于执行。 public function query( string $statement ): \PDOStatement | bool;
查询数据库并返回一个 PDOStatement。如果启用了性能分析器,操作将被记录。 public function quote( mixed $value, int $type = static-constant-access ): string;
对一个值进行引用处理,以便用于 SQL 语句中。这与PDO::quote()
不同之处在于它会将数组转换为逗号分隔的带引用的字符串。默认类型为PDO::PARAM_STR
public function rollBack(): bool;
回滚当前事务,并恢复自动提交模式。如果启用了性能分析器,操作将被记录。 public function setAttribute( int $attribute, mixed $value ): bool;
设置数据库连接属性。 DataMapper\Pdo\ConnectionLocator
GitHub上的源码
-
命名空间
-
使用
Phalcon\DataMapper\Pdo\Connection\ConnectionInterface
Phalcon\DataMapper\Pdo\Exception\ConnectionNotFound
-
继承
-
实现
ConnectionLocatorInterface
管理默认连接、读连接和写连接的 Connection 实例。
属性
/**
* 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;
方法
public function __construct( ConnectionInterface $master, array $read = [], array $write = [] );
构造函数。 public function getMaster(): ConnectionInterface;
返回默认的连接对象。 public function getRead( string $name = string ): ConnectionInterface;
按名称返回一个读连接;若未指定名称,则随机选取一个连接;若没有读连接,则返回默认连接。 public function getWrite( string $name = string ): ConnectionInterface;
按名称返回一个写连接;若未指定名称,则随机选取一个连接;若没有写连接,则返回默认连接。 public function setMaster( ConnectionInterface $callableObject ): ConnectionLocatorInterface;
设置默认连接工厂。 public function setRead( string $name, callable $callableObject ): ConnectionLocatorInterface;
按名称设置一个读连接工厂。 public function setWrite( string $name, callable $callableObject ): ConnectionLocatorInterface;
按名称设置一个写连接工厂。 protected function getConnection( string $type, string $name = string ): ConnectionInterface;
按名称返回一个连接。 DataMapper\Pdo\ConnectionLocatorInterface
GitHub上的源码
-
命名空间
-
使用
Phalcon\DataMapper\Pdo\Connection\ConnectionInterface
-
继承
-
实现
用于定位默认、读和写数据库的 PDO 连接。
方法
public function getMaster(): ConnectionInterface;
返回默认的连接对象。 public function getRead( string $name = string ): ConnectionInterface;
按名称返回一个读连接;若未指定名称,则随机选取一个连接;若没有读连接,则返回默认连接。 public function getWrite( string $name = string ): ConnectionInterface;
按名称返回一个写连接;若未指定名称,则随机选取一个连接;若没有写连接,则返回默认连接。 public function setMaster( ConnectionInterface $callableObject ): ConnectionLocatorInterface;
设置默认连接注册表项。 public function setRead( string $name, callable $callableObject ): ConnectionLocatorInterface;
按名称设置一个读连接注册表项。 public function setWrite( string $name, callable $callableObject ): ConnectionLocatorInterface;
按名称设置一个写连接注册表项。 DataMapper\Pdo\Exception\CannotDisconnect
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Exception
-
使用
-
继承
Exception
-
实现
ExtendedPdo 无法断开连接;例如,因为其 PDO 连接是由外部创建并注入的。
DataMapper\Pdo\Exception\ConnectionNotFound
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Exception
-
使用
-
继承
Exception
-
实现
定位器找不到指定名称的连接。
DataMapper\Pdo\Exception\Exception
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Exception
-
使用
-
继承
\Exception
-
实现
基础异常类。
DataMapper\Pdo\Profiler\MemoryLogger
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Profiler
-
使用
Phalcon\Logger\Adapter\AdapterInterface
Phalcon\Logger\Adapter\Noop
Phalcon\Logger\Enum
Phalcon\Logger\LoggerInterface
-
继承
-
实现
基于内存的日志记录器。
属性
/**
* @var array
*/
protected $messages;
方法
public function alert( string $message, array $context = [] ): void;
public function critical( string $message, array $context = [] ): void;
public function debug( string $message, array $context = [] ): void;
public function emergency( string $message, array $context = [] ): void;
public function error( string $message, array $context = [] ): void;
public function getAdapter( string $name ): AdapterInterface;
从堆栈中返回一个适配器 public function getAdapters(): array;
返回适配器堆栈数组 public function getLogLevel(): int;
返回日志级别 public function getMessages(): array;
返回记录的日志消息。 public function getName(): string;
返回日志记录器的名称 public function info( string $message, array $context = [] ): void;
public function log( mixed $level, string $message, array $context = [] ): void;
记录一条消息。 public function notice( string $message, array $context = [] ): void;
public function warning( string $message, array $context = [] ): void;
DataMapper\Pdo\Profiler\Profiler
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Profiler
-
使用
Phalcon\DataMapper\Pdo\Exception\Exception
Phalcon\Logger\Enum
Phalcon\Logger\LoggerInterface
Phalcon\Support\Helper\Json\Encode
-
继承
-
实现
将查询分析结果发送到日志记录器。
属性
/**
* @var bool
*/
protected $active = false;
/**
* @var array
*/
protected $context;
/**
* @var string
*/
protected $logFormat = ;
/**
* @var int
*/
protected $logLevel = ;
/**
* @var LoggerInterface
*/
protected $logger;
/**
* @var Encode
*/
private $encode;
方法
public function __construct( LoggerInterface $logger = null );
构造函数。 public function finish( string $statement = null, array $values = [] ): void;
完成并记录一个分析条目。 public function getLogFormat(): string;
返回带有占位符的日志消息格式字符串。 public function getLogLevel(): string;
返回用于记录分析消息的日志级别。 public function getLogger(): LoggerInterface;
返回底层的日志记录器实例。 public function isActive(): bool;
如果日志记录处于激活状态,则返回 true。 public function setActive( bool $active ): ProfilerInterface;
启用或禁用分析器日志记录。 public function setLogFormat( string $logFormat ): ProfilerInterface;
设置带有占位符的日志消息格式字符串。 public function setLogLevel( string $logLevel ): ProfilerInterface;
用于记录分析消息的日志级别。 public function start( string $method ): void;
开始一个分析条目。 DataMapper\Pdo\Profiler\ProfilerInterface
GitHub上的源码
-
命名空间
Phalcon\DataMapper\Pdo\Profiler
-
使用
Phalcon\Logger\LoggerInterface
-
继承
-
实现
接口:将查询分析结果发送到日志记录器。
方法
public function finish( string $statement = null, array $values = [] ): void;
完成并记录一个分析条目。 public function getLogFormat(): string;
返回带有占位符的日志消息格式字符串。 public function getLogLevel(): string;
返回用于记录分析消息的日志级别。 public function getLogger(): LoggerInterface;
返回底层的日志记录器实例。 public function isActive(): bool;
如果日志记录处于激活状态,则返回 true。 public function setActive( bool $active ): ProfilerInterface;
启用或禁用分析器日志记录。 public function setLogFormat( string $logFormat ): ProfilerInterface;
设置带有占位符的日志消息格式字符串。 public function setLogLevel( string $logLevel ): ProfilerInterface;
用于记录分析消息的日志级别。 public function start( string $method ): void;
开始一个分析条目。 DataMapper\Query\AbstractConditions
GitHub上的源码
-
命名空间
-
使用
-
继承
AbstractQuery
-
实现
AbstractConditions 类。
方法
public function andWhere( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
设置一个AND
的WHERE
条件 public function appendWhere( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
追加到最近的WHERE
子句 public function limit( int $limit ): AbstractConditions;
设置表单的LIMIT
子句 public function offset( int $offset ): AbstractConditions;
设置表单的OFFSET
子句 public function orWhere( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
设置一个OR
的WHERE
条件 public function orderBy( mixed $orderBy ): AbstractConditions;
设置表单的ORDER BY
public function where( string $condition, mixed $value = null, int $type = int ): AbstractConditions;
设置一个WHERE
条件 public function whereEquals( array $columnsValues ): AbstractConditions;
protected function addCondition( string $store, string $andor, string $condition, mixed $value = null, int $type = int ): void;
追加一个条件 protected function appendCondition( string $store, string $condition, mixed $value = null, int $type = int ): void;
连接一个条件 protected function buildBy( string $type ): string;
构造一个BY
列表 protected function buildCondition( string $type ): string;
构造条件字符串 protected function buildLimit(): string;
构造LIMIT
子句 protected function buildLimitCommon(): string;
构造LIMIT
子句(适用于所有驱动程序) protected function buildLimitEarly(): string;
构造早期的LIMIT
子句 - MS SQLServer protected function buildLimitSqlsrv(): string;
构造LIMIT
子句(适用于 MSSQLServer) protected function processValue( string $store, mixed $data ): void;
处理一个值(数组或字符串)并将其与存储合并 DataMapper\Query\AbstractQuery
GitHub上的源码
-
命名空间
-
使用
Phalcon\DataMapper\Pdo\Connection
-
继承
-
实现
AbstractQuery 类。
属性
/**
* @var Bind
*/
protected $bind;
/**
* @var Connection
*/
protected $connection;
/**
* @var array
*/
protected $store;
方法
public function __construct( Connection $connection, Bind $bind );
AbstractQuery 构造函数。 public function bindInline( mixed $value, int $type = int ): string;
内联绑定一个值 public function bindValue( string $key, mixed $value, int $type = int ): AbstractQuery;
绑定一个值 - 如有需要自动检测类型 public function bindValues( array $values ): AbstractQuery;
绑定一组值 public function getBindValues(): array;
返回所有已绑定的值 abstract public function getStatement(): string;
返回生成的语句 public function perform();
在连接中执行一条语句 public function quoteIdentifier( string $name, int $type = static-constant-access ): string;
引号标识符 public function reset(): void;
重置内部数组 public function resetColumns(): void;
重置列 public function resetFlags(): void;
重置标志 public function resetFrom(): void;
重置 from public function resetGroupBy(): void;
重置 group by public function resetHaving(): void;
重置 having public function resetLimit(): void;
重置 limit 和 offset public function resetOrderBy(): void;
重置 order by public function resetWhere(): void;
重置 where public function setFlag( string $flag, bool $enable = bool ): void;
设置查询标志,例如 "DISTINCT" protected function buildFlags();
构造标志语句 protected function buildReturning(): string;
构造RETURNING
子句 protected function indent( array $collection, string $glue = string ): string;
缩进一个集合 DataMapper\Query\Bind
GitHub上的源码
Bind 类。
属性
/**
* @var int
*/
protected $inlineCount = ;
/**
* @var array
*/
protected $store;
方法
public function bindInline( mixed $value, int $type = int ): string;
public function remove( string $key ): void;
从存储中移除一个值 public function setValue( string $key, mixed $value, int $type = int ): void;
设置一个值 public function setValues( array $values, int $type = int ): void;
从数组中设置多个值 public function toArray(): array;
返回内部集合 protected function getType( mixed $value ): int;
自动检测 PDO 类型 protected function inlineArray( array $data, int $type ): string;
处理一个数组 - 如果作为inline
参数 DataMapper\Query\Delete
GitHub上的源码
-
命名空间
-
使用
Phalcon\DataMapper\Pdo\Connection
-
继承
AbstractConditions
-
实现
删除查询
方法
public function __construct( Connection $connection, Bind $bind );
Delete 构造函数。 public function from( string $table ): Delete;
在查询中添加表 public function getStatement(): string;
public function reset(): void;
重置内部存储 public function returning( array $columns ): Delete;
添加RETURNING
子句 DataMapper\Query\Insert
GitHub上的源码
-
命名空间
-
使用
Phalcon\DataMapper\Pdo\Connection
-
继承
AbstractQuery
-
实现
插入查询
方法
public function __construct( Connection $connection, Bind $bind );
Insert 构造函数。 public function column( string $column, mixed $value = null, int $type = int ): Insert;
设置一个列用于INSERT
查询 public function columns( array $columns ): Insert;
批量设置列和值用于INSERT
public function getLastInsertId( string $name = null ): string;
返回最后一次插入记录的 ID public function getStatement(): string;
public function into( string $table ): Insert;
在查询中添加表 public function reset(): void;
重置内部存储 public function returning( array $columns ): Insert;
添加RETURNING
子句 public function set( string $column, mixed $value = null ): Insert;
设置列 = 值条件 DataMapper\Query\QueryFactory
GitHub上的源码
-
命名空间
-
使用
Phalcon\DataMapper\Pdo\Connection
-
继承
-
实现
QueryFactory
属性
/**
* @var string
*/
protected $selectClass = ;
方法
public function __construct( string $selectClass = string );
QueryFactory 构造函数。 public function newBind(): Bind;
创建一个新的 Bind 对象 public function newDelete( Connection $connection ): Delete;
创建一个新的 Delete 对象 public function newInsert( Connection $connection ): Insert;
创建一个新的 Insert 对象 public function newSelect( Connection $connection ): Select;
创建一个新的 Select 对象 public function newUpdate( Connection $connection ): Update;
创建一个新的 Update 对象 DataMapper\Query\Select
GitHub上的源码
-
命名空间
-
使用
-
继承
AbstractConditions
-
实现
Select 查询
常量
const JOIN_INNER = INNER;
const JOIN_LEFT = LEFT;
const JOIN_NATURAL = NATURAL;
const JOIN_RIGHT = RIGHT;
属性
/**
* @var string
*/
protected $asAlias = ;
/**
* @var bool
*/
protected $forUpdate = false;
方法
public function __call( string $method, array $params );
代理方法至连接 public function andHaving( string $condition, mixed $value = null, int $type = int ): Select;
设置一个AND
的HAVING
条件 public function appendHaving( string $condition, mixed $value = null, int $type = int ): Select;
追加到最近的HAVING
子句 public function appendJoin( string $condition, mixed $value = null, int $type = int ): Select;
追加到最近的JOIN
子句 public function asAlias( string $asAlias ): Select;
The AS
查询的语句 - 用于子查询非常有用 public function columns( array $columns ): Select;
要选择的列。如果数组元素中设置了键,则该键将被用作别名 public function distinct( bool $enable = bool ): Select;
public function forUpdate( bool $enable = bool ): Select;
启用FOR UPDATE
用于查询 public function from( string $table ): Select;
在查询中添加表 public function getStatement(): string;
返回编译后的 SQL 语句 public function groupBy( mixed $groupBy ): Select;
设置表单的GROUP BY
public function hasColumns(): bool;
查询是否有列 public function having( string $condition, mixed $value = null, int $type = int ): Select;
设置一个HAVING
条件 public function join( string $join, string $table, string $condition, mixed $value = null, int $type = int ): Select;
设置 'JOIN' 条件 public function orHaving( string $condition, mixed $value = null, int $type = int ): Select;
设置一个OR
的HAVING
条件 public function reset(): void;
重置内部集合 public function subSelect(): Select;
开始一个子查询 public function union(): Select;
开始一个UNION
public function unionAll(): Select;
开始一个UNION ALL
protected function getCurrentStatement( string $suffix = string ): string;
语句构建器 DataMapper\Query\Update
GitHub上的源码
-
命名空间
-
使用
Phalcon\DataMapper\Pdo\Connection
-
继承
AbstractConditions
-
实现
Update 查询
方法
public function __construct( Connection $connection, Bind $bind );
Update 构造函数。 public function column( string $column, mixed $value = null, int $type = int ): Update;
设置一个列用于UPDATE
查询 public function columns( array $columns ): Update;
批量设置列和值用于UPDATE
public function from( string $table ): Update;
在查询中添加表 public function getStatement(): string;
public function hasColumns(): bool;
查询是否有列 public function reset(): void;
重置内部存储 public function returning( array $columns ): Update;
添加RETURNING
子句 public function set( string $column, mixed $value = null ): Update;
设置列 = 值条件