# 数据库抽象层(Database Abstraction Layer)[](# "永久链接至标题")
[*Phalcon\Db*](#) 是 [*Phalcon\Mvc\Model*](#) 背后的一个组件,它为框架提供了强大的model层。它是一个完全由C语言写的独立的高级抽象层的数据库系统。
这个组件提供了比传统模式的更容易上手的数据库操作。
> 这个指引不是一个完整的包含所有方法和它们的参数的文档。查看完整的文档参考,请访问 [*API*](#)
### 数据库适配器(Database Adapters)[](# "永久链接至标题")
这个组件利用了这些适配器去封装特定的数据库的详细操作。Phalcon使用 [PDO](http://www.php.net/manual/en/book.pdo.php) 去连接这些数据库。下面这些是我们支持的数据库引擎:
| 名称 | 描述 | API |
|-----|-----|-----|
| MySQL | MySQL是这个世界上最多人使用的关系数据库,它作为服务器运行为多用户提供了访问多个数据库的功能。 | [*Phalcon\Db\Adapter\Pdo\Mysql*](#) |
| PostgreSQL | PostgreSQL是一个强大,开源的关系数据库。它拥有超过15年的积极发展和经过验证的架构,这些已经为它赢得了可靠性、数据完整性、正确性的良好的声誉 | [*Phalcon\Db\Adapter\Pdo\Postgresql*](#) |
| SQLite | SQLite是一个实现一个自包含的,无服务器,零配置,支持事务的SQL数据库引擎的软件库 | [*Phalcon\Db\Adapter\Pdo\Sqlite*](#) |
| Oracle | Oracle是一个对象-关系数据库,由甲骨文公司生产和销售。 | [*Phalcon\Db\Adapter\Pdo\Oracle*](#) |
### 自定义适配器(Implementing your own adapters)[](# "永久链接至标题")
如果你想创建自己的适配器或者扩展现有的适配器,这个 [*Phalcon\Db\AdapterInterface*](#) 接口必须被实现。
### 数据库“方言”[](# "永久链接至标题")
Phalcon把每个数据库引擎的具体操作封装成“方言”,这些“方言”提供了提供通用的功能和SQL生成的适配器。(译者注:这里的“方言”是指Phalcon把一些常用的数据库操作封装成类的方法,例如检查数据库中表是否存在,不再需要麻烦的手动写SQL,可以把调用tableExists方法去查询)
| 名称 | 描述 | API |
|-----|-----|-----|
| MySQL | MySQL的具体“方言” | [*Phalcon\Db\Dialect\Mysql*](#) |
| PostgreSQL | PostgreSQL的具体“方言” | [*Phalcon\Db\Dialect\Postgresql*](#) |
| SQLite | SQLite的具体“方言” | [*Phalcon\Db\Dialect\Sqlite*](#) |
| Oracle | Oracle的具体“方言” | [*Phalcon\Db\Dialect\Oracle*](#) |
### 自定义“方言”(Implementing your own dialects)[](# "永久链接至标题")
如果你想创建自己的“方言”或者扩展现有的“方言”,你需要实现这个接口: [*Phalcon\Db\DialectInterface*](#)
### 连接数据库(Connecting to Databases)[](# "永久链接至标题")
为了建立连接,实例化适配器类是必须的。它只接收一个包含连接参数的数组。下面的例子展示了,传递必要参数和可选项的参数去连接数据库:
~~~
<?php
// 必要参数
$config = array(
"host" => "127.0.0.1",
"username" => "mike",
"password" => "sigma",
"dbname" => "test_db"
);
// 可选参数
$config["persistent"] = false;
// 创建连接
$connection = new \Phalcon\Db\Adapter\Pdo\Mysql($config);
~~~
~~~
<?php
// 必要参数
$config = array(
"host" => "localhost",
"username" => "postgres",
"password" => "secret1",
"dbname" => "template"
);
// 可选参数
$config["schema"] = "public";
// 创建连接
$connection = new \Phalcon\Db\Adapter\Pdo\Postgresql($config);
~~~
~~~
<?php
// 必要参数
$config = array(
"dbname" => "/path/to/database.db"
);
// 创建连接
$connection = new \Phalcon\Db\Adapter\Pdo\Sqlite($config);
~~~
~~~
<?php
// 基本配置信息
$config = array(
'username' => 'scott',
'password' => 'tiger',
'dbname' => '192.168.10.145/orcl'
);
// 高级配置信息
$config = array(
'dbname' => '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=xe)(FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)(RETRIES=20)(DELAY=5))))',
'username' => 'scott',
'password' => 'tiger',
'charset' => 'AL32UTF8'
);
// 创建连接
$connection = new \Phalcon\Db\Adapter\Pdo\Oracle($config);
~~~
### 设置额外的 PDO 选项(Setting up additional PDO options)[](# "永久链接至标题")
你可以在连接的时候,通过传递'options'参数,设置PDO选项:
~~~
<?php
// 带PDO options参数的创建连接
$connection = new \Phalcon\Db\Adapter\Pdo\Mysql(
array(
"host" => "localhost",
"username" => "root",
"password" => "sigma",
"dbname" => "test_db",
"options" => array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES \'UTF8\'",
PDO::ATTR_CASE => PDO::CASE_LOWER
)
)
);
~~~
### 查找行(Finding Rows)[](# "永久链接至标题")
文档 [*Phalcon\Db*](#) 提供了几种方法去查询行。在这个例子中,SQL语句是必须符合数据库的SQL语法的:
~~~
<?php
$sql = "SELECT id, name FROM robots ORDER BY name";
// 发送SQL语句到数据库
$result = $connection->query($sql);
// 打印每个robot名称
while ($robot = $result->fetch()) {
echo $robot["name"];
}
// 返回一个包含返回结果的数组
$robots = $connection->fetchAll($sql);
foreach ($robots as $robot) {
echo $robot["name"];
}
// 只返回查询结果的第一条数据
$robot = $connection->fetchOne($sql);
~~~
默认情况下,这些调用会建立一个数组,数组中包含以字段名和以数字下标为key的值。你可以改变这种行为通过使用 Phalcon\Db\Result::setFetchMode() 。这个方法接受一个常量值,确定哪些类型的指标是被要求的。
| 常量 | 描述 |
|-----|-----|
| Phalcon\Db::FETCH_NUM | 返回一个包含数字下标的数组 |
| Phalcon\Db::FETCH_ASSOC | 返回一个包含字段名的数组 |
| Phalcon\Db::FETCH_BOTH | 返回一个包含字段名和数字下标的数组 |
| Phalcon\Db::FETCH_OBJ | 返回一个对象而不是一个数组 |
~~~
<?php
$sql = "SELECT id, name FROM robots ORDER BY name";
$result = $connection->query($sql);
$result->setFetchMode(Phalcon\Db::FETCH_NUM);
while ($robot = $result->fetch()) {
echo $robot[0];
}
~~~
这个 Phalcon\Db::query() 方法返回一个 [*Phalcon\Db\Result\Pdo*](#) 实例。这些对象封装了凡是涉及到返回的结果集的功能,例如遍历,寻找特定行,计算总行数等等
~~~
<?php
$sql = "SELECT id, name FROM robots";
$result = $connection->query($sql);
// 遍历结果集
while ($robot = $result->fetch()) {
echo $robot["name"];
}
// 获取第三条记录
$result->seek(2);
$robot = $result->fetch();
// 计算结果集的记录数
echo $result->numRows();
~~~
### 绑定参数(Binding Parameters)[](# "永久链接至标题")
在 [*Phalcon\Db*](#) 中支持绑定参数。虽然使用绑定参数会有很少性能的损失,但是我们鼓励你使用这个方法去消除(译者注:是消除,不是减少,因为使用参数绑定可以彻底解决SQL注入问题)SQL注入攻击的可能性。字符串和占位符都支持,就像下面展示的那样,绑定参数可以简单地实现:
~~~
<?php
// 用数字占位符绑定参数
$sql = "SELECT * FROM robots WHERE name = ? ORDER BY name";
$result = $connection->query($sql, array("Wall-E"));
// 用指定的占位符绑定参数
$sql = "INSERT INTO `robots`(name`, year) VALUES (:name, :year)";
$success = $connection->query($sql, array("name" => "Astro Boy", "year" => 1952));
~~~
When using numeric placeholders, you will need to define them as integers i.e. 1 or 2. In this case “1” or “2”are considered strings and not numbers, so the placeholder could not be successfully replaced. With any adapterdata are automatically escaped using [PDO Quote](http://www.php.net/manual/en/pdo.quote.php).
This function takes into account the connection charset, so its recommended to define the correct charsetin the connection parameters or in your database server configuration, as a wrongcharset will produce undesired effects when storing or retrieving data.
Also, you can pass your parameterers directly to the execute/query methods. In this casebound parameters are directly passed to PDO:
~~~
<?php
// Binding with PDO placeholders
$sql = "SELECT * FROM robots WHERE name = ? ORDER BY name";
$result = $connection->query($sql, array(1 => "Wall-E"));
~~~
### 插入、更新、删除行(Inserting/Updating/Deleting Rows)[](# "永久链接至标题")
去插入,更新或者删除行,你可以使用原生SQL操作,或者使用类中预设的方法
~~~
<?php
// 使用原生SQL插入行
$sql = "INSERT INTO `robots`(`name`, `year`) VALUES ('Astro Boy', 1952)";
$success = $connection->execute($sql);
// 使用带占位符的SQL插入行
$sql = "INSERT INTO `robots`(`name`, `year`) VALUES (?, ?)";
$success = $connection->execute($sql, array('Astro Boy', 1952));
// 使用类中预设的方法插入行
$success = $connection->insert(
"robots",
array("Astro Boy", 1952),
array("name", "year")
);
// 插入数据的另外一种方法
$success = $connection->insertAsDict(
"robots",
array(
"name" => "Astro Boy",
"year" => 1952
)
);
// 使用原生SQL更新行
$sql = "UPDATE `robots` SET `name` = 'Astro boy' WHERE `id` = 101";
$success = $connection->execute($sql);
// 使用带占位符的SQL更新行
$sql = "UPDATE `robots` SET `name` = ? WHERE `id` = ?";
$success = $connection->execute($sql, array('Astro Boy', 101));
// 使用类中预设的方法更新行
$success = $connection->update(
"robots",
array("name"),
array("New Astro Boy"),
"id = 101" // Warning! In this case values are not escaped
);
// 更新数据的另外一种方法
$success = $connection->updateAsDict(
"robots",
array(
"name" => "New Astro Boy"
),
"id = 101" // Warning! In this case values are not escaped
);
// With escaping conditions
$success = $connection->update(
"robots",
array("name"),
array("New Astro Boy"),
array(
'conditions' => 'id = ?',
'bind' => array(101),
'bindTypes' => array(PDO::PARAM_INT) // Optional parameter
)
);
$success = $connection->updateAsDict(
"robots",
array(
"name" => "New Astro Boy"
),
array(
'conditions' => 'id = ?',
'bind' => array(101),
'bindTypes' => array(PDO::PARAM_INT) // Optional parameter
)
);
// 使用原生SQL删除数据
$sql = "DELETE `robots` WHERE `id` = 101";
$success = $connection->execute($sql);
// 使用带占位符的SQL删除行
$sql = "DELETE `robots` WHERE `id` = ?";
$success = $connection->execute($sql, array(101));
// 使用类中预设的方法删除行
$success = $connection->delete("robots", "id = ?", array(101));
~~~
### 事务与嵌套事务(Transactions and Nested Transactions)[](# "永久链接至标题")
PDO支持事务工作。在事务里面执行数据操作, 在大多数数据库系统上, 往往可以提高数据库的性能:
~~~
<?php
try {
// 开始一个事务
$connection->begin();
// 执行一些操作
$connection->execute("DELETE `robots` WHERE `id` = 101");
$connection->execute("DELETE `robots` WHERE `id` = 102");
$connection->execute("DELETE `robots` WHERE `id` = 103");
// 提交操作,如果一切正常
$connection->commit();
} catch (Exception $e) {
// 如果发现异常,回滚操作
$connection->rollback();
}
~~~
除了标准的事务,Phalcon\Db提供了内置支持`嵌套事务`_(如果数据库系统支持的话)。当你第二次调用begin()方法,一个嵌套的事务就被创建了:
~~~
<?php
try {
// 开始一个事务
$connection->begin();
// 执行某些SQL操作
$connection->execute("DELETE `robots` WHERE `id` = 101");
try {
// 开始一个嵌套事务
$connection->begin();
// 在嵌套事务中执行这些SQL
$connection->execute("DELETE `robots` WHERE `id` = 102");
$connection->execute("DELETE `robots` WHERE `id` = 103");
// 创建一个保存的点
$connection->commit();
} catch (Exception $e) {
// 发生错误,释放嵌套的事务
$connection->rollback();
}
// 继续,执行更多SQL操作
$connection->execute("DELETE `robots` WHERE `id` = 104");
// 如果一切正常,提交
$connection->commit();
} catch (Exception $e) {
// 发生错误,回滚操作
$connection->rollback();
}
~~~
### 数据库事件(Database Events)[](# "永久链接至标题")
[*Phalcon\Db*](#) 可以发送事件到一个 [*EventsManager*](#) 中,如果它存在的话。一些事件当返回布尔值false可以停止操作。我们支持下面这些事件:
| 事件名 | 何时触发 | 可以停止操作吗? |
|-----|-----|-----|
| afterConnect | 当成功连接数据库之后触发 | No |
| beforeQuery | 在发送SQL到数据库前触发 | Yes |
| afterQuery | 在发送SQL到数据库执行后触发 | No |
| beforeDisconnect | 在关闭一个暂存的数据库连接前触发 | No |
| beginTransaction | 事务启动前触发 | No |
| rollbackTransaction | 事务回滚前触发 | No |
| commitTransaction | 事务提交前触发 | No |
绑定一个EventsManager给一个连接是很简单的,Phalcon\Db将触发这些类型为“db”的事件:
~~~
<?php
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Db\Adapter\Pdo\Mysql as Connection;
$eventsManager = new EventsManager();
// 监听所有数据库事件
$eventsManager->attach('db', $dbListener);
$connection = new Connection(
array(
"host" => "localhost",
"username" => "root",
"password" => "secret",
"dbname" => "invo"
)
);
// 把eventsManager分配给适配器实例
$connection->setEventsManager($eventsManager);
~~~
数据库事件中,停止操作是非常有用的,例如:如果你想要实现一个注入检查器,在发送SQL到数据库前触发:
~~~
<?php
$eventsManager->attach('db:beforeQuery', function ($event, $connection) {
// 检查是否有恶意关键词
if (preg_match('/DROP|ALTER/i', $connection->getSQLStatement())) {
// DROP/ALTER 操作是不允许的, 这肯定是一个注入!
// 返回false中断此操作
return false;
}
// 一切正常
return true;
});
~~~
### 分析 SQL 语句(Profiling SQL Statements)[](# "永久链接至标题")
[*Phalcon\Db*](#) 包含了一个性能分析组件,叫 [*Phalcon\Db\Profiler*](#) ,它被用于分析数据库的操作性能以便诊断性能问题,并发现瓶颈。使用 [*Phalcon\Db\Profiler*](#) 来分析数据库真的很简单:
~~~
<?php
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Db\Profiler as DbProfiler;
$eventsManager = new EventsManager();
$profiler = new DbProfiler();
// 监听所有数据库的事件
$eventsManager->attach('db', function ($event, $connection) use ($profiler) {
if ($event->getType() == 'beforeQuery') {
// 操作前启动分析
$profiler->startProfile($connection->getSQLStatement());
}
if ($event->getType() == 'afterQuery') {
// 操作后停止分析
$profiler->stopProfile();
}
});
// 设置事件管理器
$connection->setEventsManager($eventsManager);
$sql = "SELECT buyer_name, quantity, product_name "
. "FROM buyers "
. "LEFT JOIN products ON buyers.pid = products.id";
// 执行SQL
$connection->query($sql);
// 获取最后一个分析结果
$profile = $profiler->getLastProfile();
echo "SQL Statement: ", $profile->getSQLStatement(), "\n";
echo "Start Time: ", $profile->getInitialTime(), "\n";
echo "Final Time: ", $profile->getFinalTime(), "\n";
echo "Total Elapsed Time: ", $profile->getTotalElapsedSeconds(), "\n";
~~~
你也可以基于 [*Phalcon\Db\Profiler*](#) 建立你自己的分析器类,以记录SQL语句发送到数据库的实时统计:
~~~
<?php
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Db\Profiler as Profiler;
use Phalcon\Db\Profiler\Item as Item;
class DbProfiler extends Profiler
{
/**
* 在SQL语句将要发送给数据库前执行
*/
public function beforeStartProfile(Item $profile)
{
echo $profile->getSQLStatement();
}
/**
* 在SQL语句已经被发送到数据库后执行
*/
public function afterEndProfile(Item $profile)
{
echo $profile->getTotalElapsedSeconds();
}
}
// 创建一个事件管理器
$eventsManager = new EventsManager();
// 创建一个监听器
$dbProfiler = new DbProfiler();
// 设置监听器监听所有的数据库事件
$eventsManager->attach('db', $dbProfiler);
~~~
### 记录 SQL 语句(Logging SQL Statements)[](# "永久链接至标题")
使用例如 [*Phalcon\Db*](#) 的高级抽象组件操作数据库,被发送到数据库中执行的原生SQL语句是难以获知的。使用 [*Phalcon\Logger*](#) 和 [*Phalcon\Db*](#) 来配合使用,可以在数据库抽象层上提供记录的功能。
~~~
<?php
use Phalcon\Logger;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Logger\Adapter\File as FileLogger;
$eventsManager = new EventsManager();
$logger = new FileLogger("app/logs/db.log");
// 监听所有数据库事件
$eventsManager->attach('db', function ($event, $connection) use ($logger) {
if ($event->getType() == 'beforeQuery') {
$logger->log($connection->getSQLStatement(), Logger::INFO);
}
});
// 设置事件管理器
$connection->setEventsManager($eventsManager);
// 执行一些SQL
$connection->insert(
"products",
array("Hot pepper", 3.50),
array("name", "price")
);
~~~
如上操作,文件 *app/logs/db.log* 将包含像下面这样的信息:
~~~
[Sun, 29 Apr 12 22:35:26 -0500][DEBUG][Resource Id #77] INSERT INTO products
(name, price) VALUES ('Hot pepper', 3.50)
~~~
### 自定义日志记录器(Implementing your own Logger)[](# "永久链接至标题")
你可以实现你自己的日志类来记录数据库的所有操作,通过创建一个实现了”log”方法的类。这个方法需要接受一个字符串作为第一个参数。你可以把日志类的对象传递给Phalcon\Db::setLogger(),这样执行SQL时将调用这个对象的log方法去记录。
### 获取数据库表与视图信息(Describing Tables/Views)[](# "永久链接至标题")
[*Phalcon\Db*](#) 也提供了方法去检索详细的表和视图信息:
~~~
<?php
// 获取test_db数据库的所有表
$tables = $connection->listTables("test_db");
// 在数据库中是否存在'robots'这个表
$exists = $connection->tableExists("robots");
// 获取'robots'字段名称,数据类型,特殊特征
$fields = $connection->describeColumns("robots");
foreach ($fields as $field) {
echo "Column Type: ", $field["Type"];
}
// 获取'robots'表的所有索引
$indexes = $connection->describeIndexes("robots");
foreach ($indexes as $index) {
print_r($index->getColumns());
}
// 获取'robots'表的所有外键
$references = $connection->describeReferences("robots");
foreach ($references as $reference) {
// 打印引用的列
print_r($reference->getReferencedColumns());
}
~~~
一个表的详细描述信息和MYSQL的describe命令返回的信息非常相似,它包含以下信息:
| 下标 | 描述 |
|-----|-----|
| Field | 字段名称 |
| Type | 字段类型 |
| Key | 是否是主键或者索引 |
| Null | 是否允许为空 |
对于被支持的数据库系统,获取视图的信息的方法也被实现了:
~~~
<?php
// 获取test_db数据库的视图
$tables = $connection->listViews("test_db");
// 'robots'视图是否存在数据库中
$exists = $connection->viewExists("robots");
~~~
### 创建/修改/删除表[](# "永久链接至标题")
不同的数据库系统(MySQL,Postgresql等)通过了CREATE, ALTER 或 DROP命令提供了用于创建,修改或删除表的功能。但是不同的数据库语法不同。[*Phalcon\Db*](#) 提供了统一的接口来改变表,而不需要区分基于目标存储系统上的SQL语法。
### 创建数据库表(Creating Tables)[](# "永久链接至标题")
下面这个例子展示了怎么建立一个表:
~~~
<?php
use \Phalcon\Db\Column as Column;
$connection->createTable(
"robots",
null,
array(
"columns" => array(
new Column(
"id",
array(
"type" => Column::TYPE_INTEGER,
"size" => 10,
"notNull" => true,
"autoIncrement" => true,
)
),
new Column(
"name",
array(
"type" => Column::TYPE_VARCHAR,
"size" => 70,
"notNull" => true,
)
),
new Column(
"year",
array(
"type" => Column::TYPE_INTEGER,
"size" => 11,
"notNull" => true,
)
)
)
)
);
~~~
Phalcon\Db::createTable()接受一个描述数据库表相关的数组。字段被定义成class [*Phalcon\Db\Column*](#) 。下表列出了可用于定义字段的选项:
Phalcon\Db 支持下面的数据库字段类型:
- Phalcon\Db\Column::TYPE_INTEGER
- Phalcon\Db\Column::TYPE_DATE
- Phalcon\Db\Column::TYPE_VARCHAR
- Phalcon\Db\Column::TYPE_DECIMAL
- Phalcon\Db\Column::TYPE_DATETIME
- Phalcon\Db\Column::TYPE_CHAR
- Phalcon\Db\Column::TYPE_TEXT
传入Phalcon\Db::createTable() 的相关数组可能含有的下标:
| 下标 | 描述 | 是否可选 |
|-----|-----|-----|
| “columns” | 一个数组包含表的所有字段,字段要定义成 [*Phalcon\Db\Column*](#) | 不 |
| “indexes” | 一个数组包含表的所有索引,索引要定义成 [*Phalcon\Db\Index*](#) | 是 |
| “references” | 一个数组包含表的所有外键,外键要定义成 [*Phalcon\Db\Reference*](#) | 是 |
| “options” | 一个表包含所有创建的选项. 这些选项常常和数据库迁移有关. | 是 |
### 修改数据库表(Altering Tables)[](# "永久链接至标题")
随着你的应用的增长,作为一个重构的一部分,或者增加新功能,你也许需要修改你的数据库。因为不是所有的数据库允许你修改已存在的字段或者添加字段在2个已存在的字段之间。所以 [*Phalcon\Db*](#)会受到数据库系统的这些限制。
~~~
<?php
use Phalcon\Db\Column as Column;
// 添加一个新的字段
$connection->addColumn(
"robots",
null,
new Column(
"robot_type",
array(
"type" => Column::TYPE_VARCHAR,
"size" => 32,
"notNull" => true,
"after" => "name"
)
)
);
// 修改一个已存在的字段
$connection->modifyColumn(
"robots",
null,
new Column(
"name",
array(
"type" => Column::TYPE_VARCHAR,
"size" => 40,
"notNull" => true
)
)
);
// 删除名为"name"的字段
$connection->dropColumn(
"robots",
null,
"name"
);
~~~
### 删除数据库表(Dropping Tables)[](# "永久链接至标题")
删除数据库表的例子:
~~~
<?php
// 删除'robots'表
$connection->dropTable("robots");
// 删除数据库'machines'中的'robots'表
$connection->dropTable("robots", "machines");
~~~
|
- [索引](# "总目录")
- [下一页](# "国际化(Internationalization)") |
- [上一页](# "队列(Queueing)") |
- Phalcon 2.0.6文档
- API参考
- API列表
- Abstract class Phalcon\Acl
- Abstract class Phalcon\Acl\Adapter
- Class Phalcon\Acl\Adapter\Memory
- Interface Phalcon\Acl\AdapterInterface
- Class Phalcon\Acl\Exception
- Class Phalcon\Acl\Resource
- Interface Phalcon\Acl\ResourceInterface
- Class Phalcon\Acl\Role
- Interface Phalcon\Acl\RoleInterface
- Class Phalcon\Annotations\Annotation
- Abstract class Phalcon\Annotations\Adapter
- Class Phalcon\Annotations\Adapter\Apc
- Class Phalcon\Annotations\Adapter\Files
- Class Phalcon\Annotations\Adapter\Memory
- Class Phalcon\Annotations\Adapter\Xcache
- Interface Phalcon\Annotations\AdapterInterface
- Class Phalcon\Annotations\Collection
- Class Phalcon\Annotations\Exception
- Class Phalcon\Annotations\Reader
- Interface Phalcon\Annotations\ReaderInterface
- Class Phalcon\Annotations\Reflection
- Class Phalcon\Assets\Collection
- Class Phalcon\Assets\Exception
- Interface Phalcon\Assets\FilterInterface
- Class Phalcon\Assets\Filters\Cssmin
- Class Phalcon\Assets\Filters\Jsmin
- Class Phalcon\Assets\Filters\None
- Class Phalcon\Assets\Inline
- Class Phalcon\Assets\Inline\Css
- Class Phalcon\Assets\Inline\Js
- Class Phalcon\Assets\Manager
- Class Phalcon\Assets\Resource
- Class Phalcon\Assets\Resource\Css
- Class Phalcon\Assets\Resource\Js
- Abstract class Phalcon\Cache\Backend
- Class Phalcon\Cache\Backend\Apc
- Class Phalcon\Cache\Backend\File
- Class Phalcon\Cache\Backend\Libmemcached
- Class Phalcon\Cache\Backend\Memcache
- Class Phalcon\Cache\Backend\Memory
- Class Phalcon\Cache\Backend\Mongo
- Class Phalcon\Cache\Backend\Redis
- Class Phalcon\Cache\Backend\Xcache
- Interface Phalcon\Cache\BackendInterface
- Class Phalcon\Cache\Exception
- Class Phalcon\Cache\Frontend\Base64
- Class Phalcon\Cache\Frontend\Data
- Class Phalcon\Cache\Frontend\Igbinary
- Class Phalcon\Cache\Frontend\Json
- Class Phalcon\Cache\Frontend\None
- Class Phalcon\Cache\Frontend\Output
- Interface Phalcon\Cache\FrontendInterface
- Class Phalcon\Cache\Multiple
- Class Phalcon\Cli\Router\Route
- Class Phalcon\Config
- Class Phalcon\Config\Adapter\Ini
- Class Phalcon\Config\Adapter\Json
- Class Phalcon\Config\Adapter\Php
- Class Phalcon\Config\Adapter\Yaml
- Class Phalcon\Config\Exception
- Class Phalcon\Crypt
- Class Phalcon\Crypt\Exception
- Interface Phalcon\CryptInterface
- Abstract class Phalcon\Db
- Abstract class Phalcon\Db\Adapter
- Abstract class Phalcon\Db\Adapter\Pdo
- Class Phalcon\Db\Adapter\Pdo\Mysql
- Class Phalcon\Db\Adapter\Pdo\Oracle
- Class Phalcon\Db\Adapter\Pdo\Postgresql
- Class Phalcon\Db\Adapter\Pdo\Sqlite
- Interface Phalcon\Db\AdapterInterface
- Class Phalcon\Db\Column
- Interface Phalcon\Db\ColumnInterface
- Abstract class Phalcon\Db\Dialect
- Class Phalcon\Db\Dialect\Oracle
- Class Phalcon\Db\Dialect\Postgresql
- Class Phalcon\Db\Dialect\Sqlite
- Interface Phalcon\Db\DialectInterface
- Class Phalcon\Db\Exception
- Class Phalcon\Db\Index
- Interface Phalcon\Db\IndexInterface
- Class Phalcon\Db\Profiler
- Class Phalcon\Db\Profiler\Item
- Class Phalcon\Db\RawValue
- Class Phalcon\Db\Reference
- Interface Phalcon\Db\ReferenceInterface
- Class Phalcon\Db\Result\Pdo
- Interface Phalcon\Db\ResultInterface
- Class Phalcon\Debug
- Class Phalcon\Debug\Dump
- Class Phalcon\Debug\Exception
- Interface Phalcon\DiInterface
- Abstract class Phalcon\Dispatcher
- Interface Phalcon\DispatcherInterface
- Class Phalcon\Escaper
- Class Phalcon\Escaper\Exception
- Interface Phalcon\EscaperInterface
- Class Phalcon\Events\Event
- Interface Phalcon\Events\EventsAwareInterface
- Class Phalcon\Events\Exception
- Class Phalcon\Events\Manager
- Interface Phalcon\Events\ManagerInterface
- Class Phalcon\Exception
- Class Phalcon\Filter
- Class Phalcon\Filter\Exception
- Interface Phalcon\Filter\UserFilterInterface
- Interface Phalcon\FilterInterface
- Abstract class Phalcon\Flash
- Class Phalcon\Flash\Direct
- Class Phalcon\Flash\Exception
- Class Phalcon\Flash\Session
- Interface Phalcon\FlashInterface
- Class Phalcon\Forms\Form
- Abstract class Phalcon\Forms\Element
- Class Phalcon\Forms\Element\Check
- Class Phalcon\Forms\Element\Email
- Class Phalcon\Forms\Element\File
- Class Phalcon\Forms\Element\Date
- Class Phalcon\Forms\Element\Hidden
- Class Phalcon\Forms\Element\Numeric
- Class Phalcon\Forms\Element\Password
- Class Phalcon\Forms\Element\Radio
- Class Phalcon\Forms\Element\Select
- Class Phalcon\Forms\Element\Submit
- Class Phalcon\Forms\Element\Text
- Class Phalcon\Forms\Element\TextArea
- Interface Phalcon\Forms\ElementInterface
- Class Phalcon\Forms\Exception
- Class Phalcon\Forms\Manager
- Class Phalcon\Http\Cookie
- Class Phalcon\Http\Cookie\Exception
- Class Phalcon\Http\Request
- Class Phalcon\Http\Request\Exception
- Class Phalcon\Http\Request\File
- Interface Phalcon\Http\Request\FileInterface
- Interface Phalcon\Http\RequestInterface
- Class Phalcon\Http\Response
- Class Phalcon\Http\Response\Cookies
- Interface Phalcon\Http\Response\CookiesInterface
- Class Phalcon\Http\Response\Exception
- Class Phalcon\Http\Response\Headers
- Interface Phalcon\Http\Response\HeadersInterface
- Interface Phalcon\Http\ResponseInterface
- Class Phalcon\Image
- Abstract class Phalcon\Image\Adapter
- Class Phalcon\Image\Adapter\Imagick
- Interface Phalcon\Image\AdapterInterface
- Class Phalcon\Image\Exception
- Class Phalcon\Kernel
- Class Phalcon\Loader
- Class Phalcon\Loader\Exception
- Abstract class Phalcon\Logger
- Abstract class Phalcon\Logger\Adapter
- Class Phalcon\Logger\Adapter\File
- Class Phalcon\Logger\Adapter\Firephp
- Class Phalcon\Logger\Adapter\Stream
- Class Phalcon\Logger\Adapter\Syslog
- Interface Phalcon\Logger\AdapterInterface
- Class Phalcon\Logger\Exception
- Abstract class Phalcon\Logger\Formatter
- Class Phalcon\Logger\Formatter\Firephp
- Class Phalcon\Logger\Formatter\Json
- Class Phalcon\Logger\Formatter\Line
- Class Phalcon\Logger\Formatter\Syslog
- Interface Phalcon\Logger\FormatterInterface
- Class Phalcon\Logger\Item
- Class Phalcon\Logger\Multiple
- Class Phalcon\Mvc\Application
- Class Phalcon\Mvc\Application\Exception
- Abstract class Phalcon\Mvc\Collection
- Abstract class Phalcon\Mvc\Collection\Behavior
- Class Phalcon\Mvc\Collection\Behavior\SoftDelete
- Class Phalcon\Mvc\Collection\Behavior\Timestampable
- Interface Phalcon\Mvc\Collection\BehaviorInterface
- Class Phalcon\Mvc\Collection\Document
- Class Phalcon\Mvc\Collection\Exception
- Class Phalcon\Mvc\Collection\Manager
- Interface Phalcon\Mvc\Collection\ManagerInterface
- Interface Phalcon\Mvc\CollectionInterface
- Abstract class Phalcon\Mvc\Controller
- Interface Phalcon\Mvc\ControllerInterface
- Class Phalcon\Mvc\Dispatcher
- Class Phalcon\Mvc\Dispatcher\Exception
- Interface Phalcon\Mvc\DispatcherInterface
- Interface Phalcon\Mvc\EntityInterface
- Class Phalcon\Mvc\Micro
- Class Phalcon\Mvc\Micro\Collection
- Interface Phalcon\Mvc\Micro\CollectionInterface
- Class Phalcon\Mvc\Micro\Exception
- Class Phalcon\Mvc\Micro\LazyLoader
- Interface Phalcon\Mvc\Micro\MiddlewareInterface
- Abstract class Phalcon\Mvc\Model
- Abstract class Phalcon\Mvc\Model\Behavior
- Class Phalcon\Mvc\Model\Behavior\SoftDelete
- Class Phalcon\Mvc\Model\Behavior\Timestampable
- Interface Phalcon\Mvc\Model\BehaviorInterface
- Class Phalcon\Mvc\Model\Criteria
- Interface Phalcon\Mvc\Model\CriteriaInterface
- Class Phalcon\Mvc\Model\Exception
- Class Phalcon\Mvc\Model\Manager
- Interface Phalcon\Mvc\Model\ManagerInterface
- Class Phalcon\Mvc\Model\Message
- Interface Phalcon\Mvc\Model\MessageInterface
- Abstract class Phalcon\Mvc\Model\MetaData
- Class Phalcon\Mvc\Model\MetaData\Apc
- Class Phalcon\Mvc\Model\MetaData\Files
- Class Phalcon\Mvc\Model\MetaData\Libmemcached
- Class Phalcon\Mvc\Model\MetaData\Memcache
- Class Phalcon\Mvc\Model\MetaData\Memory
- Class Phalcon\Mvc\Model\MetaData\Session
- Class Phalcon\Mvc\Model\MetaData\Strategy\Annotations
- Class Phalcon\Mvc\Model\MetaData\Strategy\Introspection
- Interface Phalcon\Mvc\Model\MetaData\StrategyInterface
- Class Phalcon\Mvc\Model\MetaData\Xcache
- Interface Phalcon\Mvc\Model\MetaDataInterface
- Class Phalcon\Mvc\Model\Query
- Class Phalcon\Mvc\Model\Query\Builder
- Interface Phalcon\Mvc\Model\Query\BuilderInterface
- Abstract class Phalcon\Mvc\Model\Query\Lang
- Class Phalcon\Mvc\Model\Query\Status
- Interface Phalcon\Mvc\Model\Query\StatusInterface
- Interface Phalcon\Mvc\Model\QueryInterface
- Class Phalcon\Mvc\Model\Relation
- Interface Phalcon\Mvc\Model\RelationInterface
- Interface Phalcon\Mvc\Model\ResultInterface
- Abstract class Phalcon\Mvc\Model\Resultset
- Class Phalcon\Mvc\Model\Resultset\Complex
- Class Phalcon\Mvc\Model\Resultset\Simple
- Abstract class Phalcon\Mvc\Model\Validator
- Class Phalcon\Mvc\Model\Validator\Email
- Class Phalcon\Mvc\Model\Validator\Exclusionin
- Class Phalcon\Mvc\Model\Validator\Inclusionin
- Class Phalcon\Mvc\Model\Validator\Ip
- Class Phalcon\Mvc\Model\Validator\Numericality
- Class Phalcon\Mvc\Model\Validator\PresenceOf
- Class Phalcon\Mvc\Model\Validator\Regex
- Class Phalcon\Mvc\Model\Validator\StringLength
- Class Phalcon\Mvc\Model\Validator\Uniqueness
- Class Phalcon\Mvc\Model\Validator\Url
- Interface Phalcon\Mvc\Model\ValidatorInterface
- Interface Phalcon\Mvc\Model\ResultsetInterface
- Class Phalcon\Mvc\Model\Row
- Class Phalcon\Mvc\Model\Transaction
- Class Phalcon\Mvc\Model\Transaction\Exception
- Class Phalcon\Mvc\Model\Transaction\Failed
- Class Phalcon\Mvc\Model\Transaction\Manager
- Interface Phalcon\Mvc\Model\Transaction\ManagerInterface
- Interface Phalcon\Mvc\Model\TransactionInterface
- Class Phalcon\Mvc\Model\ValidationFailed
- Interface Phalcon\Mvc\ModelInterface
- Interface Phalcon\Mvc\ModuleDefinitionInterface
- Class Phalcon\Mvc\Router
- Class Phalcon\Mvc\Router\Annotations
- Class Phalcon\Mvc\Router\Exception
- Class Phalcon\Mvc\Router\Group
- Interface Phalcon\Mvc\Router\GroupInterface
- Class Phalcon\Mvc\Router\Route
- Interface Phalcon\Mvc\Router\RouteInterface
- Interface Phalcon\Mvc\RouterInterface
- Class Phalcon\Mvc\Url
- Class Phalcon\Mvc\Url\Exception
- Interface Phalcon\Mvc\UrlInterface
- Class Phalcon\Mvc\User\Component
- Class Phalcon\Mvc\User\Module
- Class Phalcon\Mvc\User\Plugin
- Class Phalcon\Mvc\View
- Abstract class Phalcon\Mvc\View\Engine
- Class Phalcon\Mvc\View\Engine\Php
- Class Phalcon\Mvc\View\Engine\Volt
- Class Phalcon\Mvc\View\Engine\Volt\Compiler
- Interface Phalcon\Mvc\View\EngineInterface
- Class Phalcon\Mvc\View\Exception
- Class Phalcon\Mvc\View\Simple
- Interface Phalcon\Mvc\ViewBaseInterface
- Interface Phalcon\Mvc\ViewInterface
- Abstract class Phalcon\Paginator\Adapter
- Class Phalcon\Paginator\Adapter\Model
- Class Phalcon\Paginator\Adapter\NativeArray
- Class Phalcon\Paginator\Adapter\QueryBuilder
- Interface Phalcon\Paginator\AdapterInterface
- Class Phalcon\Paginator\Exception
- Class Phalcon\Queue\Beanstalk
- Class Phalcon\Queue\Beanstalk\Job
- Final class Phalcon\Registry
- Class Phalcon\Security
- Class Phalcon\Security\Exception
- Abstract class Phalcon\Session
- Abstract class Phalcon\Session\Adapter
- Class Phalcon\Session\Adapter\Files
- Class Phalcon\Session\Adapter\Libmemcached
- Class Phalcon\Session\Adapter\Memcache
- Interface Phalcon\Session\AdapterInterface
- Class Phalcon\Session\Bag
- Interface Phalcon\Session\BagInterface
- Class Phalcon\Session\Exception
- Class Phalcon\Tag
- Class Phalcon\Tag\Exception
- Abstract class Phalcon\Tag\Select
- Abstract class Phalcon\Text
- Abstract class Phalcon\Translate
- Abstract class Phalcon\Translate\Adapter
- Class Phalcon\Translate\Adapter\Csv
- Class Phalcon\Translate\Adapter\Gettext
- Class Phalcon\Translate\Adapter\NativeArray
- Interface Phalcon\Translate\AdapterInterface
- Class Phalcon\Translate\Exception
- Class Phalcon\Validation
- Class Phalcon\Validation\Exception
- Class Phalcon\Validation\Message
- Class Phalcon\Validation\Message\Group
- Interface Phalcon\Validation\MessageInterface
- Abstract class Phalcon\Validation\Validator
- Class Phalcon\Validation\Validator\Alnum
- Class Phalcon\Validation\Validator\Alpha
- Class Phalcon\Validation\Validator\Between
- Class Phalcon\Validation\Validator\Confirmation
- Class Phalcon\Validation\Validator\Digit
- Class Phalcon\Validation\Validator\Email
- Class Phalcon\Validation\Validator\ExclusionIn
- Class Phalcon\Validation\Validator\File
- Class Phalcon\Validation\Validator\Identical
- Class Phalcon\Validation\Validator\InclusionIn
- Class Phalcon\Validation\Validator\Numericality
- Class Phalcon\Validation\Validator\PresenceOf
- Class Phalcon\Validation\Validator\Regex
- Class Phalcon\Validation\Validator\StringLength
- Class Phalcon\Validation\Validator\Uniqueness
- Class Phalcon\Validation\Validator\Url
- Interface Phalcon\Validation\ValidatorInterface
- Class Phalcon\Version
- 参考手册
- 安装(Installation)
- 教程 1:让我们通过例子来学习(Tutorial 1: Let’s learn by example)
- 教程 2:Introducing INVO(Tutorial 2: Introducing INVO)
- 教程 3: Securing INVO
- 教程 4: Using CRUDs
- 教程 5: Customizing INVO
- 教程 6: Vkuró
- 教程 7:创建简单的 REST API(Tutorial 7: Creating a Simple REST API)
- 示例列表(List of examples)
- 依赖注入与服务定位器(Dependency Injection/Service Location)
- MVC 架构(The MVC Architecture)
- 使用控制器(Using Controllers)
- 使用模型(Working with Models)
- 模型元数据(Models Meta-Data)
- 事务管理(Model Transactions)
- Phalcon 查询语言(Phalcon Query Language (PHQL))
- 缓存对象关系映射(Caching in the ORM)
- 对象文档映射 ODM (Object-Document Mapper)
- 使用视图(Using Views)
- 视图助手(View Helpers)
- 资源文件管理(Assets Management)
- Volt 模版引擎(Volt: Template Engine)
- MVC 应用(MVC Applications)
- 路由(Routing)
- 调度控制器(Dispatching Controllers)
- 微应用(Micro Applications)
- 使用命名空间(Working with Namespaces)
- 事件管理器(Events Manager)
- Request Environment
- 返回响应(Returning Responses)
- Cookie 管理(Cookies Management)
- 生成 URL 和 路径(Generating URLs and Paths)
- 闪存消息(Flashing Messages)
- 使用 Session 存储数据(Storing data in Session)
- 过滤与清理(Filtering and Sanitizing)
- 上下文编码(Contextual Escaping)
- 验证(Validation)
- 表单(Forms)
- 读取配置(Reading Configurations)
- 分页(Pagination)
- 使用缓存提高性能(Improving Performance with Cache)
- 安全(Security)
- Encryption/Decryption
- 访问控制列表 ACL(Access Control Lists ACL)
- 多语言支持(Multi-lingual Support)
- Universal Class Loader
- 日志记录(Logging)
- 注释解析器(Annotations Parser)
- 命令行应用(Command Line Applications)
- 队列(Queueing)
- 数据库抽象层(Database Abstraction Layer)
- 国际化(Internationalization)
- 数据库迁移(Database Migrations)
- 调试应用程序(Debugging Applications)
- Phalcon 开发工具(Phalcon Developer Tools)
- 提高性能:下一步该做什么?(Increasing Performance: What’s next?)
- 单元测试(Unit testing)
- 授权(License)