# 对象文档映射 ODM (Object-Document Mapper)
# 对象文档映射 ODM (Object-Document Mapper)
除了可以 [*映射关系数据库的表*](#) 之外,Phalcon还可以使用NoSQL数据库如MongoDB等。Phalcon中的ODM具有可以非常容易的实现如下功能:CRUD,事件,验证等。
因为NoSQL数据库中无sql查询及计划等操作故可以提高数据操作的性能。再者,由于无SQL语句创建的操作故可以减少SQL注入的危险。
当前Phalcon中支持的NosSQL数据库如下:
名称描述[MongoDB](http://www.mongodb.org/)MongoDB是一个稳定的高性能的开源的NoSQL数据### 创建模型(Creating Models)
NoSQL中的模型类扩展自 [*Phalcon\\Mvc\\Collection*](#).模型必须要放入模型文件夹中而且每个模型文件必须只能有一个模型类;模型类名应该为小驼峰法书写:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
class Robots extends Collection
{
}
```
```
> > 如果PHP版本为5.4/5.5或更高版本,为了提高性能节省内存开销,最好在模型类文件中定义每个字段。
> 模型Robots默认和数据库中的robots表格映射。如果想使用别的名字映射数据库中的表格则只需要重写getSource()方法即可:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
class Robots extends Collection
{
public function getSource()
{
return "the_robots";
}
}
```
```
### 理解文档对象(Understanding Documents To Objects)
每个模型的实例和数据库表中的一个文档(记录)相对应。我们可以非常容易的通过读取对象属性来访问表格的数据。例如访问robots表格:
```
<pre class="calibre14">```
$ mongo test
MongoDB shell version: 1.8.2
connecting to: test
> db.robots.find()
{ "_id" : ObjectId("508735512d42b8c3d15ec4e1"), "name" : "Astro Boy", "year" : 1952,
"type" : "mechanical" }
{ "_id" : ObjectId("5087358f2d42b8c3d15ec4e2"), "name" : "Bender", "year" : 1999,
"type" : "mechanical" }
{ "_id" : ObjectId("508735d32d42b8c3d15ec4e3"), "name" : "Wall-E", "year" : 2008 }
>
```
```
### 模型中使用命名空间(Models in Namespaces)
我们在这里可以使用命名空间来避免类名冲突。这个例子中我们使用getSource方法来标明要使用的数据库表:
```
<pre class="calibre14">```
<?php
namespace Store\Toys;
use Phalcon\Mvc\Collection;
class Robots extends Collection
{
public function getSource()
{
return "robots";
}
}
```
```
我们可以通过对象的ID查找到对象然后打印出其名字:
```
<pre class="calibre14">```
<?php
// Find record with _id = "5087358f2d42b8c3d15ec4e2"
$robot = Robots::findById("5087358f2d42b8c3d15ec4e2");
// Prints "Bender"
echo $robot->name;
```
```
一旦记录被加载到内存中,我们就可以对这些数据进行修改了,修改之后还可以保存:
```
<pre class="calibre14">```
<?php
$robot = Robots::findFirst(
array(
array(
'name' => 'Astro Boy'
)
)
);
$robot->name = "Voltron";
$robot->save();
```
```
### 设置连接(Setting a Connection)
这里的MongoDB服务是从服务容器中取得的。默认,Phalcon会使mongo作服务名:
```
<pre class="calibre14">```
<?php
// Simple database connection to localhost
$di->set('mongo', function () {
$mongo = new MongoClient();
return $mongo->selectDB("store");
}, true);
// Connecting to a domain socket, falling back to localhost connection
$di->set('mongo', function () {
$mongo = new MongoClient("mongodb:///tmp/mongodb-27017.sock,localhost:27017");
return $mongo->selectDB("store");
}, true);
```
```
### 查找文档(Finding Documents)
`Phalcon\Mvc\Collection`
```
<pre class="calibre14">```
<?php
// How many robots are there?
$robots = Robots::find();
echo "There are ", count($robots), "\n";
// How many mechanical robots are there?
$robots = Robots::find(
array(
array(
"type" => "mechanical"
)
)
);
echo "There are ", count($robots), "\n";
// Get and print mechanical robots ordered by name upward
$robots = Robots::find(
array(
array(
"type" => "mechanical"
),
"sort" => array(
"name" => 1
)
)
);
foreach ($robots as $robot) {
echo $robot->name, "\n";
}
// Get first 100 mechanical robots ordered by name
$robots = Robots::find(
array(
array(
"type" => "mechanical"
),
"sort" => array(
"name" => 1
),
"limit" => 100
)
);
foreach ($robots as $robot) {
echo $robot->name, "\n";
}
```
```
这里我们可以使用findFirst()来取得配置查询的第一条记录:
```
<pre class="calibre14">```
<?php
// What's the first robot in robots collection?
$robot = Robots::findFirst();
echo "The robot name is ", $robot->name, "\n";
// What's the first mechanical robot in robots collection?
$robot = Robots::findFirst(
array(
array(
"type" => "mechanical"
)
)
);
echo "The first mechanical robot name is ", $robot->name, "\n";
```
```
find()和findFirst方法都接收一个关联数据组为查询的条件:
```
<pre class="calibre14">```
<?php
// First robot where type = "mechanical" and year = "1999"
$robot = Robots::findFirst(
array(
"conditions" => array(
"type" => "mechanical",
"year" => "1999"
)
)
);
// All virtual robots ordered by name downward
$robots = Robots::find(
array(
"conditions" => array("type" => "virtual"),
"sort" => array("name" => -1)
)
);
```
```
可用的查询选项:
参数描述例子条件搜索条件,用于取只满足要求的数,默认情况下Phalcon\_model会假定关联数据的第一个参数为查询条“conditions” => array(‘$gt' => 1990)字段若指定则返回指定的字段而非全部字,当设置此字段时会返回非完全版本的对“fields” => array(‘name' => true)排这个选项用来对查询结果进行排序,使用一个为多个字段作为排序的标准,使用数组来表格,1代表升序,-1代表降“order” => array(“name” => -1, “status” => 1)限制限制查询结果集到指定的范围“limit” => 10间隔跳过指定的条目选取结果“skip” => 50如果你有使用sql(关系)数据库的经验,你也许想查看二者的映射表格 [SQL to Mongo Mapping Chart](http://www.php.net/manual/en/mongo.sqltomongo.php) .
### 聚合(Aggregations)
我们可以使用Mongo提供的方法使用Mongo模型返回聚合结果。聚合结果不是使用MapReduce来计算的。基于此,我们可以非常容易的取得聚合值,比如总计或平均值等:
```
<pre class="calibre14">```
<?php
$data = Article::aggregate(
array(
array(
'$project' => array('category' => 1)
),
array(
'$group' => array(
'_id' => array('category' => '$category'),
'id' => array('$max' => '$_id')
)
)
)
);
```
```
### 创建和更新记录(Creating Updating/Records)
Phalcon\\Mvc\\Collection::save()方法可以用来保存数据,Phalcon会根据当前数据库中的数据来对比以确定是新加一条数据还是更新数据。在Phalcon内部会直接使用[*Phalcon\\Mvc\\Collection*](#) 的save或update方法来进行操作。
当然这个方法内部也会调用我们在模型中定义的验证方法或事件等:
```
<pre class="calibre14">```
<?php
$robot = new Robots();
$robot->type = "mechanical";
$robot->name = "Astro Boy";
$robot->year = 1952;
if ($robot->save() == false) {
echo "Umh, We can't store robots right now: \n";
foreach ($robot->getMessages() as $message) {
echo $message, "\n";
}
} else {
echo "Great, a new robot was saved successfully!";
}
```
```
“\_id”属性会被Mongo驱动自动的随MongId\_而更新。
```
<pre class="calibre14">```
<?php
$robot->save();
echo "The generated id is: ", $robot->getId();
```
```
### 验证信息(Validation Messages)
[*Phalcon\\Mvc\\Collection*](#) 提供了一个信息子系统,使用此系统开发者可以非常容易的实现在数据处理中的验证信息的显示及保存。
每条信息即是一个 [*Phalcon\\Mvc\\Model\\Message*](#) 类的对象实例。我们使用getMessages来取得此信息。每条信息中包含了如哪个字段产生的消息,或是消息类型等信息:
```
<pre class="calibre14">```
<?php
if ($robot->save() == false) {
foreach ($robot->getMessages() as $message) {
echo "Message: ", $message->getMessage();
echo "Field: ", $message->getField();
echo "Type: ", $message->getType();
}
}
```
```
### 验证事件和事件管理(Validation Events and Events Manager)
在模型类的数据操作过程中可以产生一些事件。我们可以在这些事件中定义一些业务规则。下面是 [*Phalcon\\Mvc\\Collection*](#) 所支持的事件及其执行顺序:
操作名称能否停止操作解释Inserting/UpdatingbeforeValidationYES在验证和最终插入/更新进行之执行InsertingbeforeValidationOnCreateYES仅当创建新条目验证之前执行UpdatingbeforeValidationOnUpdateYES仅在更新条目验证之前Inserting/UpdatingonValidationFailsYES (already stopped)验证执行失败后执行InsertingafterValidationOnCreateYES新建条目验证之后执行UpdatingafterValidationOnUpdateYES更新条目后执行Inserting/UpdatingafterValidationYES在验证进行之前执Inserting/UpdatingbeforeSaveYES在请示的操作(保存)运行之前UpdatingbeforeUpdateYES更新操作执行之前运行InsertingbeforeCreateYES创建操作执行之前运行UpdatingafterUpdateNO更新执行之后执行InsertingafterCreateNO创建执行之后Inserting/UpdatingafterSaveNO保存执行之后为了响应一个事件,我们需在模型中实现同名方法:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
class Robots extends Collection
{
public function beforeValidationOnCreate()
{
echo "This is executed before creating a Robot!";
}
}
```
```
在执行操作之前先在指定的事件中设置值有时是非常有用的:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
class Products extends Collection
{
public function beforeCreate()
{
// Set the creation date
$this->created_at = date('Y-m-d H:i:s');
}
public function beforeUpdate()
{
// Set the modification date
$this->modified_in = date('Y-m-d H:i:s');
}
}
```
```
另外,这个组件也可以和 [*Phalcon\\Events\\Manager*](#) 进行集成,这就意味着我们在事件触发创建监听器。
```
<pre class="calibre14">```
<?php
use Phalcon\Events\Manager as EventsManager;
$eventsManager = new EventsManager();
// Attach an anonymous function as a listener for "model" events
$eventsManager->attach('collection', function ($event, $robot) {
if ($event->getType() == 'beforeSave') {
if ($robot->name == 'Scooby Doo') {
echo "Scooby Doo isn't a robot!";
return false;
}
}
return true;
});
$robot = new Robots();
$robot->setEventsManager($eventsManager);
$robot->name = 'Scooby Doo';
$robot->year = 1969;
$robot->save();
```
```
上面的例子中EventsManager仅在对象和监听器(匿名函数)之间扮演了一个桥接器的角色。如果我们想在创建应用时使用同一个EventsManager,我们需要把这个EventsManager对象设置到 collectionManager服务中:
```
<pre class="calibre14">```
<?php
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Mvc\Collection\Manager as CollectionManager;
// Registering the collectionManager service
$di->set('collectionManager', function () {
$eventsManager = new EventsManager();
// Attach an anonymous function as a listener for "model" events
$eventsManager->attach('collection', function ($event, $model) {
if (get_class($model) == 'Robots') {
if ($event->getType() == 'beforeSave') {
if ($model->name == 'Scooby Doo') {
echo "Scooby Doo isn't a robot!";
return false;
}
}
}
return true;
});
// Setting a default EventsManager
$modelsManager = new CollectionManager();
$modelsManager->setEventsManager($eventsManager);
return $modelsManager;
}, true);
```
```
### 实现业务规则(Implementing a Business Rule)
当插入或更新删除等执行时,模型会检查上面表格中列出的方法是否存在。
我们建议定义模型里的验证方法以避免业务逻辑暴露出来。
下面的例子中实现了在保存或更新时对年份的验证,年份不能小于0年:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
class Robots extends Collection
{
public function beforeSave()
{
if ($this->year < 0) {
echo "Year cannot be smaller than zero!";
return false;
}
}
}
```
```
在响应某些事件时返回了false则会停止当前的操作。 如果事实响应未返回任何值, [*Phalcon\\Mvc\\Collection*](#) 会假定返回了true值。
### 验证数据完整性(Validating Data Integrity)
[*Phalcon\\Mvc\\Collection*](#) 提供了若干个事件用于验证数据和实现业务逻辑。特定的事件中我们可以调用内建的验证器Phalcon提供了一些验证器可以用在此阶段的验证上。
下面的例子中展示了如何使用:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
use Phalcon\Mvc\Model\Validator\InclusionIn;
use Phalcon\Mvc\Model\Validator\Numericality;
class Robots extends Collection
{
public function validation()
{
$this->validate(
new InclusionIn(
array(
"field" => "type",
"message" => "Type must be: mechanical or virtual",
"domain" => array("Mechanical", "Virtual")
)
)
);
$this->validate(
new Numericality(
array(
"field" => "price",
"message" => "Price must be numeric"
)
)
);
return $this->validationHasFailed() != true;
}
}
```
```
上面的例子使用了内建的”InclusionIn”验证器。这个验证器检查了字段的类型是否在指定的范围内。如果值不在范围内即验证失败会返回false.下面支持的内验证器:
除了内建的验证器外,我们还可以创建自己的验证器:
```
<pre class="calibre14">```
<?php
use \Phalcon\Mvc\Model\Validator as CollectionValidator;
class UrlValidator extends CollectionValidator
{
public function validate($model)
{
$field = $this->getOption('field');
$value = $model->$field;
$filtered = filter_var($value, FILTER_VALIDATE_URL);
if (!$filtered) {
$this->appendMessage("The URL is invalid", $field, "UrlValidator");
return false;
}
return true;
}
}
```
```
添加验证器到模型:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
class Customers extends Collection
{
public function validation()
{
$this->validate(
new UrlValidator(
array(
"field" => "url",
)
)
);
if ($this->validationHasFailed() == true) {
return false;
}
}
}
```
```
创建验证器的目的即是使之在多个模型间重复利用以实现代码重用。验证器可简单如下:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
use Phalcon\Mvc\Model\Message as ModelMessage;
class Robots extends Collection
{
public function validation()
{
if ($this->type == "Old") {
$message = new ModelMessage(
"Sorry, old robots are not allowed anymore",
"type",
"MyType"
);
$this->appendMessage($message);
return false;
}
return true;
}
}
```
```
### 删除记录(Deleting Records)
Phalcon\\Mvc\\Collection::delete()方法用来删除记录条目。我们可以如下使用:
```
<pre class="calibre14">```
<?php
$robot = Robots::findFirst();
if ($robot != false) {
if ($robot->delete() == false) {
echo "Sorry, we can't delete the robot right now: \n";
foreach ($robot->getMessages() as $message) {
echo $message, "\n";
}
} else {
echo "The robot was deleted successfully!";
}
}
```
```
也可以使用遍历的方式删除多个条目的数据:
```
<pre class="calibre14">```
<?php
$robots = Robots::find(array(
array("type" => "mechanical")
));
foreach ($robots as $robot) {
if ($robot->delete() == false) {
echo "Sorry, we can't delete the robot right now: \n";
foreach ($robot->getMessages() as $message) {
echo $message, "\n";
}
} else {
echo "The robot was deleted successfully!";
}
}
```
```
当删除操作执行时我们可以执行如下事件,以实现定制业务逻辑的目的:
操作名称是否可停止解释删除beforeDelete是删除之前执行删除afterDelete否删除之后执行### 验证失败事件(Validation Failed Events)
验证失败时依据不同的情形下列事件会触发:
操作名称解释插入和或更新notSave当插入/更新操作失败时触插入删除或更新onValidationFails当数据操作失败时触发### 固有 Id 和 用户主键(Implicit Ids vs. User Primary Keys)
默认Phalcon\\Mvc\\Collection会使用MongoIds\_来产生\_id.如果用户想自定义主键也可以只需:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
class Robots extends Collection
{
public function initialize()
{
$this->useImplicitObjectIds(false);
}
}
```
```
### 设置多个数据库(Setting multiple databases)
Phalcon中,所有的模可以只属于一个数据库或是每个模型有一个数据。事实上当 [*Phalcon\\Mvc\\Collection*](#) 试图连接数据库时Phalcon会从DI中取名为mongo的服务。当然我们可在模型的initialize方法中进行连接设置:
```
<pre class="calibre14">```
<?php
// This service returns a mongo database at 192.168.1.100
$di->set('mongo1', function () {
$mongo = new MongoClient("mongodb://scott:nekhen@192.168.1.100");
return $mongo->selectDB("management");
}, true);
// This service returns a mongo database at localhost
$di->set('mongo2', function () {
$mongo = new MongoClient("mongodb://localhost");
return $mongo->selectDB("invoicing");
}, true);
```
```
然后在初始化方法,我们定义了模型的连接:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
class Robots extends Collection
{
public function initialize()
{
$this->setConnectionService('mongo1');
}
}
```
```
### 注入服务到模型(Injecting services into Models)
我们可能需要在模型内使用应用的服务,下面的例子中展示了如何去做:
```
<pre class="calibre14">```
<?php
use Phalcon\Mvc\Collection;
class Robots extends Collection
{
public function notSave()
{
// Obtain the flash service from the DI container
$flash = $this->getDI()->getShared('flash');
// Show validation messages
foreach ($this->getMessages() as $message) {
$flash->error((string) $message);
}
}
}
```
```
notSave事件在创建和更新失败时触发。我们使用flash服务来处理验证信息。如此做我们无需在每次保存后打印消息出来。
|
- [索引](# "总目录")
- [下一页](# "使用视图(Using Views)") |
- [上一页](# "缓存对象关系映射(Caching in the ORM)") |
- 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
- 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
- Interface Phalcon\Db\AdapterInterface
- Class Phalcon\Db\Column
- Interface Phalcon\Db\ColumnInterface
- Abstract class Phalcon\Db\Dialect
- Interface Phalcon\Db\DialectInterface
- Class Phalcon\Db\Exception
- Class Phalcon\Db\Index
- Interface Phalcon\Db\IndexInterface
- Class Phalcon\Db\Profiler
- 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\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
- 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\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
- Interface Phalcon\Mvc\Model\MetaDataInterface
- Class Phalcon\Mvc\Model\Query
- 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
- Abstract class Phalcon\Mvc\Model\Validator
- Interface Phalcon\Mvc\Model\ResultsetInterface
- Class Phalcon\Mvc\Model\Row
- Class Phalcon\Mvc\Model\Transaction
- 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
- 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
- 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)