# 對象文檔映射 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)