diff --git a/en/api/Phalcon_Acl_Adapter_Memory.rst b/en/api/Phalcon_Acl_Adapter_Memory.rst
index 008bc63dd390..087edf7c34fb 100644
--- a/en/api/Phalcon_Acl_Adapter_Memory.rst
+++ b/en/api/Phalcon_Acl_Adapter_Memory.rst
@@ -10,58 +10,68 @@ Class **Phalcon\\Acl\\Adapter\\Memory**
:raw-html:`Source on GitHub`
-Manages ACL lists in memory
+Manages ACL lists in memory
.. code-block:: php
setDefaultAction(Phalcon\Acl::DENY);
-
- //Register roles
- $roles = array(
- 'users' => new \Phalcon\Acl\Role('Users'),
- 'guests' => new \Phalcon\Acl\Role('Guests')
+
+ $acl->setDefaultAction(
+ \Phalcon\Acl::DENY
);
+
+ // Register roles
+ $roles = [
+ "users" => new \Phalcon\Acl\Role("Users"),
+ "guests" => new \Phalcon\Acl\Role("Guests"),
+ ];
foreach ($roles as $role) {
- $acl->addRole($role);
+ $acl->addRole($role);
}
-
- //Private area resources
- $privateResources = array(
- 'companies' => array('index', 'search', 'new', 'edit', 'save', 'create', 'delete'),
- 'products' => array('index', 'search', 'new', 'edit', 'save', 'create', 'delete'),
- 'invoices' => array('index', 'profile')
- );
- foreach ($privateResources as $resource => $actions) {
- $acl->addResource(new Phalcon\Acl\Resource($resource), $actions);
+
+ // Private area resources
+ $privateResources = [
+ "companies" => ["index", "search", "new", "edit", "save", "create", "delete"],
+ "products" => ["index", "search", "new", "edit", "save", "create", "delete"],
+ "invoices" => ["index", "profile"],
+ ];
+
+ foreach ($privateResources as $resourceName => $actions) {
+ $acl->addResource(
+ new \Phalcon\Acl\Resource($resourceName),
+ $actions
+ );
}
-
- //Public area resources
- $publicResources = array(
- 'index' => array('index'),
- 'about' => array('index'),
- 'session' => array('index', 'register', 'start', 'end'),
- 'contact' => array('index', 'send')
- );
- foreach ($publicResources as $resource => $actions) {
- $acl->addResource(new Phalcon\Acl\Resource($resource), $actions);
+
+ // Public area resources
+ $publicResources = [
+ "index" => ["index"],
+ "about" => ["index"],
+ "session" => ["index", "register", "start", "end"],
+ "contact" => ["index", "send"],
+ ];
+
+ foreach ($publicResources as $resourceName => $actions) {
+ $acl->addResource(
+ new \Phalcon\Acl\Resource($resourceName),
+ $actions
+ );
}
-
- //Grant access to public areas to both users and guests
+
+ // Grant access to public areas to both users and guests
foreach ($roles as $role){
- foreach ($publicResources as $resource => $actions) {
- $acl->allow($role->getName(), $resource, '*');
- }
+ foreach ($publicResources as $resource => $actions) {
+ $acl->allow($role->getName(), $resource, "*");
+ }
}
-
- //Grant access to private area to role Users
+
+ // Grant access to private area to role Users
foreach ($privateResources as $resource => $actions) {
- foreach ($actions as $action) {
- $acl->allow('Users', $resource, $action);
- }
+ foreach ($actions as $action) {
+ $acl->allow("Users", $resource, $action);
+ }
}
@@ -77,14 +87,19 @@ Phalcon\\Acl\\Adapter\\Memory constructor
public **addRole** (*RoleInterface* | *string* $role, [*array* | *string* $accessInherits])
-Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role Example:
+Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role
+Example:
.. code-block:: php
addRole(new Phalcon\Acl\Role('administrator'), 'consultant');
- $acl->addRole('administrator', 'consultant');
+ $acl->addRole(
+ new Phalcon\Acl\Role("administrator"),
+ "consultant"
+ );
+
+ $acl->addRole("administrator", "consultant");
@@ -109,19 +124,39 @@ Check whether resource exist in the resources list
public **addResource** (:doc:`Phalcon\\Acl\\Resource ` | *string* $resourceValue, *array* | *string* $accessList)
-Adds a resource to the ACL list Access names can be a particular action, by example search, update, delete, etc or a list of them Example:
+Adds a resource to the ACL list
+Access names can be a particular action, by example
+search, update, delete, etc or a list of them
+Example:
.. code-block:: php
addResource(new Phalcon\Acl\Resource('customers'), 'search');
- $acl->addResource('customers', 'search');
-
- //Add a resource with an access list
- $acl->addResource(new Phalcon\Acl\Resource('customers'), array('create', 'search'));
- $acl->addResource('customers', array('create', 'search'));
+ // Add a resource to the the list allowing access to an action
+ $acl->addResource(
+ new Phalcon\Acl\Resource("customers"),
+ "search"
+ );
+
+ $acl->addResource("customers", "search");
+
+ // Add a resource with an access list
+ $acl->addResource(
+ new Phalcon\Acl\Resource("customers"),
+ [
+ "create",
+ "search",
+ ]
+ );
+
+ $acl->addResource(
+ "customers",
+ [
+ "create",
+ "search",
+ ]
+ );
@@ -146,76 +181,83 @@ Checks if a role has access to a resource
public **allow** (*mixed* $roleName, *mixed* $resourceName, *mixed* $access, [*mixed* $func])
-Allow access to a role on a resource You can use '*' as wildcard Example:
+Allow access to a role on a resource
+You can use '*' as wildcard
+Example:
.. code-block:: php
allow('guests', 'customers', 'search');
-
- //Allow access to guests to search or create on customers
- $acl->allow('guests', 'customers', array('search', 'create'));
-
- //Allow access to any role to browse on products
- $acl->allow('*', 'products', 'browse');
-
- //Allow access to any role to browse on any resource
- $acl->allow('*', '*', 'browse');
+ //Allow access to guests to search on customers
+ $acl->allow("guests", "customers", "search");
+
+ //Allow access to guests to search or create on customers
+ $acl->allow("guests", "customers", ["search", "create"]);
+
+ //Allow access to any role to browse on products
+ $acl->allow("*", "products", "browse");
+
+ //Allow access to any role to browse on any resource
+ $acl->allow("*", "*", "browse");
public **deny** (*mixed* $roleName, *mixed* $resourceName, *mixed* $access, [*mixed* $func])
-Deny access to a role on a resource You can use '*' as wildcard Example:
+Deny access to a role on a resource
+You can use '*' as wildcard
+Example:
.. code-block:: php
deny('guests', 'customers', 'search');
-
- //Deny access to guests to search or create on customers
- $acl->deny('guests', 'customers', array('search', 'create'));
-
- //Deny access to any role to browse on products
- $acl->deny('*', 'products', 'browse');
-
- //Deny access to any role to browse on any resource
- $acl->deny('*', '*', 'browse');
+ //Deny access to guests to search on customers
+ $acl->deny("guests", "customers", "search");
+
+ //Deny access to guests to search or create on customers
+ $acl->deny("guests", "customers", ["search", "create"]);
+
+ //Deny access to any role to browse on products
+ $acl->deny("*", "products", "browse");
+ //Deny access to any role to browse on any resource
+ $acl->deny("*", "*", "browse");
-public **isAllowed** (*mixed* $roleName, *mixed* $resourceName, *mixed* $access, [*array* $parameters])
-Check whether a role is allowed to access an action from a resource
+public **isAllowed** (*RoleInterface* | *RoleAware* | *string* $roleName, *ResourceInterface* | *ResourceAware* | *string* $resourceName, *mixed* $access, [*array* $parameters])
+
+Check whether a role is allowed to access an action from a resource
.. code-block:: php
isAllowed('andres', 'Products', 'create');
-
- //Do guests have access to any resource to edit?
- $acl->isAllowed('guests', '*', 'edit');
+ //Does andres have access to the customers resource to create?
+ $acl->isAllowed("andres", "Products", "create");
+
+ //Do guests have access to any resource to edit?
+ $acl->isAllowed("guests", "*", "edit");
public **setNoArgumentsDefaultAction** (*mixed* $defaultAccess)
-Sets the default access level (Phalcon\\Acl::ALLOW or Phalcon\\Acl::DENY) for no arguments provided in isAllowed action if there exists func for accessKey
+Sets the default access level (Phalcon\\Acl::ALLOW or Phalcon\\Acl::DENY)
+for no arguments provided in isAllowed action if there exists func for
+accessKey
public **getNoArgumentsDefaultAction** ()
-Returns the default ACL access level for no arguments provided in isAllowed action if there exists func for accessKey
+Returns the default ACL access level for no arguments provided in
+isAllowed action if there exists func for accessKey
diff --git a/en/api/Phalcon_Annotations_Adapter_Apc.rst b/en/api/Phalcon_Annotations_Adapter_Apc.rst
index 9c8c0a2c39a1..27291733b1f7 100644
--- a/en/api/Phalcon_Annotations_Adapter_Apc.rst
+++ b/en/api/Phalcon_Annotations_Adapter_Apc.rst
@@ -10,13 +10,15 @@ Class **Phalcon\\Annotations\\Adapter\\Apc**
:raw-html:`Source on GitHub`
-Stores the parsed annotations in APC. This adapter is suitable for production
+Stores the parsed annotations in APC. This adapter is suitable for production
.. code-block:: php
` **read** (*string* $key)
+public **read** (*mixed* $key)
Reads parsed annotations from APC
diff --git a/en/api/Phalcon_Annotations_Adapter_Files.rst b/en/api/Phalcon_Annotations_Adapter_Files.rst
index c6adf750bdae..2701ffaefd0a 100644
--- a/en/api/Phalcon_Annotations_Adapter_Files.rst
+++ b/en/api/Phalcon_Annotations_Adapter_Files.rst
@@ -10,15 +10,19 @@ Class **Phalcon\\Annotations\\Adapter\\Files**
:raw-html:`Source on GitHub`
-Stores the parsed annotations in files. This adapter is suitable for production
+Stores the parsed annotations in files. This adapter is suitable for production
.. code-block:: php
'app/cache/annotations/']);
+ use Phalcon\Annotations\Adapter\Files;
+
+ $annotations = new Files(
+ [
+ "annotationsDir" => "app/cache/annotations/",
+ ]
+ );
diff --git a/en/api/Phalcon_Annotations_Adapter_Memory.rst b/en/api/Phalcon_Annotations_Adapter_Memory.rst
index aa087bbd922b..ca1a318a21d2 100644
--- a/en/api/Phalcon_Annotations_Adapter_Memory.rst
+++ b/en/api/Phalcon_Annotations_Adapter_Memory.rst
@@ -16,7 +16,7 @@ Stores the parsed annotations in memory. This adapter is the suitable developmen
Methods
-------
-public :doc:`Phalcon\\Annotations\\Reflection ` **read** (*string* $key)
+public **read** (*mixed* $key)
Reads parsed annotations from memory
diff --git a/en/api/Phalcon_Annotations_Adapter_Xcache.rst b/en/api/Phalcon_Annotations_Adapter_Xcache.rst
index 64b9277cc09f..58c5fceb5410 100644
--- a/en/api/Phalcon_Annotations_Adapter_Xcache.rst
+++ b/en/api/Phalcon_Annotations_Adapter_Xcache.rst
@@ -10,13 +10,13 @@ Class **Phalcon\\Annotations\\Adapter\\Xcache**
:raw-html:`Source on GitHub`
-Stores the parsed annotations to XCache. This adapter is suitable for production
+Stores the parsed annotations to XCache. This adapter is suitable for production
.. code-block:: php
Source on GitHub`
-Represents a collection of annotations. This class allows to traverse a group of annotations easily
+Represents a collection of annotations. This class allows to traverse a group of annotations easily
.. code-block:: php
getName(), PHP_EOL;
- }
-
- //Check if the annotations has a specific
- var_dump($classAnnotations->has('Cacheable'));
-
- //Get an specific annotation in the collection
- $annotation = $classAnnotations->get('Cacheable');
+ //Traverse annotations
+ foreach ($classAnnotations as $annotation) {
+ echo "Name=", $annotation->getName(), PHP_EOL;
+ }
+
+ //Check if the annotations has a specific
+ var_dump($classAnnotations->has("Cacheable"));
+
+ //Get an specific annotation in the collection
+ $annotation = $classAnnotations->get("Cacheable");
diff --git a/en/api/Phalcon_Annotations_Reflection.rst b/en/api/Phalcon_Annotations_Reflection.rst
index 03dbf90e640e..f32fefd40212 100644
--- a/en/api/Phalcon_Annotations_Reflection.rst
+++ b/en/api/Phalcon_Annotations_Reflection.rst
@@ -6,24 +6,24 @@ Class **Phalcon\\Annotations\\Reflection**
:raw-html:`Source on GitHub`
-Allows to manipulate the annotations reflection in an OO manner
+Allows to manipulate the annotations reflection in an OO manner
.. code-block:: php
parse('MyComponent');
-
- // Create the reflection
- $reflection = new Reflection($parsing);
-
- // Get the annotations in the class docblock
- $classAnnotations = reflection->getClassAnnotations();
+ use Phalcon\Annotations\Reader;
+ use Phalcon\Annotations\Reflection;
+
+ // Parse the annotations in a class
+ $reader = new Reader();
+ $parsing = $reader->parse("MyComponent");
+
+ // Create the reflection
+ $reflection = new Reflection($parsing);
+
+ // Get the annotations in the class docblock
+ $classAnnotations = $reflection->getClassAnnotations();
diff --git a/en/api/Phalcon_Application.rst b/en/api/Phalcon_Application.rst
index 393a863acf57..958c35e5da07 100644
--- a/en/api/Phalcon_Application.rst
+++ b/en/api/Phalcon_Application.rst
@@ -36,24 +36,24 @@ Returns the internal event manager
public **registerModules** (*array* $modules, [*mixed* $merge])
-Register an array of modules present in the application
+Register an array of modules present in the application
.. code-block:: php
registerModules(
- [
- 'frontend' => [
- 'className' => 'Multiple\Frontend\Module',
- 'path' => '../apps/frontend/Module.php'
- ],
- 'backend' => [
- 'className' => 'Multiple\Backend\Module',
- 'path' => '../apps/backend/Module.php'
- ]
- ]
- );
+ $this->registerModules(
+ [
+ "frontend" => [
+ "className" => "Multiple\\Frontend\\Module",
+ "path" => "../apps/frontend/Module.php",
+ ],
+ "backend" => [
+ "className" => "Multiple\\Backend\\Module",
+ "path" => "../apps/backend/Module.php",
+ ],
+ ]
+ );
diff --git a/en/api/Phalcon_Assets_Filters_Cssmin.rst b/en/api/Phalcon_Assets_Filters_Cssmin.rst
index b4dea9b86d3e..b75d40404f45 100644
--- a/en/api/Phalcon_Assets_Filters_Cssmin.rst
+++ b/en/api/Phalcon_Assets_Filters_Cssmin.rst
@@ -8,7 +8,9 @@ Class **Phalcon\\Assets\\Filters\\Cssmin**
:raw-html:`Source on GitHub`
-Minify the css - removes comments removes newlines and line feeds keeping removes last semicolon from last property
+Minify the css - removes comments
+removes newlines and line feeds keeping
+removes last semicolon from last property
Methods
diff --git a/en/api/Phalcon_Assets_Filters_Jsmin.rst b/en/api/Phalcon_Assets_Filters_Jsmin.rst
index 6f7bf658d130..2faeb8cbac8e 100644
--- a/en/api/Phalcon_Assets_Filters_Jsmin.rst
+++ b/en/api/Phalcon_Assets_Filters_Jsmin.rst
@@ -8,7 +8,9 @@ Class **Phalcon\\Assets\\Filters\\Jsmin**
:raw-html:`Source on GitHub`
-Deletes the characters which are insignificant to JavaScript. Comments will be removed. Tabs will be replaced with spaces. Carriage returns will be replaced with linefeeds. Most spaces and linefeeds will be removed.
+Deletes the characters which are insignificant to JavaScript. Comments will be removed. Tabs will be
+replaced with spaces. Carriage returns will be replaced with linefeeds.
+Most spaces and linefeeds will be removed.
Methods
diff --git a/en/api/Phalcon_Assets_Inline.rst b/en/api/Phalcon_Assets_Inline.rst
index aed05dcb985b..ae2e53a55812 100644
--- a/en/api/Phalcon_Assets_Inline.rst
+++ b/en/api/Phalcon_Assets_Inline.rst
@@ -6,13 +6,13 @@ Class **Phalcon\\Assets\\Inline**
:raw-html:`Source on GitHub`
-Represents an inline asset
+Represents an inline asset
.. code-block:: php
addCss('css/bootstrap.css');
- $assets->addCss('http://bootstrap.my-cdn.com/style.css', false);
+ $assets->addCss("css/bootstrap.css");
+ $assets->addCss("http://bootstrap.my-cdn.com/style.css", false);
@@ -58,14 +58,14 @@ Adds an inline Css to the 'css' collection
public **addJs** (*mixed* $path, [*mixed* $local], [*mixed* $filter], [*mixed* $attributes])
-Adds a javascript resource to the 'js' collection
+Adds a javascript resource to the 'js' collection
.. code-block:: php
addJs('scripts/jquery.js');
- $assets->addJs('http://jquery.my-cdn.com/jquery.js', false);
+ $assets->addJs("scripts/jquery.js");
+ $assets->addJs("http://jquery.my-cdn.com/jquery.js", false);
@@ -78,13 +78,15 @@ Adds an inline javascript to the 'js' collection
public **addResourceByType** (*mixed* $type, :doc:`Phalcon\\Assets\\Resource ` $resource)
-Adds a resource by its type
+Adds a resource by its type
.. code-block:: php
addResourceByType('css', new \Phalcon\Assets\Resource\Css('css/style.css'));
+ $assets->addResourceByType("css",
+ new \Phalcon\Assets\Resource\Css("css/style.css")
+ );
@@ -97,13 +99,15 @@ Adds an inline code by its type
public **addResource** (:doc:`Phalcon\\Assets\\Resource ` $resource)
-Adds a raw resource to the manager
+Adds a raw resource to the manager
.. code-block:: php
addResource(new Phalcon\Assets\Resource('css', 'css/style.css'));
+ $assets->addResource(
+ new Phalcon\Assets\Resource("css", "css/style.css")
+ );
@@ -116,26 +120,26 @@ Adds a raw inline code to the manager
public **set** (*mixed* $id, :doc:`Phalcon\\Assets\\Collection ` $collection)
-Sets a collection in the Assets Manager
+Sets a collection in the Assets Manager
.. code-block:: php
set('js', $collection);
+ $assets->set("js", $collection);
public **get** (*mixed* $id)
-Returns a collection by its id
+Returns a collection by its id
.. code-block:: php
get('js');
+ $scripts = $assets->get("js");
diff --git a/en/api/Phalcon_Assets_Resource.rst b/en/api/Phalcon_Assets_Resource.rst
index 77aeb8ed09d2..9ecfabd7490e 100644
--- a/en/api/Phalcon_Assets_Resource.rst
+++ b/en/api/Phalcon_Assets_Resource.rst
@@ -6,13 +6,13 @@ Class **Phalcon\\Assets\\Resource**
:raw-html:`Source on GitHub`
-Represents an asset resource
+Represents an asset resource
.. code-block:: php
`
-Returns the content of the resource as an string Optionally a base path where the resource is located can be set
+Returns the content of the resource as an string
+Optionally a base path where the resource is located can be set
diff --git a/en/api/Phalcon_Assets_Resource_Js.rst b/en/api/Phalcon_Assets_Resource_Js.rst
index dc1eaff96d8b..75a4665cd7b8 100644
--- a/en/api/Phalcon_Assets_Resource_Js.rst
+++ b/en/api/Phalcon_Assets_Resource_Js.rst
@@ -115,7 +115,8 @@ Sets the resource's target path
public **getContent** ([*mixed* $basePath]) inherited from :doc:`Phalcon\\Assets\\Resource `
-Returns the content of the resource as an string Optionally a base path where the resource is located can be set
+Returns the content of the resource as an string
+Optionally a base path where the resource is located can be set
diff --git a/en/api/Phalcon_Cache_Backend.rst b/en/api/Phalcon_Cache_Backend.rst
index c16f74551d07..1c088c1e1eac 100644
--- a/en/api/Phalcon_Cache_Backend.rst
+++ b/en/api/Phalcon_Cache_Backend.rst
@@ -1,6 +1,8 @@
Abstract class **Phalcon\\Cache\\Backend**
==========================================
+*implements* :doc:`Phalcon\\Cache\\BackendInterface `
+
.. role:: raw-html(raw)
:format: html
@@ -78,3 +80,28 @@ Gets the last lifetime set
+abstract public **get** (*mixed* $keyName, [*mixed* $lifetime]) inherited from :doc:`Phalcon\\Cache\\BackendInterface `
+
+...
+
+
+abstract public **save** ([*mixed* $keyName], [*mixed* $content], [*mixed* $lifetime], [*mixed* $stopBuffer]) inherited from :doc:`Phalcon\\Cache\\BackendInterface `
+
+...
+
+
+abstract public **delete** (*mixed* $keyName) inherited from :doc:`Phalcon\\Cache\\BackendInterface `
+
+...
+
+
+abstract public **queryKeys** ([*mixed* $prefix]) inherited from :doc:`Phalcon\\Cache\\BackendInterface `
+
+...
+
+
+abstract public **exists** ([*mixed* $keyName], [*mixed* $lifetime]) inherited from :doc:`Phalcon\\Cache\\BackendInterface `
+
+...
+
+
diff --git a/en/api/Phalcon_Cache_Backend_Apc.rst b/en/api/Phalcon_Cache_Backend_Apc.rst
index b492046925e1..ecc7ac70f43e 100644
--- a/en/api/Phalcon_Cache_Backend_Apc.rst
+++ b/en/api/Phalcon_Cache_Backend_Apc.rst
@@ -10,29 +10,34 @@ Class **Phalcon\\Cache\\Backend\\Apc**
:raw-html:`Source on GitHub`
-Allows to cache output fragments, PHP data and raw data using an APC backend
+Allows to cache output fragments, PHP data and raw data using an APC backend
.. code-block:: php
172800
- ]);
-
- $cache = new Apc($frontCache, [
- 'prefix' => 'app-data'
- ]);
-
- // Cache arbitrary data
- $cache->save('my-data', [1, 2, 3, 4, 5]);
-
- // Get data
- $data = $cache->get('my-data');
+ use Phalcon\Cache\Backend\Apc;
+ use Phalcon\Cache\Frontend\Data as FrontData;
+
+ // Cache data for 2 days
+ $frontCache = new FrontData(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ $cache = new Apc(
+ $frontCache,
+ [
+ "prefix" => "app-data",
+ ]
+ );
+
+ // Cache arbitrary data
+ $cache->save("my-data", [1, 2, 3, 4, 5]);
+
+ // Get data
+ $data = $cache->get("my-data");
@@ -45,19 +50,19 @@ Returns a cached content
-public **save** ([*string* | *long* $keyName], [*string* $content], [*long* $lifetime], [*boolean* $stopBuffer])
+public **save** ([*string* | *int* $keyName], [*string* $content], [*int* $lifetime], [*boolean* $stopBuffer])
Stores cached content into the APC backend and stops the frontend
-public *mixed* **increment** ([*string* $keyName], [*long* $value])
+public **increment** ([*string* $keyName], [*mixed* $value])
Increment of a given key, by number $value
-public *mixed* **decrement** ([*string* $keyName], [*long* $value])
+public **decrement** ([*string* $keyName], [*mixed* $value])
Decrement of a given key, by number $value
@@ -69,13 +74,23 @@ Deletes a value from the cache by its key
-public *array* **queryKeys** ([*string* $prefix])
+public **queryKeys** ([*mixed* $prefix])
+
+Query the existing cached keys.
+
+.. code-block:: php
+
+ save("users-ids", [1, 2, 3]);
+ $cache->save("projects-ids", [4, 5, 6]);
+
+ var_dump($cache->queryKeys("users")); // ["users-ids"]
-Query the existing cached keys
-public *boolean* **exists** ([*string* | *long* $keyName], [*long* $lifetime])
+public **exists** ([*string* | *int* $keyName], [*int* $lifetime])
Checks if cache exists and it hasn't expired
@@ -85,6 +100,20 @@ public **flush** ()
Immediately invalidates all existing items.
+.. code-block:: php
+
+ "app-data"]);
+
+ $cache->save("my-data", [1, 2, 3, 4, 5]);
+
+ // 'my-data' and all other used keys are deleted
+ $cache->flush();
+
+
public **getFrontend** () inherited from :doc:`Phalcon\\Cache\\Backend `
diff --git a/en/api/Phalcon_Cache_Backend_File.rst b/en/api/Phalcon_Cache_Backend_File.rst
index 05e1204c62e1..80978ff63bdc 100644
--- a/en/api/Phalcon_Cache_Backend_File.rst
+++ b/en/api/Phalcon_Cache_Backend_File.rst
@@ -10,38 +10,40 @@ Class **Phalcon\\Cache\\Backend\\File**
:raw-html:`Source on GitHub`
-Allows to cache output fragments using a file backend
+Allows to cache output fragments using a file backend
.. code-block:: php
172800
- ];
-
- // Create an output cache
- $frontCache = FrontOutput($frontOptions);
-
- // Set the cache directory
- $backendOptions = [
- 'cacheDir' => '../app/cache/'
- ];
-
- // Create the File backend
- $cache = new File($frontCache, $backendOptions);
-
- $content = $cache->start('my-cache');
- if ($content === null) {
- echo '', time(), '
';
- $cache->save();
- } else {
- echo $content;
- }
+ use Phalcon\Cache\Backend\File;
+ use Phalcon\Cache\Frontend\Output as FrontOutput;
+
+ // Cache the file for 2 days
+ $frontendOptions = [
+ "lifetime" => 172800,
+ ];
+
+ // Create an output cache
+ $frontCache = FrontOutput($frontOptions);
+
+ // Set the cache directory
+ $backendOptions = [
+ "cacheDir" => "../app/cache/",
+ ];
+
+ // Create the File backend
+ $cache = new File($frontCache, $backendOptions);
+
+ $content = $cache->start("my-cache");
+
+ if ($content === null) {
+ echo "", time(), "
";
+
+ $cache->save();
+ } else {
+ echo $content;
+ }
@@ -66,31 +68,41 @@ Stores cached content into the file backend and stops the frontend
-public *boolean* **delete** (*int* | *string* $keyName)
+public **delete** (*int* | *string* $keyName)
Deletes a value from the cache by its key
-public *array* **queryKeys** ([*string* | *int* $prefix])
+public **queryKeys** ([*mixed* $prefix])
+
+Query the existing cached keys.
+
+.. code-block:: php
+
+ save("users-ids", [1, 2, 3]);
+ $cache->save("projects-ids", [4, 5, 6]);
+
+ var_dump($cache->queryKeys("users")); // ["users-ids"]
-Query the existing cached keys
-public *boolean* **exists** ([*string* | *int* $keyName], [*int* $lifetime])
+public **exists** ([*string* | *int* $keyName], [*int* $lifetime])
Checks if cache exists and it isn't expired
-public *mixed* **increment** ([*string* | *int* $keyName], [*int* $value])
+public **increment** ([*string* | *int* $keyName], [*mixed* $value])
Increment of a given key, by number $value
-public *mixed* **decrement** ([*string* | *int* $keyName], [*int* $value])
+public **decrement** ([*string* | *int* $keyName], [*mixed* $value])
Decrement of a given key, by number $value
diff --git a/en/api/Phalcon_Cache_Backend_Libmemcached.rst b/en/api/Phalcon_Cache_Backend_Libmemcached.rst
index 66979ec70c7d..be5e647aea01 100644
--- a/en/api/Phalcon_Cache_Backend_Libmemcached.rst
+++ b/en/api/Phalcon_Cache_Backend_Libmemcached.rst
@@ -10,40 +10,46 @@ Class **Phalcon\\Cache\\Backend\\Libmemcached**
:raw-html:`Source on GitHub`
-Allows to cache output fragments, PHP data or raw data to a libmemcached backend. Per default persistent memcached connection pools are used.
+Allows to cache output fragments, PHP data or raw data to a libmemcached backend.
+Per default persistent memcached connection pools are used.
.. code-block:: php
172800
- ]);
-
- // Create the Cache setting memcached connection options
- $cache = new Libmemcached($frontCache, [
- 'servers' => [
- [
- 'host' => 'localhost',
- 'port' => 11211,
- 'weight' => 1
- ],
- ],
- 'client' => [
- \Memcached::OPT_HASH => Memcached::HASH_MD5,
- \Memcached::OPT_PREFIX_KEY => 'prefix.',
- ]
- ]);
-
- // Cache arbitrary data
- $cache->save('my-data', [1, 2, 3, 4, 5]);
-
- // Get data
- $data = $cache->get('my-data');
+ use Phalcon\Cache\Backend\Libmemcached;
+ use Phalcon\Cache\Frontend\Data as FrontData;
+
+ // Cache data for 2 days
+ $frontCache = new FrontData(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ // Create the Cache setting memcached connection options
+ $cache = new Libmemcached(
+ $frontCache,
+ [
+ "servers" => [
+ [
+ "host" => "127.0.0.1",
+ "port" => 11211,
+ "weight" => 1,
+ ],
+ ],
+ "client" => [
+ \Memcached::OPT_HASH => \Memcached::HASH_MD5,
+ \Memcached::OPT_PREFIX_KEY => "prefix.",
+ ],
+ ]
+ );
+
+ // Cache arbitrary data
+ $cache->save("my-data", [1, 2, 3, 4, 5]);
+
+ // Get data
+ $data = $cache->get("my-data");
@@ -68,7 +74,7 @@ Returns a cached content
-public **save** ([*int* | *string* $keyName], [*string* $content], [*long* $lifetime], [*boolean* $stopBuffer])
+public **save** ([*int* | *string* $keyName], [*string* $content], [*int* $lifetime], [*boolean* $stopBuffer])
Stores cached content into the file backend and stops the frontend
@@ -80,25 +86,35 @@ Deletes a value from the cache by its key
-public *array* **queryKeys** ([*string* $prefix])
+public **queryKeys** ([*mixed* $prefix])
-Query the existing cached keys
+Query the existing cached keys.
+.. code-block:: php
+
+ save("users-ids", [1, 2, 3]);
+ $cache->save("projects-ids", [4, 5, 6]);
+
+ var_dump($cache->queryKeys("users")); // ["users-ids"]
-public *boolean* **exists** ([*string* $keyName], [*long* $lifetime])
+
+
+public **exists** ([*string* $keyName], [*int* $lifetime])
Checks if cache exists and it isn't expired
-public *long* **increment** ([*string* $keyName], [*mixed* $value])
+public **increment** ([*string* $keyName], [*mixed* $value])
Increment of given $keyName by $value
-public *long* **decrement** ([*string* $keyName], [*long* $value])
+public **decrement** ([*string* $keyName], [*mixed* $value])
Decrement of $keyName by given $value
@@ -106,17 +122,25 @@ Decrement of $keyName by given $value
public **flush** ()
-Immediately invalidates all existing items. Memcached does not support flush() per default. If you require flush() support, set $config["statsKey"]. All modified keys are stored in "statsKey". Note: statsKey has a negative performance impact.
+Immediately invalidates all existing items.
+Memcached does not support flush() per default. If you require flush() support, set $config["statsKey"].
+All modified keys are stored in "statsKey". Note: statsKey has a negative performance impact.
.. code-block:: php
"_PHCM"]);
- $cache->save('my-data', array(1, 2, 3, 4, 5));
-
- //'my-data' and all other used keys are deleted
- $cache->flush();
+ $cache = new \Phalcon\Cache\Backend\Libmemcached(
+ $frontCache,
+ [
+ "statsKey" => "_PHCM",
+ ]
+ );
+
+ $cache->save("my-data", [1, 2, 3, 4, 5]);
+
+ // 'my-data' and all other used keys are deleted
+ $cache->flush();
diff --git a/en/api/Phalcon_Cache_Backend_Memcache.rst b/en/api/Phalcon_Cache_Backend_Memcache.rst
index 7cf3a6b923e9..a3156dd1fbe6 100644
--- a/en/api/Phalcon_Cache_Backend_Memcache.rst
+++ b/en/api/Phalcon_Cache_Backend_Memcache.rst
@@ -10,32 +10,39 @@ Class **Phalcon\\Cache\\Backend\\Memcache**
:raw-html:`Source on GitHub`
-Allows to cache output fragments, PHP data or raw data to a memcache backend This adapter uses the special memcached key "_PHCM" to store all the keys internally used by the adapter
+Allows to cache output fragments, PHP data or raw data to a memcache backend
+
+This adapter uses the special memcached key "_PHCM" to store all the keys internally used by the adapter
.. code-block:: php
172800
- ]);
-
- // Create the Cache setting memcached connection options
- $cache = new Memcache($frontCache, [
- 'host' => 'localhost',
- 'port' => 11211,
- 'persistent' => false
- ]);
-
- // Cache arbitrary data
- $cache->save('my-data', [1, 2, 3, 4, 5]);
-
- // Get data
- $data = $cache->get('my-data');
+ use Phalcon\Cache\Backend\Memcache;
+ use Phalcon\Cache\Frontend\Data as FrontData;
+
+ // Cache data for 2 days
+ $frontCache = new FrontData(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ // Create the Cache setting memcached connection options
+ $cache = new Memcache(
+ $frontCache,
+ [
+ "host" => "localhost",
+ "port" => 11211,
+ "persistent" => false,
+ ]
+ );
+
+ // Cache arbitrary data
+ $cache->save("my-data", [1, 2, 3, 4, 5]);
+
+ // Get data
+ $data = $cache->get("my-data");
@@ -66,7 +73,7 @@ Returns a cached content
-public **save** ([*int* | *string* $keyName], [*string* $content], [*long* $lifetime], [*boolean* $stopBuffer])
+public **save** ([*int* | *string* $keyName], [*string* $content], [*int* $lifetime], [*boolean* $stopBuffer])
Stores cached content into the file backend and stops the frontend
@@ -78,25 +85,35 @@ Deletes a value from the cache by its key
-public *array* **queryKeys** ([*string* $prefix])
+public **queryKeys** ([*mixed* $prefix])
+
+Query the existing cached keys.
+
+.. code-block:: php
+
+ save("users-ids", [1, 2, 3]);
+ $cache->save("projects-ids", [4, 5, 6]);
+
+ var_dump($cache->queryKeys("users")); // ["users-ids"]
-Query the existing cached keys
-public *boolean* **exists** ([*string* $keyName], [*long* $lifetime])
+public **exists** ([*string* $keyName], [*int* $lifetime])
Checks if cache exists and it isn't expired
-public *long* **increment** ([*string* $keyName], [*long* $value])
+public **increment** ([*string* $keyName], [*mixed* $value])
Increment of given $keyName by $value
-public *long* **decrement** ([*string* $keyName], [*long* $value])
+public **decrement** ([*string* $keyName], [*mixed* $value])
Decrement of $keyName by given $value
diff --git a/en/api/Phalcon_Cache_Backend_Memory.rst b/en/api/Phalcon_Cache_Backend_Memory.rst
index eb31091db858..76d5ff06c6d0 100644
--- a/en/api/Phalcon_Cache_Backend_Memory.rst
+++ b/en/api/Phalcon_Cache_Backend_Memory.rst
@@ -10,25 +10,25 @@ Class **Phalcon\\Cache\\Backend\\Memory**
:raw-html:`Source on GitHub`
-Stores content in memory. Data is lost when the request is finished
+Stores content in memory. Data is lost when the request is finished
.. code-block:: php
save('my-data', [1, 2, 3, 4, 5]);
-
- // Get data
- $data = $cache->get('my-data');
+ use Phalcon\Cache\Backend\Memory;
+ use Phalcon\Cache\Frontend\Data as FrontData;
+
+ // Cache data
+ $frontCache = new FrontData();
+
+ $cache = new Memory($frontCache);
+
+ // Cache arbitrary data
+ $cache->save("my-data", [1, 2, 3, 4, 5]);
+
+ // Get data
+ $data = $cache->get("my-data");
@@ -41,7 +41,7 @@ Returns a cached content
-public **save** ([*string* $keyName], [*string* $content], [*long* $lifetime], [*boolean* $stopBuffer])
+public **save** ([*string* $keyName], [*string* $content], [*int* $lifetime], [*boolean* $stopBuffer])
Stores cached content into the backend and stops the frontend
@@ -53,25 +53,35 @@ Deletes a value from the cache by its key
-public *array* **queryKeys** ([*string* | *int* $prefix])
+public **queryKeys** ([*mixed* $prefix])
+
+Query the existing cached keys.
+
+.. code-block:: php
+
+ save("users-ids", [1, 2, 3]);
+ $cache->save("projects-ids", [4, 5, 6]);
+
+ var_dump($cache->queryKeys("users")); // ["users-ids"]
-Query the existing cached keys
-public *boolean* **exists** ([*string* | *int* $keyName], [*long* $lifetime])
+public **exists** ([*string* | *int* $keyName], [*int* $lifetime])
Checks if cache exists and it hasn't expired
-public *long* **increment** ([*string* $keyName], [*mixed* $value])
+public **increment** ([*string* $keyName], [*mixed* $value])
Increment of given $keyName by $value
-public *long* **decrement** ([*string* $keyName], [*long* $value])
+public **decrement** ([*string* $keyName], [*mixed* $value])
Decrement of $keyName by given $value
diff --git a/en/api/Phalcon_Cache_Backend_Mongo.rst b/en/api/Phalcon_Cache_Backend_Mongo.rst
index 5e1bdd262b0c..882e46bd9361 100644
--- a/en/api/Phalcon_Cache_Backend_Mongo.rst
+++ b/en/api/Phalcon_Cache_Backend_Mongo.rst
@@ -10,32 +10,40 @@ Class **Phalcon\\Cache\\Backend\\Mongo**
:raw-html:`Source on GitHub`
-Allows to cache output fragments, PHP data or raw data to a MongoDb backend
+Allows to cache output fragments, PHP data or raw data to a MongoDb backend
.. code-block:: php
172800
- ]);
-
- // Create a MongoDB cache
- $cache = new Mongo($frontCache, [
- 'server' => "mongodb://localhost",
- 'db' => 'caches',
- 'collection' => 'images'
- ]);
-
- // Cache arbitrary data
- $cache->save('my-data', file_get_contents('some-image.jpg'));
-
- // Get data
- $data = $cache->get('my-data');
+ use Phalcon\Cache\Backend\Mongo;
+ use Phalcon\Cache\Frontend\Base64;
+
+ // Cache data for 2 days
+ $frontCache = new Base64(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ // Create a MongoDB cache
+ $cache = new Mongo(
+ $frontCache,
+ [
+ "server" => "mongodb://localhost",
+ "db" => "caches",
+ "collection" => "images",
+ ]
+ );
+
+ // Cache arbitrary data
+ $cache->save(
+ "my-data",
+ file_get_contents("some-image.jpg")
+ );
+
+ // Get data
+ $data = $cache->get("my-data");
@@ -60,7 +68,7 @@ Returns a cached content
-public **save** ([*int* | *string* $keyName], [*string* $content], [*long* $lifetime], [*boolean* $stopBuffer])
+public **save** ([*int* | *string* $keyName], [*string* $content], [*int* $lifetime], [*boolean* $stopBuffer])
Stores cached content into the file backend and stops the frontend
@@ -72,13 +80,23 @@ Deletes a value from the cache by its key
-public *array* **queryKeys** ([*string* $prefix])
+public **queryKeys** ([*mixed* $prefix])
+
+Query the existing cached keys.
+
+.. code-block:: php
+
+ save("users-ids", [1, 2, 3]);
+ $cache->save("projects-ids", [4, 5, 6]);
+
+ var_dump($cache->queryKeys("users")); // ["users-ids"]
-Query the existing cached keys
-public *boolean* **exists** ([*string* $keyName], [*long* $lifetime])
+public **exists** ([*string* $keyName], [*int* $lifetime])
Checks if cache exists and it isn't expired
@@ -90,13 +108,13 @@ gc
-public *mixed* **increment** (*int* | *string* $keyName, [*long* $value])
+public **increment** (*int* | *string* $keyName, [*mixed* $value])
Increment of a given key by $value
-public *mixed* **decrement** (*int* | *string* $keyName, [*long* $value])
+public **decrement** (*int* | *string* $keyName, [*mixed* $value])
Decrement of a given key by $value
diff --git a/en/api/Phalcon_Cache_Backend_Redis.rst b/en/api/Phalcon_Cache_Backend_Redis.rst
index 1b049102edb2..04edad9f35ed 100644
--- a/en/api/Phalcon_Cache_Backend_Redis.rst
+++ b/en/api/Phalcon_Cache_Backend_Redis.rst
@@ -10,34 +10,41 @@ Class **Phalcon\\Cache\\Backend\\Redis**
:raw-html:`Source on GitHub`
-Allows to cache output fragments, PHP data or raw data to a redis backend This adapter uses the special redis key "_PHCR" to store all the keys internally used by the adapter
+Allows to cache output fragments, PHP data or raw data to a redis backend
+
+This adapter uses the special redis key "_PHCR" to store all the keys internally used by the adapter
.. code-block:: php
172800
- ]);
-
- // Create the Cache setting redis connection options
- $cache = new Redis($frontCache, [
- 'host' => 'localhost',
- 'port' => 6379,
- 'auth' => 'foobared',
- 'persistent' => false
- 'index' => 0,
- ]);
-
- // Cache arbitrary data
- $cache->save('my-data', [1, 2, 3, 4, 5]);
-
- // Get data
- $data = $cache->get('my-data');
+ use Phalcon\Cache\Backend\Redis;
+ use Phalcon\Cache\Frontend\Data as FrontData;
+
+ // Cache data for 2 days
+ $frontCache = new FrontData(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ // Create the Cache setting redis connection options
+ $cache = new Redis(
+ $frontCache,
+ [
+ "host" => "localhost",
+ "port" => 6379,
+ "auth" => "foobared",
+ "persistent" => false,
+ "index" => 0,
+ ]
+ );
+
+ // Cache arbitrary data
+ $cache->save("my-data", [1, 2, 3, 4, 5]);
+
+ // Get data
+ $data = $cache->get("my-data");
@@ -62,10 +69,20 @@ Returns a cached content
-public **save** ([*int* | *string* $keyName], [*string* $content], [*long* $lifetime], [*boolean* $stopBuffer])
+public **save** ([*int* | *string* $keyName], [*string* $content], [*int* $lifetime], [*boolean* $stopBuffer])
Stores cached content into the file backend and stops the frontend
+.. code-block:: php
+
+ save("my-key", $data);
+
+ // Save data termlessly
+ $cache->save("my-key", $data, -1);
+
+
public **delete** (*int* | *string* $keyName)
@@ -74,25 +91,35 @@ Deletes a value from the cache by its key
-public **queryKeys** ([*string* $prefix])
+public **queryKeys** ([*mixed* $prefix])
+
+Query the existing cached keys.
+
+.. code-block:: php
+
+ save("users-ids", [1, 2, 3]);
+ $cache->save("projects-ids", [4, 5, 6]);
+
+ var_dump($cache->queryKeys("users")); // ["users-ids"]
-Query the existing cached keys
-public *boolean* **exists** ([*string* $keyName], [*long* $lifetime])
+public **exists** ([*string* $keyName], [*int* $lifetime])
Checks if cache exists and it isn't expired
-public **increment** ([*string* $keyName], [*long* $value])
+public **increment** ([*string* $keyName], [*mixed* $value])
Increment of given $keyName by $value
-public **decrement** ([*string* $keyName], [*long* $value])
+public **decrement** ([*string* $keyName], [*mixed* $value])
Decrement of $keyName by given $value
diff --git a/en/api/Phalcon_Cache_Backend_Xcache.rst b/en/api/Phalcon_Cache_Backend_Xcache.rst
index f72940328044..577999fdcf8e 100644
--- a/en/api/Phalcon_Cache_Backend_Xcache.rst
+++ b/en/api/Phalcon_Cache_Backend_Xcache.rst
@@ -10,29 +10,34 @@ Class **Phalcon\\Cache\\Backend\\Xcache**
:raw-html:`Source on GitHub`
-Allows to cache output fragments, PHP data and raw data using an XCache backend
+Allows to cache output fragments, PHP data and raw data using an XCache backend
.. code-block:: php
172800
- ]);
-
- $cache = new Xcache($frontCache, [
- 'prefix' => 'app-data'
- ]);
-
- // Cache arbitrary data
- $cache->save('my-data', [1, 2, 3, 4, 5]);
-
- // Get data
- $data = $cache->get('my-data');
+ use Phalcon\Cache\Backend\Xcache;
+ use Phalcon\Cache\Frontend\Data as FrontData;
+
+ // Cache data for 2 days
+ $frontCache = new FrontData(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ $cache = new Xcache(
+ $frontCache,
+ [
+ "prefix" => "app-data",
+ ]
+ );
+
+ // Cache arbitrary data
+ $cache->save("my-data", [1, 2, 3, 4, 5]);
+
+ // Get data
+ $data = $cache->get("my-data");
@@ -51,7 +56,7 @@ Returns a cached content
-public **save** ([*int* | *string* $keyName], [*string* $content], [*long* $lifetime], [*boolean* $stopBuffer])
+public **save** ([*int* | *string* $keyName], [*string* $content], [*int* $lifetime], [*boolean* $stopBuffer])
Stores cached content into the file backend and stops the frontend
@@ -63,25 +68,35 @@ Deletes a value from the cache by its key
-public *array* **queryKeys** ([*string* $prefix])
+public **queryKeys** ([*mixed* $prefix])
+
+Query the existing cached keys.
+
+.. code-block:: php
+
+ save("users-ids", [1, 2, 3]);
+ $cache->save("projects-ids", [4, 5, 6]);
+
+ var_dump($cache->queryKeys("users")); // ["users-ids"]
-Query the existing cached keys
-public *boolean* **exists** ([*string* $keyName], [*long* $lifetime])
+public **exists** ([*string* $keyName], [*int* $lifetime])
Checks if cache exists and it isn't expired
-public *mixed* **increment** (*string* $keyName, [*long* $value])
+public **increment** (*string* $keyName, [*mixed* $value])
Atomic increment of a given key, by number $value
-public *mixed* **decrement** (*string* $keyName, [*long* $value])
+public **decrement** (*string* $keyName, [*mixed* $value])
Atomic decrement of a given key, by number $value
diff --git a/en/api/Phalcon_Cache_Frontend_Base64.rst b/en/api/Phalcon_Cache_Frontend_Base64.rst
index dd153275f311..5085c2db3d55 100644
--- a/en/api/Phalcon_Cache_Frontend_Base64.rst
+++ b/en/api/Phalcon_Cache_Frontend_Base64.rst
@@ -8,37 +8,49 @@ Class **Phalcon\\Cache\\Frontend\\Base64**
:raw-html:`Source on GitHub`
-Allows to cache data converting/deconverting them to base64. This adapter uses the base64_encode/base64_decode PHP's functions
+Allows to cache data converting/deconverting them to base64.
+
+This adapter uses the base64_encode/base64_decode PHP's functions
.. code-block:: php
172800
- ));
-
- //Create a MongoDB cache
- $cache = new \Phalcon\Cache\Backend\Mongo($frontCache, array(
- 'server' => "mongodb://localhost",
- 'db' => 'caches',
- 'collection' => 'images'
- ));
-
- // Try to get cached image
- $cacheKey = 'some-image.jpg.cache';
- $image = $cache->get($cacheKey);
- if ($image === null) {
-
- // Store the image in the cache
- $cache->save($cacheKey, file_get_contents('tmp-dir/some-image.jpg'));
- }
-
- header('Content-Type: image/jpeg');
- echo $image;
+
+ // Cache the files for 2 days using a Base64 frontend
+ $frontCache = new \Phalcon\Cache\Frontend\Base64(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ //Create a MongoDB cache
+ $cache = new \Phalcon\Cache\Backend\Mongo(
+ $frontCache,
+ [
+ "server" => "mongodb://localhost",
+ "db" => "caches",
+ "collection" => "images",
+ ]
+ );
+
+ $cacheKey = "some-image.jpg.cache";
+
+ // Try to get cached image
+ $image = $cache->get($cacheKey);
+
+ if ($image === null) {
+ // Store the image in the cache
+ $cache->save(
+ $cacheKey,
+ file_get_contents("tmp-dir/some-image.jpg")
+ );
+ }
+
+ header("Content-Type: image/jpeg");
+
+ echo $image;
@@ -81,13 +93,13 @@ Stops output frontend
-public *string* **beforeStore** (*mixed* $data)
+public **beforeStore** (*mixed* $data)
Serializes data before storing them
-public *mixed* **afterRetrieve** (*mixed* $data)
+public **afterRetrieve** (*mixed* $data)
Unserializes data after retrieval
diff --git a/en/api/Phalcon_Cache_Frontend_Data.rst b/en/api/Phalcon_Cache_Frontend_Data.rst
index 828cdcd66d99..5c4b043bce37 100644
--- a/en/api/Phalcon_Cache_Frontend_Data.rst
+++ b/en/api/Phalcon_Cache_Frontend_Data.rst
@@ -8,40 +8,54 @@ Class **Phalcon\\Cache\\Frontend\\Data**
:raw-html:`Source on GitHub`
-Allows to cache native PHP data in a serialized form
+Allows to cache native PHP data in a serialized form
.. code-block:: php
172800]);
-
- // Create the component that will cache "Data" to a 'File' backend
- // Set the cache file directory - important to keep the '/' at the end of
- // of the value for the folder
- $cache = new File($frontCache, ['cacheDir' => '../app/cache/']);
-
- // Try to get cached records
- $cacheKey = 'robots_order_id.cache';
- $robots = $cache->get($cacheKey);
-
- if ($robots === null) {
- // $robots is null due to cache expiration or data does not exist
- // Make the database call and populate the variable
- $robots = Robots::find(['order' => 'id']);
-
- // Store it in the cache
- $cache->save($cacheKey, $robots);
- }
-
- // Use $robots :)
- foreach ($robots as $robot) {
- echo $robot->name, "\n";
- }
+ use Phalcon\Cache\Backend\File;
+ use Phalcon\Cache\Frontend\Data;
+
+ // Cache the files for 2 days using a Data frontend
+ $frontCache = new Data(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ // Create the component that will cache "Data" to a 'File' backend
+ // Set the cache file directory - important to keep the '/' at the end of
+ // of the value for the folder
+ $cache = new File(
+ $frontCache,
+ [
+ "cacheDir" => "../app/cache/",
+ ]
+ );
+
+ $cacheKey = "robots_order_id.cache";
+
+ // Try to get cached records
+ $robots = $cache->get($cacheKey);
+
+ if ($robots === null) {
+ // $robots is null due to cache expiration or data does not exist
+ // Make the database call and populate the variable
+ $robots = Robots::find(
+ [
+ "order" => "id",
+ ]
+ );
+
+ // Store it in the cache
+ $cache->save($cacheKey, $robots);
+ }
+
+ // Use $robots :)
+ foreach ($robots as $robot) {
+ echo $robot->name, "\n";
+ }
diff --git a/en/api/Phalcon_Cache_Frontend_Igbinary.rst b/en/api/Phalcon_Cache_Frontend_Igbinary.rst
index 3c0ed5e3f5fb..08329a44aca3 100644
--- a/en/api/Phalcon_Cache_Frontend_Igbinary.rst
+++ b/en/api/Phalcon_Cache_Frontend_Igbinary.rst
@@ -10,40 +10,50 @@ Class **Phalcon\\Cache\\Frontend\\Igbinary**
:raw-html:`Source on GitHub`
-Allows to cache native PHP data in a serialized form using igbinary extension
+Allows to cache native PHP data in a serialized form using igbinary extension
.. code-block:: php
172800
- ));
-
+ $frontCache = new \Phalcon\Cache\Frontend\Igbinary(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
// Create the component that will cache "Igbinary" to a "File" backend
// Set the cache file directory - important to keep the "/" at the end of
// of the value for the folder
- $cache = new \Phalcon\Cache\Backend\File($frontCache, array(
- "cacheDir" => "../app/cache/"
- ));
-
+ $cache = new \Phalcon\Cache\Backend\File(
+ $frontCache,
+ [
+ "cacheDir" => "../app/cache/",
+ ]
+ );
+
+ $cacheKey = "robots_order_id.cache";
+
// Try to get cached records
- $cacheKey = 'robots_order_id.cache';
- $robots = $cache->get($cacheKey);
+ $robots = $cache->get($cacheKey);
+
if ($robots === null) {
-
- // $robots is null due to cache expiration or data do not exist
- // Make the database call and populate the variable
- $robots = Robots::find(array("order" => "id"));
-
- // Store it in the cache
- $cache->save($cacheKey, $robots);
+ // $robots is null due to cache expiration or data do not exist
+ // Make the database call and populate the variable
+ $robots = Robots::find(
+ [
+ "order" => "id",
+ ]
+ );
+
+ // Store it in the cache
+ $cache->save($cacheKey, $robots);
}
-
+
// Use $robots :)
foreach ($robots as $robot) {
- echo $robot->name, "\n";
+ echo $robot->name, "\n";
}
@@ -87,13 +97,13 @@ Stops output frontend
-public *string* **beforeStore** (*mixed* $data)
+public **beforeStore** (*mixed* $data)
Serializes data before storing them
-public *mixed* **afterRetrieve** (*mixed* $data)
+public **afterRetrieve** (*mixed* $data)
Unserializes data after retrieval
diff --git a/en/api/Phalcon_Cache_Frontend_Json.rst b/en/api/Phalcon_Cache_Frontend_Json.rst
index f0dff6f3fecb..e191a3cc67e3 100644
--- a/en/api/Phalcon_Cache_Frontend_Json.rst
+++ b/en/api/Phalcon_Cache_Frontend_Json.rst
@@ -8,31 +8,41 @@ Class **Phalcon\\Cache\\Frontend\\Json**
:raw-html:`Source on GitHub`
-Allows to cache data converting/deconverting them to JSON. This adapter uses the json_encode/json_decode PHP's functions As the data is encoded in JSON other systems accessing the same backend could process them
+Allows to cache data converting/deconverting them to JSON.
+
+This adapter uses the json_encode/json_decode PHP's functions
+
+As the data is encoded in JSON other systems accessing the same backend could
+process them
.. code-block:: php
172800
- ));
-
- //Create the Cache setting memcached connection options
- $cache = new \Phalcon\Cache\Backend\Memcache($frontCache, array(
- 'host' => 'localhost',
- 'port' => 11211,
- 'persistent' => false
- ));
-
- //Cache arbitrary data
- $cache->save('my-data', array(1, 2, 3, 4, 5));
-
- //Get data
- $data = $cache->get('my-data');
+
+ // Cache the data for 2 days
+ $frontCache = new \Phalcon\Cache\Frontend\Json(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ // Create the Cache setting memcached connection options
+ $cache = new \Phalcon\Cache\Backend\Memcache(
+ $frontCache,
+ [
+ "host" => "localhost",
+ "port" => 11211,
+ "persistent" => false,
+ ]
+ );
+
+ // Cache arbitrary data
+ $cache->save("my-data", [1, 2, 3, 4, 5]);
+
+ // Get data
+ $data = $cache->get("my-data");
@@ -75,13 +85,13 @@ Stops output frontend
-public *string* **beforeStore** (*mixed* $data)
+public **beforeStore** (*mixed* $data)
Serializes data before storing them
-public *mixed* **afterRetrieve** (*mixed* $data)
+public **afterRetrieve** (*mixed* $data)
Unserializes data after retrieval
diff --git a/en/api/Phalcon_Cache_Frontend_Msgpack.rst b/en/api/Phalcon_Cache_Frontend_Msgpack.rst
index 1da5a41e15b2..55adf0e9341c 100644
--- a/en/api/Phalcon_Cache_Frontend_Msgpack.rst
+++ b/en/api/Phalcon_Cache_Frontend_Msgpack.rst
@@ -10,43 +10,55 @@ Class **Phalcon\\Cache\\Frontend\\Msgpack**
:raw-html:`Source on GitHub`
-Allows to cache native PHP data in a serialized form using msgpack extension This adapter uses a Msgpack frontend to store the cached content and requires msgpack extension.
+Allows to cache native PHP data in a serialized form using msgpack extension
+This adapter uses a Msgpack frontend to store the cached content and requires msgpack extension.
.. code-block:: php
172800
- ]);
-
- // Create the component that will cache "Msgpack" to a "File" backend
- // Set the cache file directory - important to keep the "/" at the end of
- // of the value for the folder
- $cache = new File($frontCache, [
- 'cacheDir' => '../app/cache/'
- ]);
-
- // Try to get cached records
- $cacheKey = 'robots_order_id.cache';
- $robots = $cache->get($cacheKey);
- if ($robots === null) {
- // $robots is null due to cache expiration or data do not exist
- // Make the database call and populate the variable
- $robots = Robots::find(['order' => 'id']);
-
- // Store it in the cache
- $cache->save($cacheKey, $robots);
- }
-
- // Use $robots
- foreach ($robots as $robot) {
- echo $robot->name, "\n";
- }
+ use Phalcon\Cache\Backend\File;
+ use Phalcon\Cache\Frontend\Msgpack;
+
+ // Cache the files for 2 days using Msgpack frontend
+ $frontCache = new Msgpack(
+ [
+ "lifetime" => 172800,
+ ]
+ );
+
+ // Create the component that will cache "Msgpack" to a "File" backend
+ // Set the cache file directory - important to keep the "/" at the end of
+ // of the value for the folder
+ $cache = new File(
+ $frontCache,
+ [
+ "cacheDir" => "../app/cache/",
+ ]
+ );
+
+ $cacheKey = "robots_order_id.cache";
+
+ // Try to get cached records
+ $robots = $cache->get($cacheKey);
+
+ if ($robots === null) {
+ // $robots is null due to cache expiration or data do not exist
+ // Make the database call and populate the variable
+ $robots = Robots::find(
+ [
+ "order" => "id",
+ ]
+ );
+
+ // Store it in the cache
+ $cache->save($cacheKey, $robots);
+ }
+
+ // Use $robots
+ foreach ($robots as $robot) {
+ echo $robot->name, "\n";
+ }
diff --git a/en/api/Phalcon_Cache_Frontend_None.rst b/en/api/Phalcon_Cache_Frontend_None.rst
index ede9356be7ec..5dca8830c3e9 100644
--- a/en/api/Phalcon_Cache_Frontend_None.rst
+++ b/en/api/Phalcon_Cache_Frontend_None.rst
@@ -8,39 +8,47 @@ Class **Phalcon\\Cache\\Frontend\\None**
:raw-html:`Source on GitHub`
-Discards any kind of frontend data input. This frontend does not have expiration time or any other options
+Discards any kind of frontend data input. This frontend does not have expiration time or any other options
.. code-block:: php
"localhost",
- "port" => "11211"
- ));
-
+ $cache = new \Phalcon\Cache\Backend\Memcache(
+ $frontCache,
+ [
+ "host" => "localhost",
+ "port" => "11211",
+ ]
+ );
+
+ $cacheKey = "robots_order_id.cache";
+
// This Frontend always return the data as it's returned by the backend
- $cacheKey = 'robots_order_id.cache';
- $robots = $cache->get($cacheKey);
+ $robots = $cache->get($cacheKey);
+
if ($robots === null) {
-
- // This cache doesn't perform any expiration checking, so the data is always expired
- // Make the database call and populate the variable
- $robots = Robots::find(array("order" => "id"));
-
- $cache->save($cacheKey, $robots);
+ // This cache doesn't perform any expiration checking, so the data is always expired
+ // Make the database call and populate the variable
+ $robots = Robots::find(
+ [
+ "order" => "id",
+ ]
+ );
+
+ $cache->save($cacheKey, $robots);
}
-
+
// Use $robots :)
foreach ($robots as $robot) {
- echo $robot->name, "\n";
+ echo $robot->name, "\n";
}
diff --git a/en/api/Phalcon_Cache_Frontend_Output.rst b/en/api/Phalcon_Cache_Frontend_Output.rst
index 517584eb2cef..59f138d94945 100644
--- a/en/api/Phalcon_Cache_Frontend_Output.rst
+++ b/en/api/Phalcon_Cache_Frontend_Output.rst
@@ -8,7 +8,7 @@ Class **Phalcon\\Cache\\Frontend\\Output**
:raw-html:`Source on GitHub`
-Allows to cache output fragments captured with ob_* functions
+Allows to cache output fragments captured with ob_* functions
.. code-block:: php
@@ -20,27 +20,36 @@ Allows to cache output fragments captured with ob_* functions
* use Phalcon\Cache\Frontend\Output;
*
* // Create an Output frontend. Cache the files for 2 days
- * $frontCache = new Output(['lifetime' => 172800]));
+ * $frontCache = new Output(
+ * [
+ * "lifetime" => 172800,
+ * ]
+ * );
*
* // Create the component that will cache from the "Output" to a "File" backend
* // Set the cache file directory - it's important to keep the "/" at the end of
* // the value for the folder
- * $cache = new File($frontCache, ['cacheDir' => '../app/cache/']);
+ * $cache = new File(
+ * $frontCache,
+ * [
+ * "cacheDir" => "../app/cache/",
+ * ]
+ * );
*
* // Get/Set the cache file to ../app/cache/my-cache.html
- * $content = $cache->start('my-cache.html');
+ * $content = $cache->start("my-cache.html");
*
* // If $content is null then the content will be generated for the cache
* if (null === $content) {
* // Print date and time
- * echo date('r');
+ * echo date("r");
*
* // Generate a link to the sign-up action
* echo Tag::linkTo(
* [
- * 'user/signup',
- * 'Sign Up',
- * 'class' => 'signup-button'
+ * "user/signup",
+ * "Sign Up",
+ * "class" => "signup-button",
* ]
* );
*
@@ -93,13 +102,13 @@ Stops output frontend
-public *string* **beforeStore** (*mixed* $data)
+public **beforeStore** (*mixed* $data)
Serializes data before storing them
-public *mixed* **afterRetrieve** (*mixed* $data)
+public **afterRetrieve** (*mixed* $data)
Unserializes data after retrieval
diff --git a/en/api/Phalcon_Cache_Multiple.rst b/en/api/Phalcon_Cache_Multiple.rst
index 765e69b52246..7193b6a49ae6 100644
--- a/en/api/Phalcon_Cache_Multiple.rst
+++ b/en/api/Phalcon_Cache_Multiple.rst
@@ -6,48 +6,65 @@ Class **Phalcon\\Cache\\Multiple**
:raw-html:`Source on GitHub`
-Allows to read to chained backend adapters writing to multiple backends
+Allows to read to chained backend adapters writing to multiple backends
.. code-block:: php
3600
- ));
-
- $fastFrontend = new DataFrontend(array(
- "lifetime" => 86400
- ));
-
- $slowFrontend = new DataFrontend(array(
- "lifetime" => 604800
- ));
-
- //Backends are registered from the fastest to the slower
- $cache = new Multiple(array(
- new ApcCache($ultraFastFrontend, array(
- "prefix" => 'cache',
- )),
- new MemcacheCache($fastFrontend, array(
- "prefix" => 'cache',
- "host" => "localhost",
- "port" => "11211"
- )),
- new FileCache($slowFrontend, array(
- "prefix" => 'cache',
- "cacheDir" => "../app/cache/"
- ))
- ));
-
- //Save, saves in every backend
- $cache->save('my-key', $data);
+ use Phalcon\Cache\Frontend\Data as DataFrontend;
+ use Phalcon\Cache\Multiple;
+ use Phalcon\Cache\Backend\Apc as ApcCache;
+ use Phalcon\Cache\Backend\Memcache as MemcacheCache;
+ use Phalcon\Cache\Backend\File as FileCache;
+
+ $ultraFastFrontend = new DataFrontend(
+ [
+ "lifetime" => 3600,
+ ]
+ );
+
+ $fastFrontend = new DataFrontend(
+ [
+ "lifetime" => 86400,
+ ]
+ );
+
+ $slowFrontend = new DataFrontend(
+ [
+ "lifetime" => 604800,
+ ]
+ );
+
+ //Backends are registered from the fastest to the slower
+ $cache = new Multiple(
+ [
+ new ApcCache(
+ $ultraFastFrontend,
+ [
+ "prefix" => "cache",
+ ]
+ ),
+ new MemcacheCache(
+ $fastFrontend,
+ [
+ "prefix" => "cache",
+ "host" => "localhost",
+ "port" => "11211",
+ ]
+ ),
+ new FileCache(
+ $slowFrontend,
+ [
+ "prefix" => "cache",
+ "cacheDir" => "../app/cache/",
+ ]
+ ),
+ ]
+ );
+
+ //Save, saves in every backend
+ $cache->save("my-key", $data);
@@ -66,19 +83,19 @@ Adds a backend
-public *mixed* **get** (*string* | *int* $keyName, [*long* $lifetime])
+public *mixed* **get** (*string* | *int* $keyName, [*int* $lifetime])
Returns a cached content reading the internal backends
-public **start** (*string* | *int* $keyName, [*long* $lifetime])
+public **start** (*string* | *int* $keyName, [*int* $lifetime])
Starts every backend
-public **save** ([*string* $keyName], [*string* $content], [*long* $lifetime], [*boolean* $stopBuffer])
+public **save** ([*string* $keyName], [*string* $content], [*int* $lifetime], [*boolean* $stopBuffer])
Stores cached content into all backends and stops the frontend
@@ -90,7 +107,7 @@ Deletes a value from each backend
-public *boolean* **exists** ([*string* | *int* $keyName], [*long* $lifetime])
+public **exists** ([*string* | *int* $keyName], [*int* $lifetime])
Checks if cache exists in at least one backend
diff --git a/en/api/Phalcon_Cli_Console.rst b/en/api/Phalcon_Cli_Console.rst
index cd9ab25296fe..92c2597a8ba6 100644
--- a/en/api/Phalcon_Cli_Console.rst
+++ b/en/api/Phalcon_Cli_Console.rst
@@ -18,18 +18,20 @@ Methods
public **addModules** (*array* $modules)
-Merge modules with the existing ones
+Merge modules with the existing ones
.. code-block:: php
addModules(array(
- 'admin' => array(
- 'className' => 'Multiple\Admin\Module',
- 'path' => '../apps/admin/Module.php'
- )
- ));
+ $application->addModules(
+ [
+ "admin" => [
+ "className" => "Multiple\\Admin\\Module",
+ "path" => "../apps/admin/Module.php",
+ ],
+ ]
+ );
@@ -66,24 +68,24 @@ Returns the internal event manager
public **registerModules** (*array* $modules, [*mixed* $merge]) inherited from :doc:`Phalcon\\Application `
-Register an array of modules present in the application
+Register an array of modules present in the application
.. code-block:: php
registerModules(
- [
- 'frontend' => [
- 'className' => 'Multiple\Frontend\Module',
- 'path' => '../apps/frontend/Module.php'
- ],
- 'backend' => [
- 'className' => 'Multiple\Backend\Module',
- 'path' => '../apps/backend/Module.php'
- ]
- ]
- );
+ $this->registerModules(
+ [
+ "frontend" => [
+ "className" => "Multiple\\Frontend\\Module",
+ "path" => "../apps/frontend/Module.php",
+ ],
+ "backend" => [
+ "className" => "Multiple\\Backend\\Module",
+ "path" => "../apps/backend/Module.php",
+ ],
+ ]
+ );
diff --git a/en/api/Phalcon_Cli_Dispatcher.rst b/en/api/Phalcon_Cli_Dispatcher.rst
index 8bc8e09a5d04..b886098cfbc5 100644
--- a/en/api/Phalcon_Cli_Dispatcher.rst
+++ b/en/api/Phalcon_Cli_Dispatcher.rst
@@ -10,23 +10,25 @@ Class **Phalcon\\Cli\\Dispatcher**
:raw-html:`Source on GitHub`
-Dispatching is the process of taking the command-line arguments, extracting the module name, task name, action name, and optional parameters contained in it, and then instantiating a task and calling an action on it.
+Dispatching is the process of taking the command-line arguments, extracting the module name,
+task name, action name, and optional parameters contained in it, and then
+instantiating a task and calling an action on it.
.. code-block:: php
setDi(di);
-
- $dispatcher->setTaskName('posts');
- $dispatcher->setActionName('index');
- $dispatcher->setParams(array());
-
- $handle = dispatcher->dispatch();
+
+ $dispatcher->setDi($di);
+
+ $dispatcher->setTaskName("posts");
+ $dispatcher->setActionName("index");
+ $dispatcher->setParams([]);
+
+ $handle = $dispatcher->dispatch();
@@ -86,7 +88,7 @@ Handles a user exception
public **getLastTask** ()
-Returns the lastest dispatched controller
+Returns the latest dispatched controller
@@ -277,13 +279,19 @@ Dispatches a handle action taking into account the routing parameters
public **forward** (*array* $forward) inherited from :doc:`Phalcon\\Dispatcher `
-Forwards the execution flow to another controller/action Dispatchers are unique per module. Forwarding between modules is not allowed
+Forwards the execution flow to another controller/action
+Dispatchers are unique per module. Forwarding between modules is not allowed
.. code-block:: php
dispatcher->forward(array("controller" => "posts", "action" => "index"));
+ $this->dispatcher->forward(
+ [
+ "controller" => "posts",
+ "action" => "index",
+ ]
+ );
diff --git a/en/api/Phalcon_Cli_Router.rst b/en/api/Phalcon_Cli_Router.rst
index cdfffd44bcef..08c685d252b9 100644
--- a/en/api/Phalcon_Cli_Router.rst
+++ b/en/api/Phalcon_Cli_Router.rst
@@ -8,18 +8,25 @@ Class **Phalcon\\Cli\\Router**
:raw-html:`Source on GitHub`
-Phalcon\\Cli\\Router is the standard framework router. Routing is the process of taking a command-line arguments and decomposing it into parameters to determine which module, task, and action of that task should receive the request
+Phalcon\\Cli\\Router is the standard framework router. Routing is the
+process of taking a command-line arguments and
+decomposing it into parameters to determine which module, task, and
+action of that task should receive the request
.. code-block:: php
handle(array(
- 'module' => 'main',
- 'task' => 'videos',
- 'action' => 'process'
- ));
+
+ $router->handle(
+ [
+ "module" => "main",
+ "task" => "videos",
+ "action" => "process",
+ ]
+ );
+
echo $router->getTaskName();
@@ -65,16 +72,19 @@ Sets the default action name
public **setDefaults** (*array* $defaults)
-Sets an array of default paths. If a route is missing a path the router will use the defined here This method must not be used to set a 404 route
+Sets an array of default paths. If a route is missing a path the router will use the defined here
+This method must not be used to set a 404 route
.. code-block:: php
setDefaults(array(
- 'module' => 'common',
- 'action' => 'index'
- ));
+ $router->setDefaults(
+ [
+ "module" => "common",
+ "action" => "index",
+ ]
+ );
@@ -87,26 +97,26 @@ Handles routing information received from command-line arguments
public :doc:`Phalcon\\Cli\\Router\\Route ` **add** (*string* $pattern, [*string/array* $paths])
-Adds a route to the router
+Adds a route to the router
.. code-block:: php
add('/about', 'About::main');
+ $router->add("/about", "About::main");
public **getModuleName** ()
-Returns proccesed module name
+Returns processed module name
public **getTaskName** ()
-Returns proccesed task name
+Returns processed task name
diff --git a/en/api/Phalcon_Cli_Router_Route.rst b/en/api/Phalcon_Cli_Router_Route.rst
index 8a00e4cc44c1..409d5fc2aa02 100644
--- a/en/api/Phalcon_Cli_Router_Route.rst
+++ b/en/api/Phalcon_Cli_Router_Route.rst
@@ -49,22 +49,27 @@ Returns the route's name
public **setName** (*mixed* $name)
-Sets the route's name
+Sets the route's name
.. code-block:: php
add('/about', array(
- 'controller' => 'about'
- ))->setName('about');
+ $router->add(
+ "/about",
+ [
+ "controller" => "about",
+ ]
+ )->setName("about");
public :doc:`Phalcon\\Cli\\Router\\Route ` **beforeMatch** (*callback* $callback)
-Sets a callback that is called if the route is matched. The developer can implement any arbitrary conditions here If the callback returns false the route is treated as not matched
+Sets a callback that is called if the route is matched.
+The developer can implement any arbitrary conditions here
+If the callback returns false the route is treated as not matched
diff --git a/en/api/Phalcon_Cli_Task.rst b/en/api/Phalcon_Cli_Task.rst
index 5430cce73762..55d5cdb30235 100644
--- a/en/api/Phalcon_Cli_Task.rst
+++ b/en/api/Phalcon_Cli_Task.rst
@@ -10,7 +10,10 @@ Class **Phalcon\\Cli\\Task**
:raw-html:`Source on GitHub`
-Every command-line task should extend this class that encapsulates all the task functionality A task can be used to run "tasks" such as migrations, cronjobs, unit-tests, or anything that you want. The Task class should at least have a "mainAction" method
+Every command-line task should extend this class that encapsulates all the task functionality
+
+A task can be used to run "tasks" such as migrations, cronjobs, unit-tests, or anything that you want.
+The Task class should at least have a "mainAction" method
.. code-block:: php
@@ -18,18 +21,16 @@ Every command-line task should extend this class that encapsulates all the task
class HelloTask extends \Phalcon\Cli\Task
{
-
- // This action will be executed by default
- public function mainAction()
- {
-
- }
-
- public function findAction()
- {
-
- }
-
+ // This action will be executed by default
+ public function mainAction()
+ {
+
+ }
+
+ public function findAction()
+ {
+
+ }
}
diff --git a/en/api/Phalcon_Config.rst b/en/api/Phalcon_Config.rst
index c84777e23144..5d4dc7326950 100644
--- a/en/api/Phalcon_Config.rst
+++ b/en/api/Phalcon_Config.rst
@@ -8,26 +8,30 @@ Class **Phalcon\\Config**
:raw-html:`Source on GitHub`
-Phalcon\\Config is designed to simplify the access to, and the use of, configuration data within applications. It provides a nested object property based user interface for accessing this configuration data within application code.
+Phalcon\\Config is designed to simplify the access to, and the use of, configuration data within applications.
+It provides a nested object property based user interface for accessing this configuration data within
+application code.
.. code-block:: php
array(
- "adapter" => "Mysql",
- "host" => "localhost",
- "username" => "scott",
- "password" => "cheetah",
- "dbname" => "test_db"
- ),
- "phalcon" => array(
- "controllersDir" => "../app/controllers/",
- "modelsDir" => "../app/models/",
- "viewsDir" => "../app/views/"
- )
- ));
+ $config = new \Phalcon\Config(
+ [
+ "database" => [
+ "adapter" => "Mysql",
+ "host" => "localhost",
+ "username" => "scott",
+ "password" => "cheetah",
+ "dbname" => "test_db",
+ ],
+ "phalcon" => [
+ "controllersDir" => "../app/controllers/",
+ "modelsDir" => "../app/models/",
+ "viewsDir" => "../app/views/",
+ ],
+ ]
+ );
@@ -42,113 +46,129 @@ Phalcon\\Config constructor
public **offsetExists** (*mixed* $index)
-Allows to check whether an attribute is defined using the array-syntax
+Allows to check whether an attribute is defined using the array-syntax
.. code-block:: php
get('controllersDir', '../app/controllers/');
+ echo $config->get("controllersDir", "../app/controllers/");
public **offsetGet** (*mixed* $index)
-Gets an attribute using the array-syntax
+Gets an attribute using the array-syntax
.. code-block:: php
'Sqlite');
+ $config["database"] = [
+ "type" => "Sqlite",
+ ];
public **offsetUnset** (*mixed* $index)
-Unsets an attribute using the array-syntax
+Unsets an attribute using the array-syntax
.. code-block:: php
` $config)
-Merges a configuration into the current one
+Merges a configuration into the current one
.. code-block:: php
array('host' => 'localhost')));
- $globalConfig->merge($config2);
+ $appConfig = new \Phalcon\Config(
+ [
+ "database" => [
+ "host" => "localhost",
+ ],
+ ]
+ );
+
+ $globalConfig->merge($appConfig);
public **toArray** ()
-Converts recursively the object to an array
+Converts recursively the object to an array
.. code-block:: php
toArray());
+ print_r(
+ $config->toArray()
+ );
public **count** ()
-Returns the count of properties set in the config
+Returns the count of properties set in the config
.. code-block:: php
count();
+ print $config->count();
diff --git a/en/api/Phalcon_Config_Adapter_Ini.rst b/en/api/Phalcon_Config_Adapter_Ini.rst
index 80c55dd624fb..96d34a93d11e 100644
--- a/en/api/Phalcon_Config_Adapter_Ini.rst
+++ b/en/api/Phalcon_Config_Adapter_Ini.rst
@@ -10,41 +10,50 @@ Class **Phalcon\\Config\\Adapter\\Ini**
:raw-html:`Source on GitHub`
-Reads ini files and converts them to Phalcon\\Config objects. Given the next configuration file:
+Reads ini files and converts them to Phalcon\\Config objects.
+
+Given the next configuration file:
.. code-block:: ini
phalcon->controllersDir;
- echo $config->database->username;
+ $config = new \Phalcon\Config\Adapter\Ini("path/config.ini");
+
+ echo $config->phalcon->controllersDir;
+ echo $config->database->username;
- PHP constants may also be parsed in the ini file, so if you define a constant as an ini value before calling the constructor, the constant's value will be integrated into the results. To use it this way you must specify the optional second parameter as INI_SCANNER_NORMAL when calling the constructor:
+PHP constants may also be parsed in the ini file, so if you define a constant
+as an ini value before calling the constructor, the constant's value will be
+integrated into the results. To use it this way you must specify the optional
+second parameter as INI_SCANNER_NORMAL when calling the constructor:
.. code-block:: php
_parseIniString('path.hello.world', 'value for last key');
-
- // result
- [
- 'path' => [
- 'hello' => [
- 'world' => 'value for last key',
- ],
- ],
- ];
+ $this->_parseIniString("path.hello.world", "value for last key");
+ // result
+ [
+ "path" => [
+ "hello" => [
+ "world" => "value for last key",
+ ],
+ ],
+ ];
-private **_cast** (*mixed* $ini)
+
+protected **_cast** (*mixed* $ini)
We have to cast values manually because parse_ini_file() has a poor implementation.
@@ -87,113 +96,129 @@ We have to cast values manually because parse_ini_file() has a poor implementati
public **offsetExists** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Allows to check whether an attribute is defined using the array-syntax
+Allows to check whether an attribute is defined using the array-syntax
.. code-block:: php
`
-Gets an attribute from the configuration, if the attribute isn't defined returns null If the value is exactly null or is not defined the default value will be used instead
+Gets an attribute from the configuration, if the attribute isn't defined returns null
+If the value is exactly null or is not defined the default value will be used instead
.. code-block:: php
get('controllersDir', '../app/controllers/');
+ echo $config->get("controllersDir", "../app/controllers/");
public **offsetGet** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Gets an attribute using the array-syntax
+Gets an attribute using the array-syntax
.. code-block:: php
`
-Sets an attribute using the array-syntax
+Sets an attribute using the array-syntax
.. code-block:: php
'Sqlite');
+ $config["database"] = [
+ "type" => "Sqlite",
+ ];
public **offsetUnset** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Unsets an attribute using the array-syntax
+Unsets an attribute using the array-syntax
.. code-block:: php
` $config) inherited from :doc:`Phalcon\\Config `
-Merges a configuration into the current one
+Merges a configuration into the current one
.. code-block:: php
array('host' => 'localhost')));
- $globalConfig->merge($config2);
+ $appConfig = new \Phalcon\Config(
+ [
+ "database" => [
+ "host" => "localhost",
+ ],
+ ]
+ );
+
+ $globalConfig->merge($appConfig);
public **toArray** () inherited from :doc:`Phalcon\\Config `
-Converts recursively the object to an array
+Converts recursively the object to an array
.. code-block:: php
toArray());
+ print_r(
+ $config->toArray()
+ );
public **count** () inherited from :doc:`Phalcon\\Config `
-Returns the count of properties set in the config
+Returns the count of properties set in the config
.. code-block:: php
count();
+ print $config->count();
diff --git a/en/api/Phalcon_Config_Adapter_Json.rst b/en/api/Phalcon_Config_Adapter_Json.rst
index 15f8dab21f3d..96900f581be0 100644
--- a/en/api/Phalcon_Config_Adapter_Json.rst
+++ b/en/api/Phalcon_Config_Adapter_Json.rst
@@ -10,23 +10,26 @@ Class **Phalcon\\Config\\Adapter\\Json**
:raw-html:`Source on GitHub`
-Reads JSON files and converts them to Phalcon\\Config objects. Given the following configuration file:
+Reads JSON files and converts them to Phalcon\\Config objects.
+
+Given the following configuration file:
.. code-block:: php
phalcon->baseuri;
- echo $config->models->metadata;
+ $config = new Phalcon\Config\Adapter\Json("path/config.json");
+
+ echo $config->phalcon->baseuri;
+ echo $config->models->metadata;
@@ -41,113 +44,129 @@ Phalcon\\Config\\Adapter\\Json constructor
public **offsetExists** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Allows to check whether an attribute is defined using the array-syntax
+Allows to check whether an attribute is defined using the array-syntax
.. code-block:: php
`
-Gets an attribute from the configuration, if the attribute isn't defined returns null If the value is exactly null or is not defined the default value will be used instead
+Gets an attribute from the configuration, if the attribute isn't defined returns null
+If the value is exactly null or is not defined the default value will be used instead
.. code-block:: php
get('controllersDir', '../app/controllers/');
+ echo $config->get("controllersDir", "../app/controllers/");
public **offsetGet** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Gets an attribute using the array-syntax
+Gets an attribute using the array-syntax
.. code-block:: php
`
-Sets an attribute using the array-syntax
+Sets an attribute using the array-syntax
.. code-block:: php
'Sqlite');
+ $config["database"] = [
+ "type" => "Sqlite",
+ ];
public **offsetUnset** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Unsets an attribute using the array-syntax
+Unsets an attribute using the array-syntax
.. code-block:: php
` $config) inherited from :doc:`Phalcon\\Config `
-Merges a configuration into the current one
+Merges a configuration into the current one
.. code-block:: php
array('host' => 'localhost')));
- $globalConfig->merge($config2);
+ $appConfig = new \Phalcon\Config(
+ [
+ "database" => [
+ "host" => "localhost",
+ ],
+ ]
+ );
+
+ $globalConfig->merge($appConfig);
public **toArray** () inherited from :doc:`Phalcon\\Config `
-Converts recursively the object to an array
+Converts recursively the object to an array
.. code-block:: php
toArray());
+ print_r(
+ $config->toArray()
+ );
public **count** () inherited from :doc:`Phalcon\\Config `
-Returns the count of properties set in the config
+Returns the count of properties set in the config
.. code-block:: php
count();
+ print $config->count();
diff --git a/en/api/Phalcon_Config_Adapter_Php.rst b/en/api/Phalcon_Config_Adapter_Php.rst
index 3a13c6c2963c..65d77e250347 100644
--- a/en/api/Phalcon_Config_Adapter_Php.rst
+++ b/en/api/Phalcon_Config_Adapter_Php.rst
@@ -10,37 +10,41 @@ Class **Phalcon\\Config\\Adapter\\Php**
:raw-html:`Source on GitHub`
-Reads php files and converts them to Phalcon\\Config objects. Given the next configuration file:
+Reads php files and converts them to Phalcon\\Config objects.
+
+Given the next configuration file:
.. code-block:: php
array(
- 'adapter' => 'Mysql',
- 'host' => 'localhost',
- 'username' => 'scott',
- 'password' => 'cheetah',
- 'dbname' => 'test_db'
- ),
-
- 'phalcon' => array(
- 'controllersDir' => '../app/controllers/',
- 'modelsDir' => '../app/models/',
- 'viewsDir' => '../app/views/'
- ));
-
- You can read it as follows:
+
+ return [
+ "database" => [
+ "adapter" => "Mysql",
+ "host" => "localhost",
+ "username" => "scott",
+ "password" => "cheetah",
+ "dbname" => "test_db",
+ ],
+ "phalcon" => [
+ "controllersDir" => "../app/controllers/",
+ "modelsDir" => "../app/models/",
+ "viewsDir" => "../app/views/",
+ ],
+ ];
+
+You can read it as follows:
.. code-block:: php
phalcon->controllersDir;
- echo $config->database->username;
+ $config = new \Phalcon\Config\Adapter\Php("path/config.php");
+
+ echo $config->phalcon->controllersDir;
+ echo $config->database->username;
@@ -55,113 +59,129 @@ Phalcon\\Config\\Adapter\\Php constructor
public **offsetExists** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Allows to check whether an attribute is defined using the array-syntax
+Allows to check whether an attribute is defined using the array-syntax
.. code-block:: php
`
-Gets an attribute from the configuration, if the attribute isn't defined returns null If the value is exactly null or is not defined the default value will be used instead
+Gets an attribute from the configuration, if the attribute isn't defined returns null
+If the value is exactly null or is not defined the default value will be used instead
.. code-block:: php
get('controllersDir', '../app/controllers/');
+ echo $config->get("controllersDir", "../app/controllers/");
public **offsetGet** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Gets an attribute using the array-syntax
+Gets an attribute using the array-syntax
.. code-block:: php
`
-Sets an attribute using the array-syntax
+Sets an attribute using the array-syntax
.. code-block:: php
'Sqlite');
+ $config["database"] = [
+ "type" => "Sqlite",
+ ];
public **offsetUnset** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Unsets an attribute using the array-syntax
+Unsets an attribute using the array-syntax
.. code-block:: php
` $config) inherited from :doc:`Phalcon\\Config `
-Merges a configuration into the current one
+Merges a configuration into the current one
.. code-block:: php
array('host' => 'localhost')));
- $globalConfig->merge($config2);
+ $appConfig = new \Phalcon\Config(
+ [
+ "database" => [
+ "host" => "localhost",
+ ],
+ ]
+ );
+
+ $globalConfig->merge($appConfig);
public **toArray** () inherited from :doc:`Phalcon\\Config `
-Converts recursively the object to an array
+Converts recursively the object to an array
.. code-block:: php
toArray());
+ print_r(
+ $config->toArray()
+ );
public **count** () inherited from :doc:`Phalcon\\Config `
-Returns the count of properties set in the config
+Returns the count of properties set in the config
.. code-block:: php
count();
+ print $config->count();
diff --git a/en/api/Phalcon_Config_Adapter_Yaml.rst b/en/api/Phalcon_Config_Adapter_Yaml.rst
index c45aaf905d50..491694889acf 100644
--- a/en/api/Phalcon_Config_Adapter_Yaml.rst
+++ b/en/api/Phalcon_Config_Adapter_Yaml.rst
@@ -10,35 +10,43 @@ Class **Phalcon\\Config\\Adapter\\Yaml**
:raw-html:`Source on GitHub`
-Reads YAML files and converts them to Phalcon\\Config objects. Given the following configuration file:
+Reads YAML files and converts them to Phalcon\\Config objects.
+
+Given the following configuration file:
.. code-block:: php
function($value) {
- return APPROOT . $value;
- }
- ]);
-
- echo $config->phalcon->controllersDir;
- echo $config->phalcon->baseuri;
- echo $config->models->metadata;
+ define(
+ "APPROOT",
+ dirname(__DIR__)
+ );
+
+ $config = new \Phalcon\Config\Adapter\Yaml(
+ "path/config.yaml",
+ [
+ "!approot" => function($value) {
+ return APPROOT . $value;
+ },
+ ]
+ );
+
+ echo $config->phalcon->controllersDir;
+ echo $config->phalcon->baseuri;
+ echo $config->models->metadata;
@@ -53,113 +61,129 @@ Phalcon\\Config\\Adapter\\Yaml constructor
public **offsetExists** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Allows to check whether an attribute is defined using the array-syntax
+Allows to check whether an attribute is defined using the array-syntax
.. code-block:: php
`
-Gets an attribute from the configuration, if the attribute isn't defined returns null If the value is exactly null or is not defined the default value will be used instead
+Gets an attribute from the configuration, if the attribute isn't defined returns null
+If the value is exactly null or is not defined the default value will be used instead
.. code-block:: php
get('controllersDir', '../app/controllers/');
+ echo $config->get("controllersDir", "../app/controllers/");
public **offsetGet** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Gets an attribute using the array-syntax
+Gets an attribute using the array-syntax
.. code-block:: php
`
-Sets an attribute using the array-syntax
+Sets an attribute using the array-syntax
.. code-block:: php
'Sqlite');
+ $config["database"] = [
+ "type" => "Sqlite",
+ ];
public **offsetUnset** (*mixed* $index) inherited from :doc:`Phalcon\\Config `
-Unsets an attribute using the array-syntax
+Unsets an attribute using the array-syntax
.. code-block:: php
` $config) inherited from :doc:`Phalcon\\Config `
-Merges a configuration into the current one
+Merges a configuration into the current one
.. code-block:: php
array('host' => 'localhost')));
- $globalConfig->merge($config2);
+ $appConfig = new \Phalcon\Config(
+ [
+ "database" => [
+ "host" => "localhost",
+ ],
+ ]
+ );
+
+ $globalConfig->merge($appConfig);
public **toArray** () inherited from :doc:`Phalcon\\Config `
-Converts recursively the object to an array
+Converts recursively the object to an array
.. code-block:: php
toArray());
+ print_r(
+ $config->toArray()
+ );
public **count** () inherited from :doc:`Phalcon\\Config `
-Returns the count of properties set in the config
+Returns the count of properties set in the config
.. code-block:: php
count();
+ print $config->count();
diff --git a/en/api/Phalcon_Crypt.rst b/en/api/Phalcon_Crypt.rst
index d07b1d2cb2fa..fd5d1f2fcb95 100644
--- a/en/api/Phalcon_Crypt.rst
+++ b/en/api/Phalcon_Crypt.rst
@@ -8,19 +8,19 @@ Class **Phalcon\\Crypt**
:raw-html:`Source on GitHub`
-Provides encryption facilities to phalcon applications
+Provides encryption facilities to phalcon applications
.. code-block:: php
encrypt($text, $key);
-
+
echo $crypt->decrypt($encrypted, $key);
@@ -89,7 +89,7 @@ If the function detects that the text was not padded, it will return it unmodifi
public **encrypt** (*mixed* $text, [*mixed* $key])
-Encrypts a text
+Encrypts a text
.. code-block:: php
@@ -102,7 +102,7 @@ Encrypts a text
public **decrypt** (*mixed* $text, [*mixed* $key])
-Decrypts an encrypted text
+Decrypts an encrypted text
.. code-block:: php
diff --git a/en/api/Phalcon_Db.rst b/en/api/Phalcon_Db.rst
index 0863e6299ce0..f195104f8717 100644
--- a/en/api/Phalcon_Db.rst
+++ b/en/api/Phalcon_Db.rst
@@ -6,7 +6,14 @@ Abstract class **Phalcon\\Db**
:raw-html:`Source on GitHub`
-Phalcon\\Db and its related classes provide a simple SQL database interface for Phalcon Framework. The Phalcon\\Db is the basic class you use to connect your PHP application to an RDBMS. There is a different adapter class for each brand of RDBMS. This component is intended to lower level database operations. If you want to interact with databases using higher level of abstraction use Phalcon\\Mvc\\Model. Phalcon\\Db is an abstract class. You only can use it with a database adapter like Phalcon\\Db\\Adapter\\Pdo
+Phalcon\\Db and its related classes provide a simple SQL database interface for Phalcon Framework.
+The Phalcon\\Db is the basic class you use to connect your PHP application to an RDBMS.
+There is a different adapter class for each brand of RDBMS.
+
+This component is intended to lower level database operations. If you want to interact with databases using
+higher level of abstraction use Phalcon\\Mvc\\Model.
+
+Phalcon\\Db is an abstract class. You only can use it with a database adapter like Phalcon\\Db\\Adapter\\Pdo
.. code-block:: php
@@ -15,25 +22,29 @@ Phalcon\\Db and its related classes provide a simple SQL database interface for
use Phalcon\Db;
use Phalcon\Db\Exception;
use Phalcon\Db\Adapter\Pdo\Mysql as MysqlConnection;
-
+
try {
-
- $connection = new MysqlConnection(array(
- 'host' => '192.168.0.11',
- 'username' => 'sigma',
- 'password' => 'secret',
- 'dbname' => 'blog',
- 'port' => '3306',
- ));
-
- $result = $connection->query("SELECT * FROM robots LIMIT 5");
- $result->setFetchMode(Db::FETCH_NUM);
- while ($robot = $result->fetch()) {
- print_r($robot);
- }
-
+ $connection = new MysqlConnection(
+ [
+ "host" => "192.168.0.11",
+ "username" => "sigma",
+ "password" => "secret",
+ "dbname" => "blog",
+ "port" => "3306",
+ ]
+ );
+
+ $result = $connection->query(
+ "SELECT * FROM robots LIMIT 5"
+ );
+
+ $result->setFetchMode(Db::FETCH_NUM);
+
+ while ($robot = $result->fetch()) {
+ print_r($robot);
+ }
} catch (Exception $e) {
- echo $e->getMessage(), PHP_EOL;
+ echo $e->getMessage(), PHP_EOL;
}
diff --git a/en/api/Phalcon_Db_Adapter.rst b/en/api/Phalcon_Db_Adapter.rst
index 7e9daa07de03..cb7724489427 100644
--- a/en/api/Phalcon_Db_Adapter.rst
+++ b/en/api/Phalcon_Db_Adapter.rst
@@ -1,7 +1,7 @@
Abstract class **Phalcon\\Db\\Adapter**
=======================================
-*implements* :doc:`Phalcon\\Events\\EventsAwareInterface `
+*implements* :doc:`Phalcon\\Db\\AdapterInterface `, :doc:`Phalcon\\Events\\EventsAwareInterface `
.. role:: raw-html(raw)
:format: html
@@ -64,18 +64,18 @@ Returns internal dialect instance
public **fetchOne** (*mixed* $sqlQuery, [*mixed* $fetchMode], [*mixed* $bindParams], [*mixed* $bindTypes])
-Returns the first row in a SQL query result
+Returns the first row in a SQL query result
.. code-block:: php
fetchOne("SELECT * FROM robots");
print_r($robot);
-
- //Getting first robot with associative indexes only
- $robot = $connection->fetchOne("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+
+ // Getting first robot with associative indexes only
+ $robot = $connection->fetchOne("SELECT * FROM robots", \Phalcon\Db::FETCH_ASSOC);
print_r($robot);
@@ -83,25 +83,32 @@ Returns the first row in a SQL query result
public *array* **fetchAll** (*string* $sqlQuery, [*int* $fetchMode], [*array* $bindParams], [*array* $bindTypes])
-Dumps the complete result of a query into an array
+Dumps the complete result of a query into an array
.. code-block:: php
fetchAll("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+ // Getting all robots with associative indexes only
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots",
+ \Phalcon\Db::FETCH_ASSOC
+ );
+
foreach ($robots as $robot) {
- print_r($robot);
+ print_r($robot);
}
-
- //Getting all robots that contains word "robot" withing the name
- $robots = $connection->fetchAll("SELECT * FROM robots WHERE name LIKE :name",
- Phalcon\Db::FETCH_ASSOC,
- array('name' => '%robot%')
- );
- foreach($robots as $robot){
- print_r($robot);
+
+ // Getting all robots that contains word "robot" withing the name
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots WHERE name LIKE :name",
+ \Phalcon\Db::FETCH_ASSOC,
+ [
+ "name" => "%robot%",
+ ]
+ );
+ foreach($robots as $robot) {
+ print_r($robot);
}
@@ -109,18 +116,21 @@ Dumps the complete result of a query into an array
public *string* | ** **fetchColumn** (*string* $sqlQuery, [*array* $placeholders], [*int* | *string* $column])
-Returns the n'th field of first row in a SQL query result
+Returns the n'th field of first row in a SQL query result
.. code-block:: php
fetchColumn("SELECT count(*) FROM robots");
print_r($robotsCount);
-
- //Getting name of last edited robot
- $robot = $connection->fetchColumn("SELECT id, name FROM robots order by modified desc", 1);
+
+ // Getting name of last edited robot
+ $robot = $connection->fetchColumn(
+ "SELECT id, name FROM robots order by modified desc",
+ 1
+ );
print_r($robot);
@@ -128,79 +138,81 @@ Returns the n'th field of first row in a SQL query result
public *boolean* **insert** (*string* | *array* $table, *array* $values, [*array* $fields], [*array* $dataTypes])
-Inserts data into a table using custom RDBMS SQL syntax
+Inserts data into a table using custom RDBMS SQL syntax
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", 1952),
- array("name", "year")
- );
-
- // Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insert(
+ "robots",
+ ["Astro Boy", 1952],
+ ["name", "year"]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **insertAsDict** (*string* $table, *array* $data, [*array* $dataTypes])
-Inserts data into a table using custom RBDM SQL syntax
+Inserts data into a table using custom RBDM SQL syntax
.. code-block:: php
insertAsDict(
- "robots",
- array(
- "name" => "Astro Boy",
- "year" => 1952
- )
- );
-
- //Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insertAsDict(
+ "robots",
+ [
+ "name" => "Astro Boy",
+ "year" => 1952,
+ ]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **update** (*string* | *array* $table, *array* $fields, *array* $values, [*string* | *array* $whereCondition], [*array* $dataTypes])
-Updates data on a table using custom RBDM SQL syntax
+Updates data on a table using custom RBDM SQL syntax
.. code-block:: php
update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
-
- //Updating existing robot with array condition and $dataTypes
- $success = $connection->update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- array(
- 'conditions' => "id = ?",
- 'bind' => array($some_unsafe_id),
- 'bindTypes' => array(PDO::PARAM_INT) //use only if you use $dataTypes param
- ),
- array(PDO::PARAM_STR)
- );
+ // Updating existing robot
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+
+ // Updating existing robot with array condition and $dataTypes
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ [
+ "conditions" => "id = ?",
+ "bind" => [$some_unsafe_id],
+ "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param
+ ],
+ [
+ PDO::PARAM_STR
+ ]
+ );
Warning! If $whereCondition is string it not escaped.
@@ -208,43 +220,66 @@ Warning! If $whereCondition is string it not escaped.
public *boolean* **updateAsDict** (*string* $table, *array* $data, [*string* $whereCondition], [*array* $dataTypes])
-Updates data on a table using custom RBDM SQL syntax Another, more convenient syntax
+Updates data on a table using custom RBDM SQL syntax
+Another, more convenient syntax
.. code-block:: php
updateAsDict(
- "robots",
- array(
- "name" => "New Astro Boy"
- ),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+ // Updating existing robot
+ $success = $connection->updateAsDict(
+ "robots",
+ [
+ "name" => "New Astro Boy",
+ ],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
public *boolean* **delete** (*string* | *array* $table, [*string* $whereCondition], [*array* $placeholders], [*array* $dataTypes])
-Deletes data from a table using custom RBDM SQL syntax
+Deletes data from a table using custom RBDM SQL syntax
.. code-block:: php
delete(
- "robots",
- "id = 101"
- );
-
- //Next SQL sentence is generated
- DELETE FROM `robots` WHERE `id` = 101
+ // Deleting existing robot
+ $success = $connection->delete(
+ "robots",
+ "id = 101"
+ );
+
+ // Next SQL sentence is generated
+ DELETE FROM `robots` WHERE `id` = 101
+
+
+
+
+public **escapeIdentifier** (*array* | *string* $identifier)
+
+Escapes a column/table/schema name
+
+.. code-block:: php
+
+ escapeIdentifier(
+ "robots"
+ );
+
+ $escapedTable = $connection->escapeIdentifier(
+ [
+ "store",
+ "robots",
+ ]
+ );
@@ -257,39 +292,43 @@ Gets a list of columns
public **limit** (*mixed* $sqlQuery, *mixed* $number)
-Appends a LIMIT clause to $sqlQuery argument
+Appends a LIMIT clause to $sqlQuery argument
.. code-block:: php
limit("SELECT * FROM robots", 5);
+ echo $connection->limit("SELECT * FROM robots", 5);
public **tableExists** (*mixed* $tableName, [*mixed* $schemaName])
-Generates SQL checking for the existence of a schema.table
+Generates SQL checking for the existence of a schema.table
.. code-block:: php
tableExists("blog", "posts"));
+ var_dump(
+ $connection->tableExists("blog", "posts")
+ );
public **viewExists** (*mixed* $viewName, [*mixed* $schemaName])
-Generates SQL checking for the existence of a schema.view
+Generates SQL checking for the existence of a schema.view
.. code-block:: php
viewExists("active_users", "posts"));
+ var_dump(
+ $connection->viewExists("active_users", "posts")
+ );
@@ -392,65 +431,75 @@ Returns the SQL column definition from a column
public **listTables** ([*mixed* $schemaName])
-List all tables on a database
+List all tables on a database
.. code-block:: php
listTables("blog"));
+ print_r(
+ $connection->listTables("blog")
+ );
public **listViews** ([*mixed* $schemaName])
-List all views on a database
+List all views on a database
.. code-block:: php
listViews("blog"));
+ print_r(
+ $connection->listViews("blog")
+ );
public :doc:`Phalcon\\Db\\Index `\ [] **describeIndexes** (*string* $table, [*string* $schema])
-Lists table indexes
+Lists table indexes
.. code-block:: php
describeIndexes('robots_parts'));
+ print_r(
+ $connection->describeIndexes("robots_parts")
+ );
public **describeReferences** (*mixed* $table, [*mixed* $schema])
-Lists table references
+Lists table references
.. code-block:: php
describeReferences('robots_parts'));
+ print_r(
+ $connection->describeReferences("robots_parts")
+ );
public **tableOptions** (*mixed* $tableName, [*mixed* $schemaName])
-Gets creation options from a table
+Gets creation options from a table
.. code-block:: php
tableOptions('robots'));
+ print_r(
+ $connection->tableOptions("robots")
+ );
@@ -493,36 +542,50 @@ Returns the savepoint name to use for nested transactions
public **getDefaultIdValue** ()
-Returns the default identity value to be inserted in an identity column
+Returns the default identity value to be inserted in an identity column
.. code-block:: php
insert(
- "robots",
- array($connection->getDefaultIdValue(), "Astro Boy", 1952),
- array("id", "name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'id'
+ $success = $connection->insert(
+ "robots",
+ [
+ $connection->getDefaultIdValue(),
+ "Astro Boy",
+ 1952,
+ ],
+ [
+ "id",
+ "name",
+ "year",
+ ]
+ );
public **getDefaultValue** ()
-Returns the default value to make the RBDM use the default value declared in the table definition
+Returns the default value to make the RBDM use the default value declared in the table definition
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", $connection->getDefaultValue()),
- array("name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'year'
+ $success = $connection->insert(
+ "robots",
+ [
+ "Astro Boy",
+ $connection->getDefaultValue()
+ ],
+ [
+ "name",
+ "year",
+ ]
+ );
@@ -559,7 +622,7 @@ Active SQL statement in the object
public **getRealSQLStatement** ()
-Active SQL statement in the object without replace bound paramters
+Active SQL statement in the object without replace bound parameters
@@ -569,3 +632,68 @@ Active SQL statement in the object
+abstract public **connect** ([*array* $descriptor]) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **query** (*mixed* $sqlStatement, [*mixed* $placeholders], [*mixed* $dataTypes]) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **execute** (*mixed* $sqlStatement, [*mixed* $placeholders], [*mixed* $dataTypes]) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **affectedRows** () inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **close** () inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **escapeString** (*mixed* $str) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **lastInsertId** ([*mixed* $sequenceName]) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **begin** ([*mixed* $nesting]) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **rollback** ([*mixed* $nesting]) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **commit** ([*mixed* $nesting]) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **isUnderTransaction** () inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **getInternalHandler** () inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
+abstract public **describeColumns** (*mixed* $table, [*mixed* $schema]) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
diff --git a/en/api/Phalcon_Db_Adapter_Pdo.rst b/en/api/Phalcon_Db_Adapter_Pdo.rst
index 3e62ba3615eb..187e1dacd1dc 100644
--- a/en/api/Phalcon_Db_Adapter_Pdo.rst
+++ b/en/api/Phalcon_Db_Adapter_Pdo.rst
@@ -3,30 +3,30 @@ Abstract class **Phalcon\\Db\\Adapter\\Pdo**
*extends* abstract class :doc:`Phalcon\\Db\\Adapter `
-*implements* :doc:`Phalcon\\Events\\EventsAwareInterface `
+*implements* :doc:`Phalcon\\Events\\EventsAwareInterface `, :doc:`Phalcon\\Db\\AdapterInterface `
.. role:: raw-html(raw)
:format: html
:raw-html:`Source on GitHub`
-Phalcon\\Db\\Adapter\\Pdo is the Phalcon\\Db that internally uses PDO to connect to a database
+Phalcon\\Db\\Adapter\\Pdo is the Phalcon\\Db that internally uses PDO to connect to a database
.. code-block:: php
'localhost',
- 'dbname' => 'blog',
- 'port' => 3306,
- 'username' => 'sigma',
- 'password' => 'secret'
- ];
-
- $connection = new Mysql($config);
+ use Phalcon\Db\Adapter\Pdo\Mysql;
+
+ $config = [
+ "host" => "localhost",
+ "dbname" => "blog",
+ "port" => 3306,
+ "username" => "sigma",
+ "password" => "secret",
+ ];
+
+ $connection = new Mysql($config);
@@ -41,168 +41,215 @@ Constructor for Phalcon\\Db\\Adapter\\Pdo
public **connect** ([*array* $descriptor])
-This method is automatically called in \\Phalcon\\Db\\Adapter\\Pdo constructor. Call it when you need to restore a database connection.
+This method is automatically called in \\Phalcon\\Db\\Adapter\\Pdo constructor.
+Call it when you need to restore a database connection.
.. code-block:: php
'localhost',
- 'username' => 'sigma',
- 'password' => 'secret',
- 'dbname' => 'blog',
- 'port' => 3306,
- ]);
-
- // Reconnect
- $connection->connect();
+ use Phalcon\Db\Adapter\Pdo\Mysql;
+
+ // Make a connection
+ $connection = new Mysql(
+ [
+ "host" => "localhost",
+ "username" => "sigma",
+ "password" => "secret",
+ "dbname" => "blog",
+ "port" => 3306,
+ ]
+ );
+
+ // Reconnect
+ $connection->connect();
public **prepare** (*mixed* $sqlStatement)
-Returns a PDO prepared statement to be executed with 'executePrepared'
+Returns a PDO prepared statement to be executed with 'executePrepared'
.. code-block:: php
prepare('SELECT * FROM robots WHERE name = :name');
- $result = $connection->executePrepared($statement, ['name' => 'Voltron'], ['name' => Column::BIND_PARAM_INT]);
+ use Phalcon\Db\Column;
+
+ $statement = $db->prepare(
+ "SELECT * FROM robots WHERE name = :name"
+ );
+
+ $result = $connection->executePrepared(
+ $statement,
+ [
+ "name" => "Voltron",
+ ],
+ [
+ "name" => Column::BIND_PARAM_INT,
+ ]
+ );
public `PDOStatement `_ **executePrepared** (`PDOStatement `_ $statement, *array* $placeholders, *array* $dataTypes)
-Executes a prepared statement binding. This function uses integer indexes starting from zero
+Executes a prepared statement binding. This function uses integer indexes starting from zero
.. code-block:: php
prepare('SELECT * FROM robots WHERE name = :name');
- $result = $connection->executePrepared($statement, ['name' => 'Voltron'], ['name' => Column::BIND_PARAM_INT]);
+ use Phalcon\Db\Column;
+
+ $statement = $db->prepare(
+ "SELECT * FROM robots WHERE name = :name"
+ );
+
+ $result = $connection->executePrepared(
+ $statement,
+ [
+ "name" => "Voltron",
+ ],
+ [
+ "name" => Column::BIND_PARAM_INT,
+ ]
+ );
public **query** (*mixed* $sqlStatement, [*mixed* $bindParams], [*mixed* $bindTypes])
-Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server is returning rows
+Sends SQL statements to the database server returning the success state.
+Use this method only when the SQL statement sent to the server is returning rows
.. code-block:: php
query("SELECT * FROM robots WHERE type='mechanical'");
- $resultset = $connection->query("SELECT * FROM robots WHERE type=?", array("mechanical"));
+ // Querying data
+ $resultset = $connection->query(
+ "SELECT * FROM robots WHERE type = 'mechanical'"
+ );
+
+ $resultset = $connection->query(
+ "SELECT * FROM robots WHERE type = ?",
+ [
+ "mechanical",
+ ]
+ );
public **execute** (*mixed* $sqlStatement, [*mixed* $bindParams], [*mixed* $bindTypes])
-Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server doesn't return any rows
+Sends SQL statements to the database server returning the success state.
+Use this method only when the SQL statement sent to the server doesn't return any rows
.. code-block:: php
execute("INSERT INTO robots VALUES (1, 'Astro Boy')");
- $success = $connection->execute("INSERT INTO robots VALUES (?, ?)", array(1, 'Astro Boy'));
+ // Inserting data
+ $success = $connection->execute(
+ "INSERT INTO robots VALUES (1, 'Astro Boy')"
+ );
+
+ $success = $connection->execute(
+ "INSERT INTO robots VALUES (?, ?)",
+ [
+ 1,
+ "Astro Boy",
+ ]
+ );
public **affectedRows** ()
-Returns the number of affected rows by the lastest INSERT/UPDATE/DELETE executed in the database system
+Returns the number of affected rows by the latest INSERT/UPDATE/DELETE executed in the database system
.. code-block:: php
execute("DELETE FROM robots");
- echo $connection->affectedRows(), ' were deleted';
-
+ $connection->execute(
+ "DELETE FROM robots"
+ );
+ echo $connection->affectedRows(), " were deleted";
-public **close** ()
-Closes the active connection returning success. Phalcon automatically closes and destroys active connections when the request ends
+public **close** ()
-
-public *string* **escapeIdentifier** (*string* $identifier)
-
-Escapes a column/table/schema name
-
-.. code-block:: php
-
- escapeIdentifier('robots');
- $escapedTable = $connection->escapeIdentifier(['store', 'robots']);
-
+Closes the active connection returning success. Phalcon automatically closes and destroys
+active connections when the request ends
public **escapeString** (*mixed* $str)
-Escapes a value to avoid SQL injections according to the active charset in the connection
+Escapes a value to avoid SQL injections according to the active charset in the connection
.. code-block:: php
escapeString('some dangerous value');
+ $escapedStr = $connection->escapeString("some dangerous value");
public **convertBoundParams** (*mixed* $sql, [*array* $params])
-Converts bound parameters such as :name: or ?1 into PDO bind params ?
+Converts bound parameters such as :name: or ?1 into PDO bind params ?
.. code-block:: php
convertBoundParams('SELECT * FROM robots WHERE name = :name:', array('Bender')));
+ print_r(
+ $connection->convertBoundParams(
+ "SELECT * FROM robots WHERE name = :name:",
+ [
+ "Bender",
+ ]
+ )
+ );
public *int* | *boolean* **lastInsertId** ([*string* $sequenceName])
-Returns the insert id for the auto_increment/serial column inserted in the lastest executed SQL statement
+Returns the insert id for the auto_increment/serial column inserted in the latest executed SQL statement
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", 1952),
- array("name", "year")
- );
-
- //Getting the generated id
- $id = $connection->lastInsertId();
+ // Inserting a new robot
+ $success = $connection->insert(
+ "robots",
+ [
+ "Astro Boy",
+ 1952,
+ ],
+ [
+ "name",
+ "year",
+ ]
+ );
+
+ // Getting the generated id
+ $id = $connection->lastInsertId();
@@ -233,14 +280,18 @@ Returns the current transaction nesting level
public **isUnderTransaction** ()
-Checks whether the connection is under a transaction
+Checks whether the connection is under a transaction
.. code-block:: php
begin();
- var_dump($connection->isUnderTransaction()); //true
+
+ // true
+ var_dump(
+ $connection->isUnderTransaction()
+ );
@@ -301,18 +352,18 @@ Returns internal dialect instance
public **fetchOne** (*mixed* $sqlQuery, [*mixed* $fetchMode], [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the first row in a SQL query result
+Returns the first row in a SQL query result
.. code-block:: php
fetchOne("SELECT * FROM robots");
print_r($robot);
-
- //Getting first robot with associative indexes only
- $robot = $connection->fetchOne("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+
+ // Getting first robot with associative indexes only
+ $robot = $connection->fetchOne("SELECT * FROM robots", \Phalcon\Db::FETCH_ASSOC);
print_r($robot);
@@ -320,25 +371,32 @@ Returns the first row in a SQL query result
public *array* **fetchAll** (*string* $sqlQuery, [*int* $fetchMode], [*array* $bindParams], [*array* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Dumps the complete result of a query into an array
+Dumps the complete result of a query into an array
.. code-block:: php
fetchAll("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+ // Getting all robots with associative indexes only
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots",
+ \Phalcon\Db::FETCH_ASSOC
+ );
+
foreach ($robots as $robot) {
- print_r($robot);
+ print_r($robot);
}
-
- //Getting all robots that contains word "robot" withing the name
- $robots = $connection->fetchAll("SELECT * FROM robots WHERE name LIKE :name",
- Phalcon\Db::FETCH_ASSOC,
- array('name' => '%robot%')
- );
- foreach($robots as $robot){
- print_r($robot);
+
+ // Getting all robots that contains word "robot" withing the name
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots WHERE name LIKE :name",
+ \Phalcon\Db::FETCH_ASSOC,
+ [
+ "name" => "%robot%",
+ ]
+ );
+ foreach($robots as $robot) {
+ print_r($robot);
}
@@ -346,18 +404,21 @@ Dumps the complete result of a query into an array
public *string* | ** **fetchColumn** (*string* $sqlQuery, [*array* $placeholders], [*int* | *string* $column]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the n'th field of first row in a SQL query result
+Returns the n'th field of first row in a SQL query result
.. code-block:: php
fetchColumn("SELECT count(*) FROM robots");
print_r($robotsCount);
-
- //Getting name of last edited robot
- $robot = $connection->fetchColumn("SELECT id, name FROM robots order by modified desc", 1);
+
+ // Getting name of last edited robot
+ $robot = $connection->fetchColumn(
+ "SELECT id, name FROM robots order by modified desc",
+ 1
+ );
print_r($robot);
@@ -365,79 +426,81 @@ Returns the n'th field of first row in a SQL query result
public *boolean* **insert** (*string* | *array* $table, *array* $values, [*array* $fields], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Inserts data into a table using custom RDBMS SQL syntax
+Inserts data into a table using custom RDBMS SQL syntax
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", 1952),
- array("name", "year")
- );
-
- // Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insert(
+ "robots",
+ ["Astro Boy", 1952],
+ ["name", "year"]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **insertAsDict** (*string* $table, *array* $data, [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Inserts data into a table using custom RBDM SQL syntax
+Inserts data into a table using custom RBDM SQL syntax
.. code-block:: php
insertAsDict(
- "robots",
- array(
- "name" => "Astro Boy",
- "year" => 1952
- )
- );
-
- //Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insertAsDict(
+ "robots",
+ [
+ "name" => "Astro Boy",
+ "year" => 1952,
+ ]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **update** (*string* | *array* $table, *array* $fields, *array* $values, [*string* | *array* $whereCondition], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Updates data on a table using custom RBDM SQL syntax
+Updates data on a table using custom RBDM SQL syntax
.. code-block:: php
update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
-
- //Updating existing robot with array condition and $dataTypes
- $success = $connection->update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- array(
- 'conditions' => "id = ?",
- 'bind' => array($some_unsafe_id),
- 'bindTypes' => array(PDO::PARAM_INT) //use only if you use $dataTypes param
- ),
- array(PDO::PARAM_STR)
- );
+ // Updating existing robot
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+
+ // Updating existing robot with array condition and $dataTypes
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ [
+ "conditions" => "id = ?",
+ "bind" => [$some_unsafe_id],
+ "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param
+ ],
+ [
+ PDO::PARAM_STR
+ ]
+ );
Warning! If $whereCondition is string it not escaped.
@@ -445,43 +508,66 @@ Warning! If $whereCondition is string it not escaped.
public *boolean* **updateAsDict** (*string* $table, *array* $data, [*string* $whereCondition], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Updates data on a table using custom RBDM SQL syntax Another, more convenient syntax
+Updates data on a table using custom RBDM SQL syntax
+Another, more convenient syntax
.. code-block:: php
updateAsDict(
- "robots",
- array(
- "name" => "New Astro Boy"
- ),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+ // Updating existing robot
+ $success = $connection->updateAsDict(
+ "robots",
+ [
+ "name" => "New Astro Boy",
+ ],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
public *boolean* **delete** (*string* | *array* $table, [*string* $whereCondition], [*array* $placeholders], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Deletes data from a table using custom RBDM SQL syntax
+Deletes data from a table using custom RBDM SQL syntax
+
+.. code-block:: php
+
+ delete(
+ "robots",
+ "id = 101"
+ );
+
+ // Next SQL sentence is generated
+ DELETE FROM `robots` WHERE `id` = 101
+
+
+
+
+public **escapeIdentifier** (*array* | *string* $identifier) inherited from :doc:`Phalcon\\Db\\Adapter `
+
+Escapes a column/table/schema name
.. code-block:: php
delete(
- "robots",
- "id = 101"
- );
-
- //Next SQL sentence is generated
- DELETE FROM `robots` WHERE `id` = 101
+ $escapedTable = $connection->escapeIdentifier(
+ "robots"
+ );
+
+ $escapedTable = $connection->escapeIdentifier(
+ [
+ "store",
+ "robots",
+ ]
+ );
@@ -494,39 +580,43 @@ Gets a list of columns
public **limit** (*mixed* $sqlQuery, *mixed* $number) inherited from :doc:`Phalcon\\Db\\Adapter `
-Appends a LIMIT clause to $sqlQuery argument
+Appends a LIMIT clause to $sqlQuery argument
.. code-block:: php
limit("SELECT * FROM robots", 5);
+ echo $connection->limit("SELECT * FROM robots", 5);
public **tableExists** (*mixed* $tableName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Generates SQL checking for the existence of a schema.table
+Generates SQL checking for the existence of a schema.table
.. code-block:: php
tableExists("blog", "posts"));
+ var_dump(
+ $connection->tableExists("blog", "posts")
+ );
public **viewExists** (*mixed* $viewName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Generates SQL checking for the existence of a schema.view
+Generates SQL checking for the existence of a schema.view
.. code-block:: php
viewExists("active_users", "posts"));
+ var_dump(
+ $connection->viewExists("active_users", "posts")
+ );
@@ -629,65 +719,75 @@ Returns the SQL column definition from a column
public **listTables** ([*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-List all tables on a database
+List all tables on a database
.. code-block:: php
listTables("blog"));
+ print_r(
+ $connection->listTables("blog")
+ );
public **listViews** ([*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-List all views on a database
+List all views on a database
.. code-block:: php
listViews("blog"));
+ print_r(
+ $connection->listViews("blog")
+ );
public :doc:`Phalcon\\Db\\Index `\ [] **describeIndexes** (*string* $table, [*string* $schema]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Lists table indexes
+Lists table indexes
.. code-block:: php
describeIndexes('robots_parts'));
+ print_r(
+ $connection->describeIndexes("robots_parts")
+ );
public **describeReferences** (*mixed* $table, [*mixed* $schema]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Lists table references
+Lists table references
.. code-block:: php
describeReferences('robots_parts'));
+ print_r(
+ $connection->describeReferences("robots_parts")
+ );
public **tableOptions** (*mixed* $tableName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Gets creation options from a table
+Gets creation options from a table
.. code-block:: php
tableOptions('robots'));
+ print_r(
+ $connection->tableOptions("robots")
+ );
@@ -730,36 +830,50 @@ Returns the savepoint name to use for nested transactions
public **getDefaultIdValue** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the default identity value to be inserted in an identity column
+Returns the default identity value to be inserted in an identity column
.. code-block:: php
insert(
- "robots",
- array($connection->getDefaultIdValue(), "Astro Boy", 1952),
- array("id", "name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'id'
+ $success = $connection->insert(
+ "robots",
+ [
+ $connection->getDefaultIdValue(),
+ "Astro Boy",
+ 1952,
+ ],
+ [
+ "id",
+ "name",
+ "year",
+ ]
+ );
public **getDefaultValue** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the default value to make the RBDM use the default value declared in the table definition
+Returns the default value to make the RBDM use the default value declared in the table definition
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", $connection->getDefaultValue()),
- array("name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'year'
+ $success = $connection->insert(
+ "robots",
+ [
+ "Astro Boy",
+ $connection->getDefaultValue()
+ ],
+ [
+ "name",
+ "year",
+ ]
+ );
@@ -796,7 +910,7 @@ Active SQL statement in the object
public **getRealSQLStatement** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Active SQL statement in the object without replace bound paramters
+Active SQL statement in the object without replace bound parameters
@@ -806,3 +920,8 @@ Active SQL statement in the object
+abstract public **describeColumns** (*mixed* $table, [*mixed* $schema]) inherited from :doc:`Phalcon\\Db\\AdapterInterface `
+
+...
+
+
diff --git a/en/api/Phalcon_Db_Adapter_Pdo_Mysql.rst b/en/api/Phalcon_Db_Adapter_Pdo_Mysql.rst
index fcbf407d0423..46195b1392df 100644
--- a/en/api/Phalcon_Db_Adapter_Pdo_Mysql.rst
+++ b/en/api/Phalcon_Db_Adapter_Pdo_Mysql.rst
@@ -3,91 +3,77 @@ Class **Phalcon\\Db\\Adapter\\Pdo\\Mysql**
*extends* abstract class :doc:`Phalcon\\Db\\Adapter\\Pdo `
-*implements* :doc:`Phalcon\\Events\\EventsAwareInterface `, :doc:`Phalcon\\Db\\AdapterInterface `
+*implements* :doc:`Phalcon\\Db\\AdapterInterface `, :doc:`Phalcon\\Events\\EventsAwareInterface `
.. role:: raw-html(raw)
:format: html
:raw-html:`Source on GitHub`
-Specific functions for the Mysql database system
+Specific functions for the Mysql database system
.. code-block:: php
'localhost',
- 'dbname' => 'blog',
- 'port' => 3306,
- 'username' => 'sigma',
- 'password' => 'secret'
- ];
-
- $connection = new Mysql($config);
+ use Phalcon\Db\Adapter\Pdo\Mysql;
+ $config = [
+ "host" => "localhost",
+ "dbname" => "blog",
+ "port" => 3306,
+ "username" => "sigma",
+ "password" => "secret",
+ ];
-
-Methods
--------
-
-public **escapeIdentifier** (*mixed* $identifier)
-
-Escapes a column/table/schema name
-
-.. code-block:: php
-
- escapeIdentifier('my_table'); // `my_table`
- echo $connection->escapeIdentifier(['companies', 'name']); // `companies`.`name`
-
-.. code-block:: php
-
- describeColumns("posts"));
+ print_r(
+ $connection->describeColumns("posts")
+ );
public :doc:`Phalcon\\Db\\IndexInterface `\ [] **describeIndexes** (*string* $table, [*string* $schema])
-Lists table indexes
+Lists table indexes
.. code-block:: php
describeIndexes('robots_parts'));
+ print_r(
+ $connection->describeIndexes("robots_parts")
+ );
public **describeReferences** (*mixed* $table, [*mixed* $schema])
-Lists table references
+Lists table references
.. code-block:: php
describeReferences('robots_parts'));
+ print_r(
+ $connection->describeReferences("robots_parts")
+ );
@@ -100,154 +86,215 @@ Constructor for Phalcon\\Db\\Adapter\\Pdo
public **connect** ([*array* $descriptor]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-This method is automatically called in \\Phalcon\\Db\\Adapter\\Pdo constructor. Call it when you need to restore a database connection.
+This method is automatically called in \\Phalcon\\Db\\Adapter\\Pdo constructor.
+Call it when you need to restore a database connection.
.. code-block:: php
'localhost',
- 'username' => 'sigma',
- 'password' => 'secret',
- 'dbname' => 'blog',
- 'port' => 3306,
- ]);
-
- // Reconnect
- $connection->connect();
+ use Phalcon\Db\Adapter\Pdo\Mysql;
+
+ // Make a connection
+ $connection = new Mysql(
+ [
+ "host" => "localhost",
+ "username" => "sigma",
+ "password" => "secret",
+ "dbname" => "blog",
+ "port" => 3306,
+ ]
+ );
+
+ // Reconnect
+ $connection->connect();
public **prepare** (*mixed* $sqlStatement) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Returns a PDO prepared statement to be executed with 'executePrepared'
+Returns a PDO prepared statement to be executed with 'executePrepared'
.. code-block:: php
prepare('SELECT * FROM robots WHERE name = :name');
- $result = $connection->executePrepared($statement, ['name' => 'Voltron'], ['name' => Column::BIND_PARAM_INT]);
+ use Phalcon\Db\Column;
+
+ $statement = $db->prepare(
+ "SELECT * FROM robots WHERE name = :name"
+ );
+
+ $result = $connection->executePrepared(
+ $statement,
+ [
+ "name" => "Voltron",
+ ],
+ [
+ "name" => Column::BIND_PARAM_INT,
+ ]
+ );
public `PDOStatement `_ **executePrepared** (`PDOStatement `_ $statement, *array* $placeholders, *array* $dataTypes) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Executes a prepared statement binding. This function uses integer indexes starting from zero
+Executes a prepared statement binding. This function uses integer indexes starting from zero
.. code-block:: php
prepare('SELECT * FROM robots WHERE name = :name');
- $result = $connection->executePrepared($statement, ['name' => 'Voltron'], ['name' => Column::BIND_PARAM_INT]);
+ use Phalcon\Db\Column;
+
+ $statement = $db->prepare(
+ "SELECT * FROM robots WHERE name = :name"
+ );
+
+ $result = $connection->executePrepared(
+ $statement,
+ [
+ "name" => "Voltron",
+ ],
+ [
+ "name" => Column::BIND_PARAM_INT,
+ ]
+ );
public **query** (*mixed* $sqlStatement, [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server is returning rows
+Sends SQL statements to the database server returning the success state.
+Use this method only when the SQL statement sent to the server is returning rows
.. code-block:: php
query("SELECT * FROM robots WHERE type='mechanical'");
- $resultset = $connection->query("SELECT * FROM robots WHERE type=?", array("mechanical"));
+ // Querying data
+ $resultset = $connection->query(
+ "SELECT * FROM robots WHERE type = 'mechanical'"
+ );
+
+ $resultset = $connection->query(
+ "SELECT * FROM robots WHERE type = ?",
+ [
+ "mechanical",
+ ]
+ );
public **execute** (*mixed* $sqlStatement, [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server doesn't return any rows
+Sends SQL statements to the database server returning the success state.
+Use this method only when the SQL statement sent to the server doesn't return any rows
.. code-block:: php
execute("INSERT INTO robots VALUES (1, 'Astro Boy')");
- $success = $connection->execute("INSERT INTO robots VALUES (?, ?)", array(1, 'Astro Boy'));
+ // Inserting data
+ $success = $connection->execute(
+ "INSERT INTO robots VALUES (1, 'Astro Boy')"
+ );
+
+ $success = $connection->execute(
+ "INSERT INTO robots VALUES (?, ?)",
+ [
+ 1,
+ "Astro Boy",
+ ]
+ );
public **affectedRows** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Returns the number of affected rows by the lastest INSERT/UPDATE/DELETE executed in the database system
+Returns the number of affected rows by the latest INSERT/UPDATE/DELETE executed in the database system
.. code-block:: php
execute("DELETE FROM robots");
- echo $connection->affectedRows(), ' were deleted';
+ $connection->execute(
+ "DELETE FROM robots"
+ );
+
+ echo $connection->affectedRows(), " were deleted";
public **close** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Closes the active connection returning success. Phalcon automatically closes and destroys active connections when the request ends
+Closes the active connection returning success. Phalcon automatically closes and destroys
+active connections when the request ends
public **escapeString** (*mixed* $str) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Escapes a value to avoid SQL injections according to the active charset in the connection
+Escapes a value to avoid SQL injections according to the active charset in the connection
.. code-block:: php
escapeString('some dangerous value');
+ $escapedStr = $connection->escapeString("some dangerous value");
public **convertBoundParams** (*mixed* $sql, [*array* $params]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Converts bound parameters such as :name: or ?1 into PDO bind params ?
+Converts bound parameters such as :name: or ?1 into PDO bind params ?
.. code-block:: php
convertBoundParams('SELECT * FROM robots WHERE name = :name:', array('Bender')));
+ print_r(
+ $connection->convertBoundParams(
+ "SELECT * FROM robots WHERE name = :name:",
+ [
+ "Bender",
+ ]
+ )
+ );
public *int* | *boolean* **lastInsertId** ([*string* $sequenceName]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Returns the insert id for the auto_increment/serial column inserted in the lastest executed SQL statement
+Returns the insert id for the auto_increment/serial column inserted in the latest executed SQL statement
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", 1952),
- array("name", "year")
- );
-
- //Getting the generated id
- $id = $connection->lastInsertId();
+ // Inserting a new robot
+ $success = $connection->insert(
+ "robots",
+ [
+ "Astro Boy",
+ 1952,
+ ],
+ [
+ "name",
+ "year",
+ ]
+ );
+
+ // Getting the generated id
+ $id = $connection->lastInsertId();
@@ -278,14 +325,18 @@ Returns the current transaction nesting level
public **isUnderTransaction** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Checks whether the connection is under a transaction
+Checks whether the connection is under a transaction
.. code-block:: php
begin();
- var_dump($connection->isUnderTransaction()); //true
+
+ // true
+ var_dump(
+ $connection->isUnderTransaction()
+ );
@@ -346,18 +397,18 @@ Returns internal dialect instance
public **fetchOne** (*mixed* $sqlQuery, [*mixed* $fetchMode], [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the first row in a SQL query result
+Returns the first row in a SQL query result
.. code-block:: php
fetchOne("SELECT * FROM robots");
print_r($robot);
-
- //Getting first robot with associative indexes only
- $robot = $connection->fetchOne("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+
+ // Getting first robot with associative indexes only
+ $robot = $connection->fetchOne("SELECT * FROM robots", \Phalcon\Db::FETCH_ASSOC);
print_r($robot);
@@ -365,25 +416,32 @@ Returns the first row in a SQL query result
public *array* **fetchAll** (*string* $sqlQuery, [*int* $fetchMode], [*array* $bindParams], [*array* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Dumps the complete result of a query into an array
+Dumps the complete result of a query into an array
.. code-block:: php
fetchAll("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+ // Getting all robots with associative indexes only
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots",
+ \Phalcon\Db::FETCH_ASSOC
+ );
+
foreach ($robots as $robot) {
- print_r($robot);
+ print_r($robot);
}
-
- //Getting all robots that contains word "robot" withing the name
- $robots = $connection->fetchAll("SELECT * FROM robots WHERE name LIKE :name",
- Phalcon\Db::FETCH_ASSOC,
- array('name' => '%robot%')
- );
- foreach($robots as $robot){
- print_r($robot);
+
+ // Getting all robots that contains word "robot" withing the name
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots WHERE name LIKE :name",
+ \Phalcon\Db::FETCH_ASSOC,
+ [
+ "name" => "%robot%",
+ ]
+ );
+ foreach($robots as $robot) {
+ print_r($robot);
}
@@ -391,18 +449,21 @@ Dumps the complete result of a query into an array
public *string* | ** **fetchColumn** (*string* $sqlQuery, [*array* $placeholders], [*int* | *string* $column]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the n'th field of first row in a SQL query result
+Returns the n'th field of first row in a SQL query result
.. code-block:: php
fetchColumn("SELECT count(*) FROM robots");
print_r($robotsCount);
-
- //Getting name of last edited robot
- $robot = $connection->fetchColumn("SELECT id, name FROM robots order by modified desc", 1);
+
+ // Getting name of last edited robot
+ $robot = $connection->fetchColumn(
+ "SELECT id, name FROM robots order by modified desc",
+ 1
+ );
print_r($robot);
@@ -410,79 +471,81 @@ Returns the n'th field of first row in a SQL query result
public *boolean* **insert** (*string* | *array* $table, *array* $values, [*array* $fields], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Inserts data into a table using custom RDBMS SQL syntax
+Inserts data into a table using custom RDBMS SQL syntax
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", 1952),
- array("name", "year")
- );
-
- // Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insert(
+ "robots",
+ ["Astro Boy", 1952],
+ ["name", "year"]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **insertAsDict** (*string* $table, *array* $data, [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Inserts data into a table using custom RBDM SQL syntax
+Inserts data into a table using custom RBDM SQL syntax
.. code-block:: php
insertAsDict(
- "robots",
- array(
- "name" => "Astro Boy",
- "year" => 1952
- )
- );
-
- //Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insertAsDict(
+ "robots",
+ [
+ "name" => "Astro Boy",
+ "year" => 1952,
+ ]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **update** (*string* | *array* $table, *array* $fields, *array* $values, [*string* | *array* $whereCondition], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Updates data on a table using custom RBDM SQL syntax
+Updates data on a table using custom RBDM SQL syntax
.. code-block:: php
update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
-
- //Updating existing robot with array condition and $dataTypes
- $success = $connection->update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- array(
- 'conditions' => "id = ?",
- 'bind' => array($some_unsafe_id),
- 'bindTypes' => array(PDO::PARAM_INT) //use only if you use $dataTypes param
- ),
- array(PDO::PARAM_STR)
- );
+ // Updating existing robot
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+
+ // Updating existing robot with array condition and $dataTypes
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ [
+ "conditions" => "id = ?",
+ "bind" => [$some_unsafe_id],
+ "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param
+ ],
+ [
+ PDO::PARAM_STR
+ ]
+ );
Warning! If $whereCondition is string it not escaped.
@@ -490,43 +553,66 @@ Warning! If $whereCondition is string it not escaped.
public *boolean* **updateAsDict** (*string* $table, *array* $data, [*string* $whereCondition], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Updates data on a table using custom RBDM SQL syntax Another, more convenient syntax
+Updates data on a table using custom RBDM SQL syntax
+Another, more convenient syntax
.. code-block:: php
updateAsDict(
- "robots",
- array(
- "name" => "New Astro Boy"
- ),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+ // Updating existing robot
+ $success = $connection->updateAsDict(
+ "robots",
+ [
+ "name" => "New Astro Boy",
+ ],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
public *boolean* **delete** (*string* | *array* $table, [*string* $whereCondition], [*array* $placeholders], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Deletes data from a table using custom RBDM SQL syntax
+Deletes data from a table using custom RBDM SQL syntax
.. code-block:: php
delete(
- "robots",
- "id = 101"
- );
-
- //Next SQL sentence is generated
- DELETE FROM `robots` WHERE `id` = 101
+ // Deleting existing robot
+ $success = $connection->delete(
+ "robots",
+ "id = 101"
+ );
+
+ // Next SQL sentence is generated
+ DELETE FROM `robots` WHERE `id` = 101
+
+
+
+
+public **escapeIdentifier** (*array* | *string* $identifier) inherited from :doc:`Phalcon\\Db\\Adapter `
+
+Escapes a column/table/schema name
+
+.. code-block:: php
+
+ escapeIdentifier(
+ "robots"
+ );
+
+ $escapedTable = $connection->escapeIdentifier(
+ [
+ "store",
+ "robots",
+ ]
+ );
@@ -539,39 +625,43 @@ Gets a list of columns
public **limit** (*mixed* $sqlQuery, *mixed* $number) inherited from :doc:`Phalcon\\Db\\Adapter `
-Appends a LIMIT clause to $sqlQuery argument
+Appends a LIMIT clause to $sqlQuery argument
.. code-block:: php
limit("SELECT * FROM robots", 5);
+ echo $connection->limit("SELECT * FROM robots", 5);
public **tableExists** (*mixed* $tableName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Generates SQL checking for the existence of a schema.table
+Generates SQL checking for the existence of a schema.table
.. code-block:: php
tableExists("blog", "posts"));
+ var_dump(
+ $connection->tableExists("blog", "posts")
+ );
public **viewExists** (*mixed* $viewName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Generates SQL checking for the existence of a schema.view
+Generates SQL checking for the existence of a schema.view
.. code-block:: php
viewExists("active_users", "posts"));
+ var_dump(
+ $connection->viewExists("active_users", "posts")
+ );
@@ -674,39 +764,45 @@ Returns the SQL column definition from a column
public **listTables** ([*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-List all tables on a database
+List all tables on a database
.. code-block:: php
listTables("blog"));
+ print_r(
+ $connection->listTables("blog")
+ );
public **listViews** ([*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-List all views on a database
+List all views on a database
.. code-block:: php
listViews("blog"));
+ print_r(
+ $connection->listViews("blog")
+ );
public **tableOptions** (*mixed* $tableName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Gets creation options from a table
+Gets creation options from a table
.. code-block:: php
tableOptions('robots'));
+ print_r(
+ $connection->tableOptions("robots")
+ );
@@ -749,36 +845,50 @@ Returns the savepoint name to use for nested transactions
public **getDefaultIdValue** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the default identity value to be inserted in an identity column
+Returns the default identity value to be inserted in an identity column
.. code-block:: php
insert(
- "robots",
- array($connection->getDefaultIdValue(), "Astro Boy", 1952),
- array("id", "name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'id'
+ $success = $connection->insert(
+ "robots",
+ [
+ $connection->getDefaultIdValue(),
+ "Astro Boy",
+ 1952,
+ ],
+ [
+ "id",
+ "name",
+ "year",
+ ]
+ );
public **getDefaultValue** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the default value to make the RBDM use the default value declared in the table definition
+Returns the default value to make the RBDM use the default value declared in the table definition
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", $connection->getDefaultValue()),
- array("name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'year'
+ $success = $connection->insert(
+ "robots",
+ [
+ "Astro Boy",
+ $connection->getDefaultValue()
+ ],
+ [
+ "name",
+ "year",
+ ]
+ );
@@ -815,7 +925,7 @@ Active SQL statement in the object
public **getRealSQLStatement** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Active SQL statement in the object without replace bound paramters
+Active SQL statement in the object without replace bound parameters
diff --git a/en/api/Phalcon_Db_Adapter_Pdo_Postgresql.rst b/en/api/Phalcon_Db_Adapter_Pdo_Postgresql.rst
index 74386b53650b..cbdecf79c1bf 100644
--- a/en/api/Phalcon_Db_Adapter_Pdo_Postgresql.rst
+++ b/en/api/Phalcon_Db_Adapter_Pdo_Postgresql.rst
@@ -3,30 +3,30 @@ Class **Phalcon\\Db\\Adapter\\Pdo\\Postgresql**
*extends* abstract class :doc:`Phalcon\\Db\\Adapter\\Pdo `
-*implements* :doc:`Phalcon\\Events\\EventsAwareInterface `, :doc:`Phalcon\\Db\\AdapterInterface `
+*implements* :doc:`Phalcon\\Db\\AdapterInterface `, :doc:`Phalcon\\Events\\EventsAwareInterface `
.. role:: raw-html(raw)
:format: html
:raw-html:`Source on GitHub`
-Specific functions for the Postgresql database system
+Specific functions for the Postgresql database system
.. code-block:: php
'localhost',
- 'dbname' => 'blog',
- 'port' => 5432,
- 'username' => 'postgres',
- 'password' => 'secret'
- ];
-
- $connection = new Postgresql($config);
+ use Phalcon\Db\Adapter\Pdo\Postgresql;
+
+ $config = [
+ "host" => "localhost",
+ "dbname" => "blog",
+ "port" => 5432,
+ "username" => "postgres",
+ "password" => "secret",
+ ];
+
+ $connection = new Postgresql($config);
@@ -35,19 +35,22 @@ Methods
public **connect** ([*array* $descriptor])
-This method is automatically called in Phalcon\\Db\\Adapter\\Pdo constructor. Call it when you need to restore a database connection.
+This method is automatically called in Phalcon\\Db\\Adapter\\Pdo constructor.
+Call it when you need to restore a database connection.
public **describeColumns** (*mixed* $table, [*mixed* $schema])
-Returns an array of Phalcon\\Db\\Column objects describing a table
+Returns an array of Phalcon\\Db\\Column objects describing a table
.. code-block:: php
describeColumns("posts"));
+ print_r(
+ $connection->describeColumns("posts")
+ );
@@ -72,18 +75,26 @@ Check whether the database system requires an explicit value for identity column
public **getDefaultIdValue** ()
-Returns the default identity value to be inserted in an identity column
+Returns the default identity value to be inserted in an identity column
.. code-block:: php
insert(
- "robots",
- array($connection->getDefaultIdValue(), "Astro Boy", 1952),
- array("id", "name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'id'
+ $success = $connection->insert(
+ "robots",
+ [
+ $connection->getDefaultIdValue(),
+ "Astro Boy",
+ 1952,
+ ],
+ [
+ "id",
+ "name",
+ "year",
+ ]
+ );
@@ -102,143 +113,187 @@ Constructor for Phalcon\\Db\\Adapter\\Pdo
public **prepare** (*mixed* $sqlStatement) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Returns a PDO prepared statement to be executed with 'executePrepared'
+Returns a PDO prepared statement to be executed with 'executePrepared'
.. code-block:: php
prepare('SELECT * FROM robots WHERE name = :name');
- $result = $connection->executePrepared($statement, ['name' => 'Voltron'], ['name' => Column::BIND_PARAM_INT]);
+ use Phalcon\Db\Column;
+
+ $statement = $db->prepare(
+ "SELECT * FROM robots WHERE name = :name"
+ );
+
+ $result = $connection->executePrepared(
+ $statement,
+ [
+ "name" => "Voltron",
+ ],
+ [
+ "name" => Column::BIND_PARAM_INT,
+ ]
+ );
public `PDOStatement `_ **executePrepared** (`PDOStatement `_ $statement, *array* $placeholders, *array* $dataTypes) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Executes a prepared statement binding. This function uses integer indexes starting from zero
+Executes a prepared statement binding. This function uses integer indexes starting from zero
.. code-block:: php
prepare('SELECT * FROM robots WHERE name = :name');
- $result = $connection->executePrepared($statement, ['name' => 'Voltron'], ['name' => Column::BIND_PARAM_INT]);
+ use Phalcon\Db\Column;
+
+ $statement = $db->prepare(
+ "SELECT * FROM robots WHERE name = :name"
+ );
+
+ $result = $connection->executePrepared(
+ $statement,
+ [
+ "name" => "Voltron",
+ ],
+ [
+ "name" => Column::BIND_PARAM_INT,
+ ]
+ );
public **query** (*mixed* $sqlStatement, [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server is returning rows
+Sends SQL statements to the database server returning the success state.
+Use this method only when the SQL statement sent to the server is returning rows
.. code-block:: php
query("SELECT * FROM robots WHERE type='mechanical'");
- $resultset = $connection->query("SELECT * FROM robots WHERE type=?", array("mechanical"));
+ // Querying data
+ $resultset = $connection->query(
+ "SELECT * FROM robots WHERE type = 'mechanical'"
+ );
+
+ $resultset = $connection->query(
+ "SELECT * FROM robots WHERE type = ?",
+ [
+ "mechanical",
+ ]
+ );
public **execute** (*mixed* $sqlStatement, [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server doesn't return any rows
+Sends SQL statements to the database server returning the success state.
+Use this method only when the SQL statement sent to the server doesn't return any rows
.. code-block:: php
execute("INSERT INTO robots VALUES (1, 'Astro Boy')");
- $success = $connection->execute("INSERT INTO robots VALUES (?, ?)", array(1, 'Astro Boy'));
+ // Inserting data
+ $success = $connection->execute(
+ "INSERT INTO robots VALUES (1, 'Astro Boy')"
+ );
+
+ $success = $connection->execute(
+ "INSERT INTO robots VALUES (?, ?)",
+ [
+ 1,
+ "Astro Boy",
+ ]
+ );
public **affectedRows** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Returns the number of affected rows by the lastest INSERT/UPDATE/DELETE executed in the database system
+Returns the number of affected rows by the latest INSERT/UPDATE/DELETE executed in the database system
.. code-block:: php
execute("DELETE FROM robots");
- echo $connection->affectedRows(), ' were deleted';
-
-
+ $connection->execute(
+ "DELETE FROM robots"
+ );
+ echo $connection->affectedRows(), " were deleted";
-public **close** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-
-Closes the active connection returning success. Phalcon automatically closes and destroys active connections when the request ends
-
-
-
-public *string* **escapeIdentifier** (*string* $identifier) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Escapes a column/table/schema name
-.. code-block:: php
-
- escapeIdentifier('robots');
- $escapedTable = $connection->escapeIdentifier(['store', 'robots']);
+public **close** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
+Closes the active connection returning success. Phalcon automatically closes and destroys
+active connections when the request ends
public **escapeString** (*mixed* $str) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Escapes a value to avoid SQL injections according to the active charset in the connection
+Escapes a value to avoid SQL injections according to the active charset in the connection
.. code-block:: php
escapeString('some dangerous value');
+ $escapedStr = $connection->escapeString("some dangerous value");
public **convertBoundParams** (*mixed* $sql, [*array* $params]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Converts bound parameters such as :name: or ?1 into PDO bind params ?
+Converts bound parameters such as :name: or ?1 into PDO bind params ?
.. code-block:: php
convertBoundParams('SELECT * FROM robots WHERE name = :name:', array('Bender')));
+ print_r(
+ $connection->convertBoundParams(
+ "SELECT * FROM robots WHERE name = :name:",
+ [
+ "Bender",
+ ]
+ )
+ );
public *int* | *boolean* **lastInsertId** ([*string* $sequenceName]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Returns the insert id for the auto_increment/serial column inserted in the lastest executed SQL statement
+Returns the insert id for the auto_increment/serial column inserted in the latest executed SQL statement
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", 1952),
- array("name", "year")
- );
-
- //Getting the generated id
- $id = $connection->lastInsertId();
+ // Inserting a new robot
+ $success = $connection->insert(
+ "robots",
+ [
+ "Astro Boy",
+ 1952,
+ ],
+ [
+ "name",
+ "year",
+ ]
+ );
+
+ // Getting the generated id
+ $id = $connection->lastInsertId();
@@ -269,14 +324,18 @@ Returns the current transaction nesting level
public **isUnderTransaction** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Checks whether the connection is under a transaction
+Checks whether the connection is under a transaction
.. code-block:: php
begin();
- var_dump($connection->isUnderTransaction()); //true
+
+ // true
+ var_dump(
+ $connection->isUnderTransaction()
+ );
@@ -337,18 +396,18 @@ Returns internal dialect instance
public **fetchOne** (*mixed* $sqlQuery, [*mixed* $fetchMode], [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the first row in a SQL query result
+Returns the first row in a SQL query result
.. code-block:: php
fetchOne("SELECT * FROM robots");
print_r($robot);
-
- //Getting first robot with associative indexes only
- $robot = $connection->fetchOne("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+
+ // Getting first robot with associative indexes only
+ $robot = $connection->fetchOne("SELECT * FROM robots", \Phalcon\Db::FETCH_ASSOC);
print_r($robot);
@@ -356,25 +415,32 @@ Returns the first row in a SQL query result
public *array* **fetchAll** (*string* $sqlQuery, [*int* $fetchMode], [*array* $bindParams], [*array* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Dumps the complete result of a query into an array
+Dumps the complete result of a query into an array
.. code-block:: php
fetchAll("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+ // Getting all robots with associative indexes only
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots",
+ \Phalcon\Db::FETCH_ASSOC
+ );
+
foreach ($robots as $robot) {
- print_r($robot);
+ print_r($robot);
}
-
- //Getting all robots that contains word "robot" withing the name
- $robots = $connection->fetchAll("SELECT * FROM robots WHERE name LIKE :name",
- Phalcon\Db::FETCH_ASSOC,
- array('name' => '%robot%')
- );
- foreach($robots as $robot){
- print_r($robot);
+
+ // Getting all robots that contains word "robot" withing the name
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots WHERE name LIKE :name",
+ \Phalcon\Db::FETCH_ASSOC,
+ [
+ "name" => "%robot%",
+ ]
+ );
+ foreach($robots as $robot) {
+ print_r($robot);
}
@@ -382,18 +448,21 @@ Dumps the complete result of a query into an array
public *string* | ** **fetchColumn** (*string* $sqlQuery, [*array* $placeholders], [*int* | *string* $column]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the n'th field of first row in a SQL query result
+Returns the n'th field of first row in a SQL query result
.. code-block:: php
fetchColumn("SELECT count(*) FROM robots");
print_r($robotsCount);
-
- //Getting name of last edited robot
- $robot = $connection->fetchColumn("SELECT id, name FROM robots order by modified desc", 1);
+
+ // Getting name of last edited robot
+ $robot = $connection->fetchColumn(
+ "SELECT id, name FROM robots order by modified desc",
+ 1
+ );
print_r($robot);
@@ -401,79 +470,81 @@ Returns the n'th field of first row in a SQL query result
public *boolean* **insert** (*string* | *array* $table, *array* $values, [*array* $fields], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Inserts data into a table using custom RDBMS SQL syntax
+Inserts data into a table using custom RDBMS SQL syntax
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", 1952),
- array("name", "year")
- );
-
- // Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insert(
+ "robots",
+ ["Astro Boy", 1952],
+ ["name", "year"]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **insertAsDict** (*string* $table, *array* $data, [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Inserts data into a table using custom RBDM SQL syntax
+Inserts data into a table using custom RBDM SQL syntax
.. code-block:: php
insertAsDict(
- "robots",
- array(
- "name" => "Astro Boy",
- "year" => 1952
- )
- );
-
- //Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insertAsDict(
+ "robots",
+ [
+ "name" => "Astro Boy",
+ "year" => 1952,
+ ]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **update** (*string* | *array* $table, *array* $fields, *array* $values, [*string* | *array* $whereCondition], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Updates data on a table using custom RBDM SQL syntax
+Updates data on a table using custom RBDM SQL syntax
.. code-block:: php
update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
-
- //Updating existing robot with array condition and $dataTypes
- $success = $connection->update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- array(
- 'conditions' => "id = ?",
- 'bind' => array($some_unsafe_id),
- 'bindTypes' => array(PDO::PARAM_INT) //use only if you use $dataTypes param
- ),
- array(PDO::PARAM_STR)
- );
+ // Updating existing robot
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+
+ // Updating existing robot with array condition and $dataTypes
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ [
+ "conditions" => "id = ?",
+ "bind" => [$some_unsafe_id],
+ "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param
+ ],
+ [
+ PDO::PARAM_STR
+ ]
+ );
Warning! If $whereCondition is string it not escaped.
@@ -481,43 +552,66 @@ Warning! If $whereCondition is string it not escaped.
public *boolean* **updateAsDict** (*string* $table, *array* $data, [*string* $whereCondition], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Updates data on a table using custom RBDM SQL syntax Another, more convenient syntax
+Updates data on a table using custom RBDM SQL syntax
+Another, more convenient syntax
.. code-block:: php
updateAsDict(
- "robots",
- array(
- "name" => "New Astro Boy"
- ),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+ // Updating existing robot
+ $success = $connection->updateAsDict(
+ "robots",
+ [
+ "name" => "New Astro Boy",
+ ],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
public *boolean* **delete** (*string* | *array* $table, [*string* $whereCondition], [*array* $placeholders], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Deletes data from a table using custom RBDM SQL syntax
+Deletes data from a table using custom RBDM SQL syntax
+
+.. code-block:: php
+
+ delete(
+ "robots",
+ "id = 101"
+ );
+
+ // Next SQL sentence is generated
+ DELETE FROM `robots` WHERE `id` = 101
+
+
+
+
+public **escapeIdentifier** (*array* | *string* $identifier) inherited from :doc:`Phalcon\\Db\\Adapter `
+
+Escapes a column/table/schema name
.. code-block:: php
delete(
- "robots",
- "id = 101"
- );
-
- //Next SQL sentence is generated
- DELETE FROM `robots` WHERE `id` = 101
+ $escapedTable = $connection->escapeIdentifier(
+ "robots"
+ );
+
+ $escapedTable = $connection->escapeIdentifier(
+ [
+ "store",
+ "robots",
+ ]
+ );
@@ -530,39 +624,43 @@ Gets a list of columns
public **limit** (*mixed* $sqlQuery, *mixed* $number) inherited from :doc:`Phalcon\\Db\\Adapter `
-Appends a LIMIT clause to $sqlQuery argument
+Appends a LIMIT clause to $sqlQuery argument
.. code-block:: php
limit("SELECT * FROM robots", 5);
+ echo $connection->limit("SELECT * FROM robots", 5);
public **tableExists** (*mixed* $tableName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Generates SQL checking for the existence of a schema.table
+Generates SQL checking for the existence of a schema.table
.. code-block:: php
tableExists("blog", "posts"));
+ var_dump(
+ $connection->tableExists("blog", "posts")
+ );
public **viewExists** (*mixed* $viewName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Generates SQL checking for the existence of a schema.view
+Generates SQL checking for the existence of a schema.view
.. code-block:: php
viewExists("active_users", "posts"));
+ var_dump(
+ $connection->viewExists("active_users", "posts")
+ );
@@ -653,65 +751,75 @@ Returns the SQL column definition from a column
public **listTables** ([*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-List all tables on a database
+List all tables on a database
.. code-block:: php
listTables("blog"));
+ print_r(
+ $connection->listTables("blog")
+ );
public **listViews** ([*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-List all views on a database
+List all views on a database
.. code-block:: php
listViews("blog"));
+ print_r(
+ $connection->listViews("blog")
+ );
public :doc:`Phalcon\\Db\\Index `\ [] **describeIndexes** (*string* $table, [*string* $schema]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Lists table indexes
+Lists table indexes
.. code-block:: php
describeIndexes('robots_parts'));
+ print_r(
+ $connection->describeIndexes("robots_parts")
+ );
public **describeReferences** (*mixed* $table, [*mixed* $schema]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Lists table references
+Lists table references
.. code-block:: php
describeReferences('robots_parts'));
+ print_r(
+ $connection->describeReferences("robots_parts")
+ );
public **tableOptions** (*mixed* $tableName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Gets creation options from a table
+Gets creation options from a table
.. code-block:: php
tableOptions('robots'));
+ print_r(
+ $connection->tableOptions("robots")
+ );
@@ -754,18 +862,24 @@ Returns the savepoint name to use for nested transactions
public **getDefaultValue** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the default value to make the RBDM use the default value declared in the table definition
+Returns the default value to make the RBDM use the default value declared in the table definition
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", $connection->getDefaultValue()),
- array("name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'year'
+ $success = $connection->insert(
+ "robots",
+ [
+ "Astro Boy",
+ $connection->getDefaultValue()
+ ],
+ [
+ "name",
+ "year",
+ ]
+ );
@@ -790,7 +904,7 @@ Active SQL statement in the object
public **getRealSQLStatement** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Active SQL statement in the object without replace bound paramters
+Active SQL statement in the object without replace bound parameters
diff --git a/en/api/Phalcon_Db_Adapter_Pdo_Sqlite.rst b/en/api/Phalcon_Db_Adapter_Pdo_Sqlite.rst
index 3e775356fe24..748da97dc14b 100644
--- a/en/api/Phalcon_Db_Adapter_Pdo_Sqlite.rst
+++ b/en/api/Phalcon_Db_Adapter_Pdo_Sqlite.rst
@@ -3,22 +3,26 @@ Class **Phalcon\\Db\\Adapter\\Pdo\\Sqlite**
*extends* abstract class :doc:`Phalcon\\Db\\Adapter\\Pdo `
-*implements* :doc:`Phalcon\\Events\\EventsAwareInterface `, :doc:`Phalcon\\Db\\AdapterInterface `
+*implements* :doc:`Phalcon\\Db\\AdapterInterface `, :doc:`Phalcon\\Events\\EventsAwareInterface `
.. role:: raw-html(raw)
:format: html
:raw-html:`Source on GitHub`
-Specific functions for the Sqlite database system
+Specific functions for the Sqlite database system
.. code-block:: php
'/tmp/test.sqlite']);
+ use Phalcon\Db\Adapter\Pdo\Sqlite;
+
+ $connection = new Sqlite(
+ [
+ "dbname" => "/tmp/test.sqlite",
+ ]
+ );
@@ -27,32 +31,37 @@ Methods
public **connect** ([*array* $descriptor])
-This method is automatically called in Phalcon\\Db\\Adapter\\Pdo constructor. Call it when you need to restore a database connection.
+This method is automatically called in Phalcon\\Db\\Adapter\\Pdo constructor.
+Call it when you need to restore a database connection.
public **describeColumns** (*mixed* $table, [*mixed* $schema])
-Returns an array of Phalcon\\Db\\Column objects describing a table
+Returns an array of Phalcon\\Db\\Column objects describing a table
.. code-block:: php
describeColumns("posts"));
+ print_r(
+ $connection->describeColumns("posts")
+ );
public :doc:`Phalcon\\Db\\IndexInterface `\ [] **describeIndexes** (*string* $table, [*string* $schema])
-Lists table indexes
+Lists table indexes
.. code-block:: php
describeIndexes('robots_parts'));
+ print_r(
+ $connection->describeIndexes("robots_parts")
+ );
@@ -71,18 +80,24 @@ Check whether the database system requires an explicit value for identity column
public **getDefaultValue** ()
-Returns the default value to make the RBDM use the default value declared in the table definition
+Returns the default value to make the RBDM use the default value declared in the table definition
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", $connection->getDefaultValue()),
- array("name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'year'
+ $success = $connection->insert(
+ "robots",
+ [
+ "Astro Boy",
+ $connection->getDefaultValue(),
+ ],
+ [
+ "name",
+ "year",
+ ]
+ );
@@ -95,143 +110,187 @@ Constructor for Phalcon\\Db\\Adapter\\Pdo
public **prepare** (*mixed* $sqlStatement) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Returns a PDO prepared statement to be executed with 'executePrepared'
+Returns a PDO prepared statement to be executed with 'executePrepared'
.. code-block:: php
prepare('SELECT * FROM robots WHERE name = :name');
- $result = $connection->executePrepared($statement, ['name' => 'Voltron'], ['name' => Column::BIND_PARAM_INT]);
+ use Phalcon\Db\Column;
+
+ $statement = $db->prepare(
+ "SELECT * FROM robots WHERE name = :name"
+ );
+
+ $result = $connection->executePrepared(
+ $statement,
+ [
+ "name" => "Voltron",
+ ],
+ [
+ "name" => Column::BIND_PARAM_INT,
+ ]
+ );
public `PDOStatement `_ **executePrepared** (`PDOStatement `_ $statement, *array* $placeholders, *array* $dataTypes) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Executes a prepared statement binding. This function uses integer indexes starting from zero
+Executes a prepared statement binding. This function uses integer indexes starting from zero
.. code-block:: php
prepare('SELECT * FROM robots WHERE name = :name');
- $result = $connection->executePrepared($statement, ['name' => 'Voltron'], ['name' => Column::BIND_PARAM_INT]);
+ use Phalcon\Db\Column;
+
+ $statement = $db->prepare(
+ "SELECT * FROM robots WHERE name = :name"
+ );
+
+ $result = $connection->executePrepared(
+ $statement,
+ [
+ "name" => "Voltron",
+ ],
+ [
+ "name" => Column::BIND_PARAM_INT,
+ ]
+ );
public **query** (*mixed* $sqlStatement, [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server is returning rows
+Sends SQL statements to the database server returning the success state.
+Use this method only when the SQL statement sent to the server is returning rows
.. code-block:: php
query("SELECT * FROM robots WHERE type='mechanical'");
- $resultset = $connection->query("SELECT * FROM robots WHERE type=?", array("mechanical"));
+ // Querying data
+ $resultset = $connection->query(
+ "SELECT * FROM robots WHERE type = 'mechanical'"
+ );
+
+ $resultset = $connection->query(
+ "SELECT * FROM robots WHERE type = ?",
+ [
+ "mechanical",
+ ]
+ );
public **execute** (*mixed* $sqlStatement, [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server doesn't return any rows
+Sends SQL statements to the database server returning the success state.
+Use this method only when the SQL statement sent to the server doesn't return any rows
.. code-block:: php
execute("INSERT INTO robots VALUES (1, 'Astro Boy')");
- $success = $connection->execute("INSERT INTO robots VALUES (?, ?)", array(1, 'Astro Boy'));
+ // Inserting data
+ $success = $connection->execute(
+ "INSERT INTO robots VALUES (1, 'Astro Boy')"
+ );
+
+ $success = $connection->execute(
+ "INSERT INTO robots VALUES (?, ?)",
+ [
+ 1,
+ "Astro Boy",
+ ]
+ );
public **affectedRows** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Returns the number of affected rows by the lastest INSERT/UPDATE/DELETE executed in the database system
+Returns the number of affected rows by the latest INSERT/UPDATE/DELETE executed in the database system
.. code-block:: php
execute("DELETE FROM robots");
- echo $connection->affectedRows(), ' were deleted';
-
-
-
+ $connection->execute(
+ "DELETE FROM robots"
+ );
-public **close** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-
-Closes the active connection returning success. Phalcon automatically closes and destroys active connections when the request ends
-
-
-
-public *string* **escapeIdentifier** (*string* $identifier) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
+ echo $connection->affectedRows(), " were deleted";
-Escapes a column/table/schema name
-.. code-block:: php
- escapeIdentifier('robots');
- $escapedTable = $connection->escapeIdentifier(['store', 'robots']);
+public **close** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
+Closes the active connection returning success. Phalcon automatically closes and destroys
+active connections when the request ends
public **escapeString** (*mixed* $str) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Escapes a value to avoid SQL injections according to the active charset in the connection
+Escapes a value to avoid SQL injections according to the active charset in the connection
.. code-block:: php
escapeString('some dangerous value');
+ $escapedStr = $connection->escapeString("some dangerous value");
public **convertBoundParams** (*mixed* $sql, [*array* $params]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Converts bound parameters such as :name: or ?1 into PDO bind params ?
+Converts bound parameters such as :name: or ?1 into PDO bind params ?
.. code-block:: php
convertBoundParams('SELECT * FROM robots WHERE name = :name:', array('Bender')));
+ print_r(
+ $connection->convertBoundParams(
+ "SELECT * FROM robots WHERE name = :name:",
+ [
+ "Bender",
+ ]
+ )
+ );
public *int* | *boolean* **lastInsertId** ([*string* $sequenceName]) inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Returns the insert id for the auto_increment/serial column inserted in the lastest executed SQL statement
+Returns the insert id for the auto_increment/serial column inserted in the latest executed SQL statement
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", 1952),
- array("name", "year")
- );
-
- //Getting the generated id
- $id = $connection->lastInsertId();
+ // Inserting a new robot
+ $success = $connection->insert(
+ "robots",
+ [
+ "Astro Boy",
+ 1952,
+ ],
+ [
+ "name",
+ "year",
+ ]
+ );
+
+ // Getting the generated id
+ $id = $connection->lastInsertId();
@@ -262,14 +321,18 @@ Returns the current transaction nesting level
public **isUnderTransaction** () inherited from :doc:`Phalcon\\Db\\Adapter\\Pdo `
-Checks whether the connection is under a transaction
+Checks whether the connection is under a transaction
.. code-block:: php
begin();
- var_dump($connection->isUnderTransaction()); //true
+
+ // true
+ var_dump(
+ $connection->isUnderTransaction()
+ );
@@ -330,18 +393,18 @@ Returns internal dialect instance
public **fetchOne** (*mixed* $sqlQuery, [*mixed* $fetchMode], [*mixed* $bindParams], [*mixed* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the first row in a SQL query result
+Returns the first row in a SQL query result
.. code-block:: php
fetchOne("SELECT * FROM robots");
print_r($robot);
-
- //Getting first robot with associative indexes only
- $robot = $connection->fetchOne("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+
+ // Getting first robot with associative indexes only
+ $robot = $connection->fetchOne("SELECT * FROM robots", \Phalcon\Db::FETCH_ASSOC);
print_r($robot);
@@ -349,25 +412,32 @@ Returns the first row in a SQL query result
public *array* **fetchAll** (*string* $sqlQuery, [*int* $fetchMode], [*array* $bindParams], [*array* $bindTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Dumps the complete result of a query into an array
+Dumps the complete result of a query into an array
.. code-block:: php
fetchAll("SELECT * FROM robots", Phalcon\Db::FETCH_ASSOC);
+ // Getting all robots with associative indexes only
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots",
+ \Phalcon\Db::FETCH_ASSOC
+ );
+
foreach ($robots as $robot) {
- print_r($robot);
+ print_r($robot);
}
-
- //Getting all robots that contains word "robot" withing the name
- $robots = $connection->fetchAll("SELECT * FROM robots WHERE name LIKE :name",
- Phalcon\Db::FETCH_ASSOC,
- array('name' => '%robot%')
- );
- foreach($robots as $robot){
- print_r($robot);
+
+ // Getting all robots that contains word "robot" withing the name
+ $robots = $connection->fetchAll(
+ "SELECT * FROM robots WHERE name LIKE :name",
+ \Phalcon\Db::FETCH_ASSOC,
+ [
+ "name" => "%robot%",
+ ]
+ );
+ foreach($robots as $robot) {
+ print_r($robot);
}
@@ -375,18 +445,21 @@ Dumps the complete result of a query into an array
public *string* | ** **fetchColumn** (*string* $sqlQuery, [*array* $placeholders], [*int* | *string* $column]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the n'th field of first row in a SQL query result
+Returns the n'th field of first row in a SQL query result
.. code-block:: php
fetchColumn("SELECT count(*) FROM robots");
print_r($robotsCount);
-
- //Getting name of last edited robot
- $robot = $connection->fetchColumn("SELECT id, name FROM robots order by modified desc", 1);
+
+ // Getting name of last edited robot
+ $robot = $connection->fetchColumn(
+ "SELECT id, name FROM robots order by modified desc",
+ 1
+ );
print_r($robot);
@@ -394,79 +467,81 @@ Returns the n'th field of first row in a SQL query result
public *boolean* **insert** (*string* | *array* $table, *array* $values, [*array* $fields], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Inserts data into a table using custom RDBMS SQL syntax
+Inserts data into a table using custom RDBMS SQL syntax
.. code-block:: php
insert(
- "robots",
- array("Astro Boy", 1952),
- array("name", "year")
- );
-
- // Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insert(
+ "robots",
+ ["Astro Boy", 1952],
+ ["name", "year"]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **insertAsDict** (*string* $table, *array* $data, [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Inserts data into a table using custom RBDM SQL syntax
+Inserts data into a table using custom RBDM SQL syntax
.. code-block:: php
insertAsDict(
- "robots",
- array(
- "name" => "Astro Boy",
- "year" => 1952
- )
- );
-
- //Next SQL sentence is sent to the database system
- INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
+ // Inserting a new robot
+ $success = $connection->insertAsDict(
+ "robots",
+ [
+ "name" => "Astro Boy",
+ "year" => 1952,
+ ]
+ );
+
+ // Next SQL sentence is sent to the database system
+ INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
public *boolean* **update** (*string* | *array* $table, *array* $fields, *array* $values, [*string* | *array* $whereCondition], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Updates data on a table using custom RBDM SQL syntax
+Updates data on a table using custom RBDM SQL syntax
.. code-block:: php
update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
-
- //Updating existing robot with array condition and $dataTypes
- $success = $connection->update(
- "robots",
- array("name"),
- array("New Astro Boy"),
- array(
- 'conditions' => "id = ?",
- 'bind' => array($some_unsafe_id),
- 'bindTypes' => array(PDO::PARAM_INT) //use only if you use $dataTypes param
- ),
- array(PDO::PARAM_STR)
- );
+ // Updating existing robot
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+
+ // Updating existing robot with array condition and $dataTypes
+ $success = $connection->update(
+ "robots",
+ ["name"],
+ ["New Astro Boy"],
+ [
+ "conditions" => "id = ?",
+ "bind" => [$some_unsafe_id],
+ "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param
+ ],
+ [
+ PDO::PARAM_STR
+ ]
+ );
Warning! If $whereCondition is string it not escaped.
@@ -474,43 +549,66 @@ Warning! If $whereCondition is string it not escaped.
public *boolean* **updateAsDict** (*string* $table, *array* $data, [*string* $whereCondition], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Updates data on a table using custom RBDM SQL syntax Another, more convenient syntax
+Updates data on a table using custom RBDM SQL syntax
+Another, more convenient syntax
.. code-block:: php
updateAsDict(
- "robots",
- array(
- "name" => "New Astro Boy"
- ),
- "id = 101"
- );
-
- //Next SQL sentence is sent to the database system
- UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
+ // Updating existing robot
+ $success = $connection->updateAsDict(
+ "robots",
+ [
+ "name" => "New Astro Boy",
+ ],
+ "id = 101"
+ );
+
+ // Next SQL sentence is sent to the database system
+ UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
public *boolean* **delete** (*string* | *array* $table, [*string* $whereCondition], [*array* $placeholders], [*array* $dataTypes]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Deletes data from a table using custom RBDM SQL syntax
+Deletes data from a table using custom RBDM SQL syntax
.. code-block:: php
delete(
- "robots",
- "id = 101"
- );
-
- //Next SQL sentence is generated
- DELETE FROM `robots` WHERE `id` = 101
+ // Deleting existing robot
+ $success = $connection->delete(
+ "robots",
+ "id = 101"
+ );
+
+ // Next SQL sentence is generated
+ DELETE FROM `robots` WHERE `id` = 101
+
+
+
+
+public **escapeIdentifier** (*array* | *string* $identifier) inherited from :doc:`Phalcon\\Db\\Adapter `
+
+Escapes a column/table/schema name
+
+.. code-block:: php
+
+ escapeIdentifier(
+ "robots"
+ );
+
+ $escapedTable = $connection->escapeIdentifier(
+ [
+ "store",
+ "robots",
+ ]
+ );
@@ -523,39 +621,43 @@ Gets a list of columns
public **limit** (*mixed* $sqlQuery, *mixed* $number) inherited from :doc:`Phalcon\\Db\\Adapter `
-Appends a LIMIT clause to $sqlQuery argument
+Appends a LIMIT clause to $sqlQuery argument
.. code-block:: php
limit("SELECT * FROM robots", 5);
+ echo $connection->limit("SELECT * FROM robots", 5);
public **tableExists** (*mixed* $tableName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Generates SQL checking for the existence of a schema.table
+Generates SQL checking for the existence of a schema.table
.. code-block:: php
tableExists("blog", "posts"));
+ var_dump(
+ $connection->tableExists("blog", "posts")
+ );
public **viewExists** (*mixed* $viewName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Generates SQL checking for the existence of a schema.view
+Generates SQL checking for the existence of a schema.view
.. code-block:: php
viewExists("active_users", "posts"));
+ var_dump(
+ $connection->viewExists("active_users", "posts")
+ );
@@ -658,39 +760,45 @@ Returns the SQL column definition from a column
public **listTables** ([*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-List all tables on a database
+List all tables on a database
.. code-block:: php
listTables("blog"));
+ print_r(
+ $connection->listTables("blog")
+ );
public **listViews** ([*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-List all views on a database
+List all views on a database
.. code-block:: php
listViews("blog"));
+ print_r(
+ $connection->listViews("blog")
+ );
public **tableOptions** (*mixed* $tableName, [*mixed* $schemaName]) inherited from :doc:`Phalcon\\Db\\Adapter `
-Gets creation options from a table
+Gets creation options from a table
.. code-block:: php
tableOptions('robots'));
+ print_r(
+ $connection->tableOptions("robots")
+ );
@@ -733,18 +841,26 @@ Returns the savepoint name to use for nested transactions
public **getDefaultIdValue** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Returns the default identity value to be inserted in an identity column
+Returns the default identity value to be inserted in an identity column
.. code-block:: php
insert(
- "robots",
- array($connection->getDefaultIdValue(), "Astro Boy", 1952),
- array("id", "name", "year")
- );
+ // Inserting a new robot with a valid default value for the column 'id'
+ $success = $connection->insert(
+ "robots",
+ [
+ $connection->getDefaultIdValue(),
+ "Astro Boy",
+ 1952,
+ ],
+ [
+ "id",
+ "name",
+ "year",
+ ]
+ );
@@ -775,7 +891,7 @@ Active SQL statement in the object
public **getRealSQLStatement** () inherited from :doc:`Phalcon\\Db\\Adapter `
-Active SQL statement in the object without replace bound paramters
+Active SQL statement in the object without replace bound parameters
diff --git a/en/api/Phalcon_Db_Column.rst b/en/api/Phalcon_Db_Column.rst
index 30e9833f0037..afccbd2f714b 100644
--- a/en/api/Phalcon_Db_Column.rst
+++ b/en/api/Phalcon_Db_Column.rst
@@ -8,26 +8,29 @@ Class **Phalcon\\Db\\Column**
:raw-html:`Source on GitHub`
-Allows to define columns to be used on create or alter table operations
+Allows to define columns to be used on create or alter table operations
.. code-block:: php
Column::TYPE_INTEGER,
- "size" => 10,
- "unsigned" => true,
- "notNull" => true,
- "autoIncrement" => true,
- "first" => true
- ));
-
- //add column to existing table
- $connection->addColumn("robots", null, $column);
+
+ // Column definition
+ $column = new Column(
+ "id",
+ [
+ "type" => Column::TYPE_INTEGER,
+ "size" => 10,
+ "unsigned" => true,
+ "notNull" => true,
+ "autoIncrement" => true,
+ "first" => true,
+ ]
+ );
+
+ // Add column to existing table
+ $connection->addColumn("robots", null, $column);
diff --git a/en/api/Phalcon_Db_Dialect.rst b/en/api/Phalcon_Db_Dialect.rst
index 921b35af1933..5809f05336e1 100644
--- a/en/api/Phalcon_Db_Dialect.rst
+++ b/en/api/Phalcon_Db_Dialect.rst
@@ -8,7 +8,8 @@ Abstract class **Phalcon\\Db\\Dialect**
:raw-html:`Source on GitHub`
-This is the base class to each database dialect. This implements common methods to transform intermediate code into its RDBMS related syntax
+This is the base class to each database dialect. This implements
+common methods to transform intermediate code into its RDBMS related syntax
Methods
@@ -40,58 +41,63 @@ Escape identifiers
public **limit** (*mixed* $sqlQuery, *mixed* $number)
-Generates the SQL for LIMIT clause
+Generates the SQL for LIMIT clause
.. code-block:: php
limit('SELECT * FROM robots', 10);
- echo $sql; // SELECT * FROM robots LIMIT 10
-
- $sql = $dialect->limit('SELECT * FROM robots', [10, 50]);
- echo $sql; // SELECT * FROM robots LIMIT 10 OFFSET 50
+ $sql = $dialect->limit("SELECT * FROM robots", 10);
+ echo $sql; // SELECT * FROM robots LIMIT 10
+
+ $sql = $dialect->limit("SELECT * FROM robots", [10, 50]);
+ echo $sql; // SELECT * FROM robots LIMIT 10 OFFSET 50
public **forUpdate** (*mixed* $sqlQuery)
-Returns a SQL modified with a FOR UPDATE clause
+Returns a SQL modified with a FOR UPDATE clause
.. code-block:: php
forUpdate('SELECT * FROM robots');
- echo $sql; // SELECT * FROM robots FOR UPDATE
+ $sql = $dialect->forUpdate("SELECT * FROM robots");
+ echo $sql; // SELECT * FROM robots FOR UPDATE
public **sharedLock** (*mixed* $sqlQuery)
-Returns a SQL modified with a LOCK IN SHARE MODE clause
+Returns a SQL modified with a LOCK IN SHARE MODE clause
.. code-block:: php
sharedLock('SELECT * FROM robots');
- echo $sql; // SELECT * FROM robots LOCK IN SHARE MODE
+ $sql = $dialect->sharedLock("SELECT * FROM robots");
+ echo $sql; // SELECT * FROM robots LOCK IN SHARE MODE
final public **getColumnList** (*array* $columnList, [*mixed* $escapeChar], [*mixed* $bindCounts])
-Gets a list of columns with escaped identifiers
+Gets a list of columns with escaped identifiers
.. code-block:: php
getColumnList(array('column1', 'column'));
+ echo $dialect->getColumnList(
+ [
+ "column1",
+ "column",
+ ]
+ );
diff --git a/en/api/Phalcon_Db_Dialect_Mysql.rst b/en/api/Phalcon_Db_Dialect_Mysql.rst
index cd899fb89df4..2f51516bfee5 100644
--- a/en/api/Phalcon_Db_Dialect_Mysql.rst
+++ b/en/api/Phalcon_Db_Dialect_Mysql.rst
@@ -102,14 +102,15 @@ Generates SQL to drop a view
public **tableExists** (*mixed* $tableName, [*mixed* $schemaName])
-Generates SQL checking for the existence of a schema.table
+Generates SQL checking for the existence of a schema.table
.. code-block:: php
tableExists("posts", "blog");
- echo $dialect->tableExists("posts");
+ echo $dialect->tableExists("posts", "blog");
+
+ echo $dialect->tableExists("posts");
@@ -122,26 +123,30 @@ Generates SQL checking for the existence of a schema.view
public **describeColumns** (*mixed* $table, [*mixed* $schema])
-Generates SQL describing a table
+Generates SQL describing a table
.. code-block:: php
describeColumns("posts"));
+ print_r(
+ $dialect->describeColumns("posts")
+ );
public **listTables** ([*mixed* $schemaName])
-List all tables in database
+List all tables in database
.. code-block:: php
listTables("blog"))
+ print_r(
+ $dialect->listTables("blog")
+ );
@@ -202,58 +207,63 @@ Escape identifiers
public **limit** (*mixed* $sqlQuery, *mixed* $number) inherited from :doc:`Phalcon\\Db\\Dialect `
-Generates the SQL for LIMIT clause
+Generates the SQL for LIMIT clause
.. code-block:: php
limit('SELECT * FROM robots', 10);
- echo $sql; // SELECT * FROM robots LIMIT 10
-
- $sql = $dialect->limit('SELECT * FROM robots', [10, 50]);
- echo $sql; // SELECT * FROM robots LIMIT 10 OFFSET 50
+ $sql = $dialect->limit("SELECT * FROM robots", 10);
+ echo $sql; // SELECT * FROM robots LIMIT 10
+
+ $sql = $dialect->limit("SELECT * FROM robots", [10, 50]);
+ echo $sql; // SELECT * FROM robots LIMIT 10 OFFSET 50
public **forUpdate** (*mixed* $sqlQuery) inherited from :doc:`Phalcon\\Db\\Dialect `
-Returns a SQL modified with a FOR UPDATE clause
+Returns a SQL modified with a FOR UPDATE clause
.. code-block:: php
forUpdate('SELECT * FROM robots');
- echo $sql; // SELECT * FROM robots FOR UPDATE
+ $sql = $dialect->forUpdate("SELECT * FROM robots");
+ echo $sql; // SELECT * FROM robots FOR UPDATE
public **sharedLock** (*mixed* $sqlQuery) inherited from :doc:`Phalcon\\Db\\Dialect `
-Returns a SQL modified with a LOCK IN SHARE MODE clause
+Returns a SQL modified with a LOCK IN SHARE MODE clause
.. code-block:: php
sharedLock('SELECT * FROM robots');
- echo $sql; // SELECT * FROM robots LOCK IN SHARE MODE
+ $sql = $dialect->sharedLock("SELECT * FROM robots");
+ echo $sql; // SELECT * FROM robots LOCK IN SHARE MODE
final public **getColumnList** (*array* $columnList, [*mixed* $escapeChar], [*mixed* $bindCounts]) inherited from :doc:`Phalcon\\Db\\Dialect `
-Gets a list of columns with escaped identifiers
+Gets a list of columns with escaped identifiers
.. code-block:: php
getColumnList(array('column1', 'column'));
+ echo $dialect->getColumnList(
+ [
+ "column1",
+ "column",
+ ]
+ );
diff --git a/en/api/Phalcon_Db_Dialect_Postgresql.rst b/en/api/Phalcon_Db_Dialect_Postgresql.rst
index 2e382429bdcf..ad6fc41bda8b 100644
--- a/en/api/Phalcon_Db_Dialect_Postgresql.rst
+++ b/en/api/Phalcon_Db_Dialect_Postgresql.rst
@@ -84,7 +84,7 @@ Generates SQL to create a table
public **dropTable** (*mixed* $tableName, [*mixed* $schemaName], [*mixed* $ifExists])
-Generates SQL to drop a view
+Generates SQL to drop a table
@@ -102,14 +102,15 @@ Generates SQL to drop a view
public **tableExists** (*mixed* $tableName, [*mixed* $schemaName])
-Generates SQL checking for the existence of a schema.table
+Generates SQL checking for the existence of a schema.table
.. code-block:: php
tableExists("posts", "blog");
- echo $dialect->tableExists("posts");
+ echo $dialect->tableExists("posts", "blog");
+
+ echo $dialect->tableExists("posts");
@@ -122,26 +123,30 @@ Generates SQL checking for the existence of a schema.view
public **describeColumns** (*mixed* $table, [*mixed* $schema])
-Generates SQL describing a table
+Generates SQL describing a table
.. code-block:: php
describeColumns("posts"));
+ print_r(
+ $dialect->describeColumns("posts")
+ );
public **listTables** ([*mixed* $schemaName])
-List all tables in database
+List all tables in database
.. code-block:: php
listTables("blog"))
+ print_r(
+ $dialect->listTables("blog")
+ );
@@ -170,6 +175,11 @@ Generates the SQL to describe the table creation options
+protected **_castDefault** (:doc:`Phalcon\\Db\\ColumnInterface ` $column)
+
+...
+
+
protected **_getTableOptions** (*array* $definition)
...
@@ -201,58 +211,63 @@ Escape identifiers
public **limit** (*mixed* $sqlQuery, *mixed* $number) inherited from :doc:`Phalcon\\Db\\Dialect `
-Generates the SQL for LIMIT clause
+Generates the SQL for LIMIT clause
.. code-block:: php
limit('SELECT * FROM robots', 10);
- echo $sql; // SELECT * FROM robots LIMIT 10
-
- $sql = $dialect->limit('SELECT * FROM robots', [10, 50]);
- echo $sql; // SELECT * FROM robots LIMIT 10 OFFSET 50
+ $sql = $dialect->limit("SELECT * FROM robots", 10);
+ echo $sql; // SELECT * FROM robots LIMIT 10
+
+ $sql = $dialect->limit("SELECT * FROM robots", [10, 50]);
+ echo $sql; // SELECT * FROM robots LIMIT 10 OFFSET 50
public **forUpdate** (*mixed* $sqlQuery) inherited from :doc:`Phalcon\\Db\\Dialect `
-Returns a SQL modified with a FOR UPDATE clause
+Returns a SQL modified with a FOR UPDATE clause
.. code-block:: php
forUpdate('SELECT * FROM robots');
- echo $sql; // SELECT * FROM robots FOR UPDATE
+ $sql = $dialect->forUpdate("SELECT * FROM robots");
+ echo $sql; // SELECT * FROM robots FOR UPDATE
public **sharedLock** (*mixed* $sqlQuery) inherited from :doc:`Phalcon\\Db\\Dialect `
-Returns a SQL modified with a LOCK IN SHARE MODE clause
+Returns a SQL modified with a LOCK IN SHARE MODE clause
.. code-block:: php
sharedLock('SELECT * FROM robots');
- echo $sql; // SELECT * FROM robots LOCK IN SHARE MODE
+ $sql = $dialect->sharedLock("SELECT * FROM robots");
+ echo $sql; // SELECT * FROM robots LOCK IN SHARE MODE
final public **getColumnList** (*array* $columnList, [*mixed* $escapeChar], [*mixed* $bindCounts]) inherited from :doc:`Phalcon\\Db\\Dialect `
-Gets a list of columns with escaped identifiers
+Gets a list of columns with escaped identifiers
.. code-block:: php
getColumnList(array('column1', 'column'));
+ echo $dialect->getColumnList(
+ [
+ "column1",
+ "column",
+ ]
+ );
diff --git a/en/api/Phalcon_Db_Dialect_Sqlite.rst b/en/api/Phalcon_Db_Dialect_Sqlite.rst
index 3fff656f9601..1f22ccc8176a 100644
--- a/en/api/Phalcon_Db_Dialect_Sqlite.rst
+++ b/en/api/Phalcon_Db_Dialect_Sqlite.rst
@@ -102,14 +102,15 @@ Generates SQL to drop a view
public **tableExists** (*mixed* $tableName, [*mixed* $schemaName])
-Generates SQL checking for the existence of a schema.table
+Generates SQL checking for the existence of a schema.table
.. code-block:: php
tableExists("posts", "blog");
- echo $dialect->tableExists("posts");
+ echo $dialect->tableExists("posts", "blog");
+
+ echo $dialect->tableExists("posts");
@@ -122,26 +123,30 @@ Generates SQL checking for the existence of a schema.view
public **describeColumns** (*mixed* $table, [*mixed* $schema])
-Generates SQL describing a table
+Generates SQL describing a table
.. code-block:: php
describeColumns("posts"));
+ print_r(
+ $dialect->describeColumns("posts")
+ );
public **listTables** ([*mixed* $schemaName])
-List all tables in database
+List all tables in database
.. code-block:: php
listTables("blog"))
+ print_r(
+ $dialect->listTables("blog")
+ );
@@ -154,13 +159,15 @@ Generates the SQL to list all views of a schema or user
public **listIndexesSql** (*mixed* $table, [*mixed* $schema], [*mixed* $keyName])
-Generates the SQL to get query list of indexes
+Generates the SQL to get query list of indexes
.. code-block:: php
listIndexesSql("blog"))
+ print_r(
+ $dialect->listIndexesSql("blog")
+ );
@@ -215,58 +222,63 @@ Escape identifiers
public **limit** (*mixed* $sqlQuery, *mixed* $number) inherited from :doc:`Phalcon\\Db\\Dialect `
-Generates the SQL for LIMIT clause
+Generates the SQL for LIMIT clause
.. code-block:: php
limit('SELECT * FROM robots', 10);
- echo $sql; // SELECT * FROM robots LIMIT 10
-
- $sql = $dialect->limit('SELECT * FROM robots', [10, 50]);
- echo $sql; // SELECT * FROM robots LIMIT 10 OFFSET 50
+ $sql = $dialect->limit("SELECT * FROM robots", 10);
+ echo $sql; // SELECT * FROM robots LIMIT 10
+
+ $sql = $dialect->limit("SELECT * FROM robots", [10, 50]);
+ echo $sql; // SELECT * FROM robots LIMIT 10 OFFSET 50
public **forUpdate** (*mixed* $sqlQuery) inherited from :doc:`Phalcon\\Db\\Dialect `
-Returns a SQL modified with a FOR UPDATE clause
+Returns a SQL modified with a FOR UPDATE clause
.. code-block:: php
forUpdate('SELECT * FROM robots');
- echo $sql; // SELECT * FROM robots FOR UPDATE
+ $sql = $dialect->forUpdate("SELECT * FROM robots");
+ echo $sql; // SELECT * FROM robots FOR UPDATE
public **sharedLock** (*mixed* $sqlQuery) inherited from :doc:`Phalcon\\Db\\Dialect `
-Returns a SQL modified with a LOCK IN SHARE MODE clause
+Returns a SQL modified with a LOCK IN SHARE MODE clause
.. code-block:: php
sharedLock('SELECT * FROM robots');
- echo $sql; // SELECT * FROM robots LOCK IN SHARE MODE
+ $sql = $dialect->sharedLock("SELECT * FROM robots");
+ echo $sql; // SELECT * FROM robots LOCK IN SHARE MODE
final public **getColumnList** (*array* $columnList, [*mixed* $escapeChar], [*mixed* $bindCounts]) inherited from :doc:`Phalcon\\Db\\Dialect `
-Gets a list of columns with escaped identifiers
+Gets a list of columns with escaped identifiers
.. code-block:: php
getColumnList(array('column1', 'column'));
+ echo $dialect->getColumnList(
+ [
+ "column1",
+ "column",
+ ]
+ );
diff --git a/en/api/Phalcon_Db_Index.rst b/en/api/Phalcon_Db_Index.rst
index 3c6f460563a7..415a456a64bd 100644
--- a/en/api/Phalcon_Db_Index.rst
+++ b/en/api/Phalcon_Db_Index.rst
@@ -8,7 +8,9 @@ Class **Phalcon\\Db\\Index**
:raw-html:`Source on GitHub`
-Allows to define indexes to be used on tables. Indexes are a common way to enhance database performance. An index allows the database server to find and retrieve specific rows much faster than it could do without an index
+Allows to define indexes to be used on tables. Indexes are a common way
+to enhance database performance. An index allows the database server to find
+and retrieve specific rows much faster than it could do without an index
Methods
@@ -43,3 +45,4 @@ public static **__set_state** (*array* $data)
Restore a Phalcon\\Db\\Index object from export
+
diff --git a/en/api/Phalcon_Db_Profiler.rst b/en/api/Phalcon_Db_Profiler.rst
index e8859d1ebdb4..9f1dac4bdf32 100644
--- a/en/api/Phalcon_Db_Profiler.rst
+++ b/en/api/Phalcon_Db_Profiler.rst
@@ -6,27 +6,30 @@ Class **Phalcon\\Db\\Profiler**
:raw-html:`Source on GitHub`
-Instances of Phalcon\\Db can generate execution profiles on SQL statements sent to the relational database. Profiled information includes execution time in milliseconds. This helps you to identify bottlenecks in your applications.
+Instances of Phalcon\\Db can generate execution profiles
+on SQL statements sent to the relational database. Profiled
+information includes execution time in milliseconds.
+This helps you to identify bottlenecks in your applications.
.. code-block:: php
setProfiler($profiler);
-
+
$sql = "SELECT buyer_name, quantity, product_name
FROM buyers LEFT JOIN products ON
buyers.pid=products.id";
-
- //Execute a SQL statement
+
+ // Execute a SQL statement
$connection->query($sql);
-
- //Get the last profile in the profiler
+
+ // Get the last profile in the profiler
$profile = $profiler->getLastProfile();
-
+
echo "SQL Statement: ", $profile->getSQLStatement(), "\n";
echo "Start Time: ", $profile->getInitialTime(), "\n";
echo "Final Time: ", $profile->getFinalTime(), "\n";
diff --git a/en/api/Phalcon_Db_RawValue.rst b/en/api/Phalcon_Db_RawValue.rst
index e49a858dc99b..7fc6d43dad0a 100644
--- a/en/api/Phalcon_Db_RawValue.rst
+++ b/en/api/Phalcon_Db_RawValue.rst
@@ -6,15 +6,19 @@ Class **Phalcon\\Db\\RawValue**
:raw-html:`Source on GitHub`
-This class allows to insert/update raw data without quoting or formatting. The next example shows how to use the MySQL now() function as a field value.
+This class allows to insert/update raw data without quoting or formatting.
+
+The next example shows how to use the MySQL now() function as a field value.
.. code-block:: php
email = 'andres@phalconphp.com';
- $subscriber->createdAt = new \Phalcon\Db\RawValue('now()');
+
+ $subscriber->email = "andres@phalconphp.com";
+ $subscriber->createdAt = new \Phalcon\Db\RawValue("now()");
+
$subscriber->save();
diff --git a/en/api/Phalcon_Db_Reference.rst b/en/api/Phalcon_Db_Reference.rst
index 5a3fe05264e0..932290f7733e 100644
--- a/en/api/Phalcon_Db_Reference.rst
+++ b/en/api/Phalcon_Db_Reference.rst
@@ -8,18 +8,27 @@ Class **Phalcon\\Db\\Reference**
:raw-html:`Source on GitHub`
-Allows to define reference constraints on tables
+Allows to define reference constraints on tables
.. code-block:: php
"invoicing",
- 'referencedTable' => "products",
- 'columns' => array("product_type", "product_code"),
- 'referencedColumns' => array("type", "code")
- ));
+ $reference = new \Phalcon\Db\Reference(
+ "field_fk",
+ [
+ "referencedSchema" => "invoicing",
+ "referencedTable" => "products",
+ "columns" => [
+ "product_type",
+ "product_code",
+ ],
+ "referencedColumns" => [
+ "type",
+ "code",
+ ],
+ ]
+ );
diff --git a/en/api/Phalcon_Db_Result_Pdo.rst b/en/api/Phalcon_Db_Result_Pdo.rst
index 6b44bdd731a5..966109f2fb47 100644
--- a/en/api/Phalcon_Db_Result_Pdo.rst
+++ b/en/api/Phalcon_Db_Result_Pdo.rst
@@ -8,16 +8,20 @@ Class **Phalcon\\Db\\Result\\Pdo**
:raw-html:`Source on GitHub`
-Encapsulates the resultset internals
+Encapsulates the resultset internals
.. code-block:: php
query("SELECT * FROM robots ORDER BY name");
- $result->setFetchMode(Phalcon\Db::FETCH_NUM);
+
+ $result->setFetchMode(
+ \Phalcon\Db::FETCH_NUM
+ );
+
while ($robot = $result->fetchArray()) {
- print_r($robot);
+ print_r($robot);
}
@@ -33,22 +37,28 @@ Phalcon\\Db\\Result\\Pdo constructor
public **execute** ()
-Allows to execute the statement again. Some database systems don't support scrollable cursors, So, as cursors are forward only, we need to execute the cursor again to fetch rows from the begining
+Allows to execute the statement again. Some database systems don't support scrollable cursors,
+So, as cursors are forward only, we need to execute the cursor again to fetch rows from the begining
public **fetch** ([*mixed* $fetchStyle], [*mixed* $cursorOrientation], [*mixed* $cursorOffset])
-Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. This method is affected by the active fetch flag set using Phalcon\\Db\\Result\\Pdo::setFetchMode
+Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows.
+This method is affected by the active fetch flag set using Phalcon\\Db\\Result\\Pdo::setFetchMode
.. code-block:: php
query("SELECT * FROM robots ORDER BY name");
- $result->setFetchMode(Phalcon\Db::FETCH_OBJ);
+
+ $result->setFetchMode(
+ \Phalcon\Db::FETCH_OBJ
+ );
+
while ($robot = $result->fetch()) {
- echo $robot->name;
+ echo $robot->name;
}
@@ -56,16 +66,21 @@ Fetches an array/object of strings that corresponds to the fetched row, or FALSE
public **fetchArray** ()
-Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. This method is affected by the active fetch flag set using Phalcon\\Db\\Result\\Pdo::setFetchMode
+Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows.
+This method is affected by the active fetch flag set using Phalcon\\Db\\Result\\Pdo::setFetchMode
.. code-block:: php
query("SELECT * FROM robots ORDER BY name");
- $result->setFetchMode(Phalcon\Db::FETCH_NUM);
+
+ $result->setFetchMode(
+ \Phalcon\Db::FETCH_NUM
+ );
+
while ($robot = result->fetchArray()) {
- print_r($robot);
+ print_r($robot);
}
@@ -73,13 +88,17 @@ Returns an array of strings that corresponds to the fetched row, or FALSE if the
public **fetchAll** ([*mixed* $fetchStyle], [*mixed* $fetchArgument], [*mixed* $ctorArgs])
-Returns an array of arrays containing all the records in the result This method is affected by the active fetch flag set using Phalcon\\Db\\Result\\Pdo::setFetchMode
+Returns an array of arrays containing all the records in the result
+This method is affected by the active fetch flag set using Phalcon\\Db\\Result\\Pdo::setFetchMode
.. code-block:: php
query("SELECT * FROM robots ORDER BY name");
+ $result = $connection->query(
+ "SELECT * FROM robots ORDER BY name"
+ );
+
$robots = $result->fetchAll();
@@ -87,52 +106,69 @@ Returns an array of arrays containing all the records in the result This method
public **numRows** ()
-Gets number of rows returned by a resultset
+Gets number of rows returned by a resultset
.. code-block:: php
query("SELECT * FROM robots ORDER BY name");
- echo 'There are ', $result->numRows(), ' rows in the resultset';
+ $result = $connection->query(
+ "SELECT * FROM robots ORDER BY name"
+ );
+
+ echo "There are ", $result->numRows(), " rows in the resultset";
public **dataSeek** (*mixed* $number)
-Moves internal resultset cursor to another position letting us to fetch a certain row
+Moves internal resultset cursor to another position letting us to fetch a certain row
.. code-block:: php
query("SELECT * FROM robots ORDER BY name");
- $result->dataSeek(2); // Move to third row on result
- $row = $result->fetch(); // Fetch third row
+ $result = $connection->query(
+ "SELECT * FROM robots ORDER BY name"
+ );
+
+ // Move to third row on result
+ $result->dataSeek(2);
+
+ // Fetch third row
+ $row = $result->fetch();
public **setFetchMode** (*mixed* $fetchMode, [*mixed* $colNoOrClassNameOrObject], [*mixed* $ctorargs])
-Changes the fetching mode affecting Phalcon\\Db\\Result\\Pdo::fetch()
+Changes the fetching mode affecting Phalcon\\Db\\Result\\Pdo::fetch()
.. code-block:: php
setFetchMode(\Phalcon\Db::FETCH_NUM);
-
- //Return associative array without integer indexes
- $result->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
-
- //Return associative array together with integer indexes
- $result->setFetchMode(\Phalcon\Db::FETCH_BOTH);
-
- //Return an object
- $result->setFetchMode(\Phalcon\Db::FETCH_OBJ);
+ // Return array with integer indexes
+ $result->setFetchMode(
+ \Phalcon\Db::FETCH_NUM
+ );
+
+ // Return associative array without integer indexes
+ $result->setFetchMode(
+ \Phalcon\Db::FETCH_ASSOC
+ );
+
+ // Return associative array together with integer indexes
+ $result->setFetchMode(
+ \Phalcon\Db::FETCH_BOTH
+ );
+
+ // Return an object
+ $result->setFetchMode(
+ \Phalcon\Db::FETCH_OBJ
+ );
diff --git a/en/api/Phalcon_Debug.rst b/en/api/Phalcon_Debug.rst
index d92551a4b0f5..6b91ad0a31a3 100644
--- a/en/api/Phalcon_Debug.rst
+++ b/en/api/Phalcon_Debug.rst
@@ -32,7 +32,8 @@ Set if files part of the backtrace must be shown in the output
public **setShowFileFragment** (*mixed* $showFileFragment)
-Sets if files must be completely opened and showed in the output or just the fragment related to the exception
+Sets if files must be completely opened and showed in the output
+or just the fragment related to the exception
diff --git a/en/api/Phalcon_Debug_Dump.rst b/en/api/Phalcon_Debug_Dump.rst
index 3d35ad49f661..92cd9e1b15b0 100644
--- a/en/api/Phalcon_Debug_Dump.rst
+++ b/en/api/Phalcon_Debug_Dump.rst
@@ -6,23 +6,25 @@ Class **Phalcon\\Debug\\Dump**
:raw-html:`Source on GitHub`
-Dumps information about a variable(s)
+Dumps information about a variable(s)
.. code-block:: php
variable($foo, "foo");
+ $foo = 123;
+
+ echo (new \Phalcon\Debug\Dump())->variable($foo, "foo");
.. code-block:: php
"value"];
- $baz = new stdClass();
- echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz);
+ $foo = "string";
+ $bar = ["key" => "value"];
+ $baz = new stdClass();
+
+ echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz);
@@ -57,7 +59,7 @@ Get style for type
-public **setStyles** ([*mixed* $styles])
+public **setStyles** ([*array* $styles])
Set styles for vars type
@@ -77,46 +79,53 @@ Prepare an HTML string of information about a single variable.
public **variable** (*mixed* $variable, [*mixed* $name])
-Returns an HTML string of information about a single variable.
+Returns an HTML string of information about a single variable.
.. code-block:: php
variable($foo, "foo");
+ echo (new \Phalcon\Debug\Dump())->variable($foo, "foo");
public **variables** ()
-Returns an HTML string of debugging information about any number of variables, each wrapped in a "pre" tag.
+Returns an HTML string of debugging information about any number of
+variables, each wrapped in a "pre" tag.
.. code-block:: php
"value"];
- $baz = new stdClass();
- echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz);
+ $foo = "string";
+ $bar = ["key" => "value"];
+ $baz = new stdClass();
+
+ echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz);
public **toJson** (*mixed* $variable)
-Returns an JSON string of information about a single variable.
+Returns an JSON string of information about a single variable.
.. code-block:: php
"value"];
- echo (new \Phalcon\Debug\Dump())->toJson($foo);
- $foo = new stdClass();
- $foo->bar = 'buz';
- echo (new \Phalcon\Debug\Dump())->toJson($foo);
+ $foo = [
+ "key" => "value",
+ ];
+
+ echo (new \Phalcon\Debug\Dump())->toJson($foo);
+
+ $foo = new stdClass();
+ $foo->bar = "buz";
+
+ echo (new \Phalcon\Debug\Dump())->toJson($foo);
diff --git a/en/api/Phalcon_Di.rst b/en/api/Phalcon_Di.rst
index b8c1e7c21c92..9c74d79c2739 100644
--- a/en/api/Phalcon_Di.rst
+++ b/en/api/Phalcon_Di.rst
@@ -8,23 +8,41 @@ Class **Phalcon\\Di**
:raw-html:`Source on GitHub`
-Phalcon\\Di is a component that implements Dependency Injection/Service Location of services and it's itself a container for them. Since Phalcon is highly decoupled, Phalcon\\Di is essential to integrate the different components of the framework. The developer can also use this component to inject dependencies and manage global instances of the different classes used in the application. Basically, this component implements the `Inversion of Control` pattern. Applying this, the objects do not receive their dependencies using setters or constructors, but requesting a service dependency injector. This reduces the overall complexity, since there is only one way to get the required dependencies within a component. Additionally, this pattern increases testability in the code, thus making it less prone to errors.
+Phalcon\\Di is a component that implements Dependency Injection/Service Location
+of services and it's itself a container for them.
+
+Since Phalcon is highly decoupled, Phalcon\\Di is essential to integrate the different
+components of the framework. The developer can also use this component to inject dependencies
+and manage global instances of the different classes used in the application.
+
+Basically, this component implements the `Inversion of Control` pattern. Applying this,
+the objects do not receive their dependencies using setters or constructors, but requesting
+a service dependency injector. This reduces the overall complexity, since there is only one
+way to get the required dependencies within a component.
+
+Additionally, this pattern increases testability in the code, thus making it less prone to errors.
.. code-block:: php
set("request", "Phalcon\Http\Request", true);
-
- //Using an anonymous function
- $di->set("request", function(){
- return new \Phalcon\Http\Request();
- }, true);
-
- $request = $di->getRequest();
+ use Phalcon\Di;
+ use Phalcon\Http\Request;
+
+ $di = new Di();
+
+ // Using a string definition
+ $di->set("request", Request::class, true);
+
+ // Using an anonymous function
+ $di->setShared(
+ "request",
+ function () {
+ return new Request();
+ }
+ );
+
+ $request = $di->getRequest();
@@ -63,13 +81,16 @@ Registers an "always shared" service in the services container
public **remove** (*mixed* $name)
-Removes a service in the services container It also removes any shared instance created for the service
+Removes a service in the services container
+It also removes any shared instance created for the service
public **attempt** (*mixed* $name, *mixed* $definition, [*mixed* $shared])
-Attempts to register a service in the services container Only is successful if a service hasn't been registered previously with the same name
+Attempts to register a service in the services container
+Only is successful if a service hasn't been registered previously
+with the same name
@@ -99,7 +120,8 @@ Resolves the service based on its configuration
public *mixed* **getShared** (*string* $name, [*array* $parameters])
-Resolves a service, the resolved service is stored in the DI, subsequent requests for this service will return the same instance
+Resolves a service, the resolved service is stored in the DI, subsequent
+requests for this service will return the same instance
@@ -127,9 +149,9 @@ Check if a service is registered using the array syntax
-public *boolean* **offsetSet** (*string* $name, *mixed* $definition)
+public **offsetSet** (*mixed* $name, *mixed* $definition)
-Allows to register a shared service using the array syntax
+Allows to register a shared service using the array syntax
.. code-block:: php
@@ -142,7 +164,7 @@ Allows to register a shared service using the array syntax
public **offsetGet** (*mixed* $name)
-Allows to obtain a shared service using the array syntax
+Allows to obtain a shared service using the array syntax
.. code-block:: php
@@ -159,7 +181,7 @@ Removes a service from the services container using the array syntax
-public **__call** (*string* $method, [*array* $arguments])
+public **__call** (*mixed* $method, [*mixed* $arguments])
Magic method to get or set services using setters/getters
diff --git a/en/api/Phalcon_Di_FactoryDefault.rst b/en/api/Phalcon_Di_FactoryDefault.rst
index c0755449e2d1..fa2efd203098 100644
--- a/en/api/Phalcon_Di_FactoryDefault.rst
+++ b/en/api/Phalcon_Di_FactoryDefault.rst
@@ -10,7 +10,9 @@ Class **Phalcon\\Di\\FactoryDefault**
:raw-html:`Source on GitHub`
-This is a variant of the standard Phalcon\\Di. By default it automatically registers all the services provided by the framework. Thanks to this, the developer does not need to register each service individually providing a full stack framework
+This is a variant of the standard Phalcon\\Di. By default it automatically
+registers all the services provided by the framework. Thanks to this, the developer does not need
+to register each service individually providing a full stack framework
Methods
@@ -48,13 +50,16 @@ Registers an "always shared" service in the services container
public **remove** (*mixed* $name) inherited from :doc:`Phalcon\\Di `
-Removes a service in the services container It also removes any shared instance created for the service
+Removes a service in the services container
+It also removes any shared instance created for the service
public **attempt** (*mixed* $name, *mixed* $definition, [*mixed* $shared]) inherited from :doc:`Phalcon\\Di `
-Attempts to register a service in the services container Only is successful if a service hasn't been registered previously with the same name
+Attempts to register a service in the services container
+Only is successful if a service hasn't been registered previously
+with the same name
@@ -84,7 +89,8 @@ Resolves the service based on its configuration
public *mixed* **getShared** (*string* $name, [*array* $parameters]) inherited from :doc:`Phalcon\\Di `
-Resolves a service, the resolved service is stored in the DI, subsequent requests for this service will return the same instance
+Resolves a service, the resolved service is stored in the DI, subsequent
+requests for this service will return the same instance
@@ -112,9 +118,9 @@ Check if a service is registered using the array syntax
-public *boolean* **offsetSet** (*string* $name, *mixed* $definition) inherited from :doc:`Phalcon\\Di `
+public **offsetSet** (*mixed* $name, *mixed* $definition) inherited from :doc:`Phalcon\\Di `
-Allows to register a shared service using the array syntax
+Allows to register a shared service using the array syntax
.. code-block:: php
@@ -127,7 +133,7 @@ Allows to register a shared service using the array syntax
public **offsetGet** (*mixed* $name) inherited from :doc:`Phalcon\\Di `
-Allows to obtain a shared service using the array syntax
+Allows to obtain a shared service using the array syntax
.. code-block:: php
@@ -144,7 +150,7 @@ Removes a service from the services container using the array syntax
-public **__call** (*string* $method, [*array* $arguments]) inherited from :doc:`Phalcon\\Di `
+public **__call** (*mixed* $method, [*mixed* $arguments]) inherited from :doc:`Phalcon\\Di `
Magic method to get or set services using setters/getters
diff --git a/en/api/Phalcon_Di_FactoryDefault_Cli.rst b/en/api/Phalcon_Di_FactoryDefault_Cli.rst
index 0c1fd2c616f8..6bc613806a53 100644
--- a/en/api/Phalcon_Di_FactoryDefault_Cli.rst
+++ b/en/api/Phalcon_Di_FactoryDefault_Cli.rst
@@ -10,7 +10,10 @@ Class **Phalcon\\Di\\FactoryDefault\\Cli**
:raw-html:`Source on GitHub`
-This is a variant of the standard Phalcon\\Di. By default it automatically registers all the services provided by the framework. Thanks to this, the developer does not need to register each service individually. This class is specially suitable for CLI applications
+This is a variant of the standard Phalcon\\Di. By default it automatically
+registers all the services provided by the framework.
+Thanks to this, the developer does not need to register each service individually.
+This class is specially suitable for CLI applications
Methods
@@ -48,13 +51,16 @@ Registers an "always shared" service in the services container
public **remove** (*mixed* $name) inherited from :doc:`Phalcon\\Di `
-Removes a service in the services container It also removes any shared instance created for the service
+Removes a service in the services container
+It also removes any shared instance created for the service
public **attempt** (*mixed* $name, *mixed* $definition, [*mixed* $shared]) inherited from :doc:`Phalcon\\Di `
-Attempts to register a service in the services container Only is successful if a service hasn't been registered previously with the same name
+Attempts to register a service in the services container
+Only is successful if a service hasn't been registered previously
+with the same name
@@ -84,7 +90,8 @@ Resolves the service based on its configuration
public *mixed* **getShared** (*string* $name, [*array* $parameters]) inherited from :doc:`Phalcon\\Di `
-Resolves a service, the resolved service is stored in the DI, subsequent requests for this service will return the same instance
+Resolves a service, the resolved service is stored in the DI, subsequent
+requests for this service will return the same instance
@@ -112,9 +119,9 @@ Check if a service is registered using the array syntax
-public *boolean* **offsetSet** (*string* $name, *mixed* $definition) inherited from :doc:`Phalcon\\Di `
+public **offsetSet** (*mixed* $name, *mixed* $definition) inherited from :doc:`Phalcon\\Di `
-Allows to register a shared service using the array syntax
+Allows to register a shared service using the array syntax
.. code-block:: php
@@ -127,7 +134,7 @@ Allows to register a shared service using the array syntax
public **offsetGet** (*mixed* $name) inherited from :doc:`Phalcon\\Di `
-Allows to obtain a shared service using the array syntax
+Allows to obtain a shared service using the array syntax
.. code-block:: php
@@ -144,7 +151,7 @@ Removes a service from the services container using the array syntax
-public **__call** (*string* $method, [*array* $arguments]) inherited from :doc:`Phalcon\\Di `
+public **__call** (*mixed* $method, [*mixed* $arguments]) inherited from :doc:`Phalcon\\Di `
Magic method to get or set services using setters/getters
diff --git a/en/api/Phalcon_Di_Injectable.rst b/en/api/Phalcon_Di_Injectable.rst
index 6e70e8d8cb37..d4f17c92d19a 100644
--- a/en/api/Phalcon_Di_Injectable.rst
+++ b/en/api/Phalcon_Di_Injectable.rst
@@ -8,7 +8,8 @@ Abstract class **Phalcon\\Di\\Injectable**
:raw-html:`Source on GitHub`
-This class allows to access services in the services container by just only accessing a public property with the same name of a registered service
+This class allows to access services in the services container by just only accessing a public property
+with the same name of a registered service
Methods
diff --git a/en/api/Phalcon_Di_Service.rst b/en/api/Phalcon_Di_Service.rst
index 923683f09c64..3f6dc4d7f646 100644
--- a/en/api/Phalcon_Di_Service.rst
+++ b/en/api/Phalcon_Di_Service.rst
@@ -8,14 +8,18 @@ Class **Phalcon\\Di\\Service**
:raw-html:`Source on GitHub`
-Represents individually a service in the services container
+Represents individually a service in the services container
.. code-block:: php
resolve();
+ $service = new \Phalcon\Di\Service(
+ "request",
+ "Phalcon\\Http\\Request"
+ );
+
+ $request = service->resolve();
.. code-block:: php
diff --git a/en/api/Phalcon_Dispatcher.rst b/en/api/Phalcon_Dispatcher.rst
index 35a8198767e0..14e17cfb147b 100644
--- a/en/api/Phalcon_Dispatcher.rst
+++ b/en/api/Phalcon_Dispatcher.rst
@@ -8,7 +8,8 @@ Abstract class **Phalcon\\Dispatcher**
:raw-html:`Source on GitHub`
-This is the base class for Phalcon\\Mvc\\Dispatcher and Phalcon\\Cli\\Dispatcher. This class can't be instantiated directly, you can use it to create your own dispatchers.
+This is the base class for Phalcon\\Mvc\\Dispatcher and Phalcon\\Cli\\Dispatcher.
+This class can't be instantiated directly, you can use it to create your own dispatchers.
Constants
@@ -193,13 +194,19 @@ Dispatches a handle action taking into account the routing parameters
public **forward** (*array* $forward)
-Forwards the execution flow to another controller/action Dispatchers are unique per module. Forwarding between modules is not allowed
+Forwards the execution flow to another controller/action
+Dispatchers are unique per module. Forwarding between modules is not allowed
.. code-block:: php
dispatcher->forward(array("controller" => "posts", "action" => "index"));
+ $this->dispatcher->forward(
+ [
+ "controller" => "posts",
+ "action" => "index",
+ ]
+ );
diff --git a/en/api/Phalcon_Escaper.rst b/en/api/Phalcon_Escaper.rst
index 9a7b5dff02eb..38c6b827cd2c 100644
--- a/en/api/Phalcon_Escaper.rst
+++ b/en/api/Phalcon_Escaper.rst
@@ -8,14 +8,19 @@ Class **Phalcon\\Escaper**
:raw-html:`Source on GitHub`
-Escapes different kinds of text securing them. By using this component you may prevent XSS attacks. This component only works with UTF-8. The PREG extension needs to be compiled with UTF-8 support.
+Escapes different kinds of text securing them. By using this component you may
+prevent XSS attacks.
+
+This component only works with UTF-8. The PREG extension needs to be compiled with UTF-8 support.
.. code-block:: php
escapeCss("font-family: ");
+
echo $escaped; // font\2D family\3A \20 \3C Verdana\3E
@@ -25,13 +30,13 @@ Methods
public **setEncoding** (*mixed* $encoding)
-Sets the encoding to be used by the escaper
+Sets the encoding to be used by the escaper
.. code-block:: php
setEncoding('utf-8');
+ $escaper->setEncoding("utf-8");
@@ -44,33 +49,34 @@ Returns the internal encoding used by the escaper
public **setHtmlQuoteType** (*mixed* $quoteType)
-Sets the HTML quoting type for htmlspecialchars
+Sets the HTML quoting type for htmlspecialchars
.. code-block:: php
setHtmlQuoteType(ENT_XHTML);
+ $escaper->setHtmlQuoteType(ENT_XHTML);
public **setDoubleEncode** (*mixed* $doubleEncode)
-Sets the double_encode to be used by the escaper
+Sets the double_encode to be used by the escaper
.. code-block:: php
setDoubleEncode(false);
+ $escaper->setDoubleEncode(false);
final public **detectEncoding** (*mixed* $str)
-Detect the character encoding of a string to be handled by an encoder Special-handling for chr(172) and chr(128) to chr(159) which fail to be detected by mb_detect_encoding()
+Detect the character encoding of a string to be handled by an encoder
+Special-handling for chr(172) and chr(128) to chr(159) which fail to be detected by mb_detect_encoding()
diff --git a/en/api/Phalcon_Events_Event.rst b/en/api/Phalcon_Events_Event.rst
index d42a9ee0b2a5..4f95d29bf37d 100644
--- a/en/api/Phalcon_Events_Event.rst
+++ b/en/api/Phalcon_Events_Event.rst
@@ -40,31 +40,49 @@ Phalcon\\Events\\Event constructor
public **setData** ([*mixed* $data])
-Sets event data
+Sets event data.
public **setType** (*mixed* $type)
-Sets event type
+Sets event type.
public **stop** ()
-Stops the event preventing propagation
+Stops the event preventing propagation.
+
+.. code-block:: php
+
+ isCancelable()) {
+ $event->stop();
+ }
+
public **isStopped** ()
-Check whether the event is currently stopped
+Check whether the event is currently stopped.
public **isCancelable** ()
-Check whether the event is cancelable
+Check whether the event is cancelable.
+
+.. code-block:: php
+
+ isCancelable()) {
+ $event->stop();
+ }
+
diff --git a/en/api/Phalcon_Events_Manager.rst b/en/api/Phalcon_Events_Manager.rst
index ef60a98269be..cf2e621bf034 100644
--- a/en/api/Phalcon_Events_Manager.rst
+++ b/en/api/Phalcon_Events_Manager.rst
@@ -8,7 +8,9 @@ Class **Phalcon\\Events\\Manager**
:raw-html:`Source on GitHub`
-Phalcon Events Manager, offers an easy way to intercept and manipulate, if needed, the normal flow of operation. With the EventsManager the developer can create hooks or plugins that will offer monitoring of data, manipulation, conditional execution and much more.
+Phalcon Events Manager, offers an easy way to intercept and manipulate, if needed,
+the normal flow of operation. With the EventsManager the developer can create hooks or
+plugins that will offer monitoring of data, manipulation, conditional execution and much more.
Methods
@@ -40,13 +42,15 @@ Returns if priorities are enabled
public **collectResponses** (*mixed* $collect)
-Tells the event manager if it needs to collect all the responses returned by every registered listener in a single fire
+Tells the event manager if it needs to collect all the responses returned by every
+registered listener in a single fire
public **isCollecting** ()
-Check if the events manager is collecting all all the responses returned by every registered listener in a single fire
+Check if the events manager is collecting all all the responses returned by every
+registered listener in a single fire
@@ -70,13 +74,13 @@ Internal handler to call a queue of events
public *mixed* **fire** (*string* $eventType, *object* $source, [*mixed* $data], [*boolean* $cancelable])
-Fires an event in the events manager causing the active listeners to be notified about it
+Fires an event in the events manager causing the active listeners to be notified about it
.. code-block:: php
fire('db', $connection);
+ $eventsManager->fire("db", $connection);
diff --git a/en/api/Phalcon_Filter.rst b/en/api/Phalcon_Filter.rst
index f96f3bb37b37..c4a6c87c3eb0 100644
--- a/en/api/Phalcon_Filter.rst
+++ b/en/api/Phalcon_Filter.rst
@@ -8,13 +8,16 @@ Class **Phalcon\\Filter**
:raw-html:`Source on GitHub`
-The Phalcon\\Filter component provides a set of commonly needed data filters. It provides object oriented wrappers to the php filter extension. Also allows the developer to define his/her own filters
+The Phalcon\\Filter component provides a set of commonly needed data filters. It provides
+object oriented wrappers to the php filter extension. Also allows the developer to
+define his/her own filters
.. code-block:: php
sanitize("some(one)@exa\\mple.com", "email"); // returns "someone@example.com"
$filter->sanitize("hello<<", "string"); // returns "hello"
$filter->sanitize("!100a019", "int"); // returns "100019"
diff --git a/en/api/Phalcon_Flash.rst b/en/api/Phalcon_Flash.rst
index 80983e65b995..0f3465dbbdb2 100644
--- a/en/api/Phalcon_Flash.rst
+++ b/en/api/Phalcon_Flash.rst
@@ -1,21 +1,21 @@
Abstract class **Phalcon\\Flash**
=================================
-*implements* :doc:`Phalcon\\Di\\InjectionAwareInterface `
+*implements* :doc:`Phalcon\\FlashInterface `, :doc:`Phalcon\\Di\\InjectionAwareInterface `
.. role:: raw-html(raw)
:format: html
:raw-html:`Source on GitHub`
-Shows HTML notifications related to different circumstances. Classes can be stylized using CSS
+Shows HTML notifications related to different circumstances. Classes can be stylized using CSS
.. code-block:: php
success("The record was successfully deleted");
- $flash->error("Cannot open the file");
+ $flash->success("The record was successfully deleted");
+ $flash->error("Cannot open the file");
@@ -84,65 +84,65 @@ Set an array with CSS classes to format the messages
public **error** (*mixed* $message)
-Shows a HTML error message
+Shows a HTML error message
.. code-block:: php
error('This is an error');
+ $flash->error("This is an error");
public **notice** (*mixed* $message)
-Shows a HTML notice/information message
+Shows a HTML notice/information message
.. code-block:: php
notice('This is an information');
+ $flash->notice("This is an information");
public **success** (*mixed* $message)
-Shows a HTML success message
+Shows a HTML success message
.. code-block:: php
success('The process was finished successfully');
+ $flash->success("The process was finished successfully");
public **warning** (*mixed* $message)
-Shows a HTML warning message
+Shows a HTML warning message
.. code-block:: php
warning('Hey, this is important');
+ $flash->warning("Hey, this is important");
public *string* | *void* **outputMessage** (*mixed* $type, *string* | *array* $message)
-Outputs a message formatting it with HTML
+Outputs a message formatting it with HTML
.. code-block:: php
outputMessage('error', message);
+ $flash->outputMessage("error", $message);
@@ -153,3 +153,8 @@ Clears accumulated messages when implicit flush is disabled
+abstract public **message** (*mixed* $type, *mixed* $message) inherited from :doc:`Phalcon\\FlashInterface `
+
+...
+
+
diff --git a/en/api/Phalcon_Flash_Direct.rst b/en/api/Phalcon_Flash_Direct.rst
index 94fed7171560..acb58ea9eebc 100644
--- a/en/api/Phalcon_Flash_Direct.rst
+++ b/en/api/Phalcon_Flash_Direct.rst
@@ -90,65 +90,65 @@ Set an array with CSS classes to format the messages
public **error** (*mixed* $message) inherited from :doc:`Phalcon\\Flash `
-Shows a HTML error message
+Shows a HTML error message
.. code-block:: php
error('This is an error');
+ $flash->error("This is an error");
public **notice** (*mixed* $message) inherited from :doc:`Phalcon\\Flash `
-Shows a HTML notice/information message
+Shows a HTML notice/information message
.. code-block:: php
notice('This is an information');
+ $flash->notice("This is an information");
public **success** (*mixed* $message) inherited from :doc:`Phalcon\\Flash `
-Shows a HTML success message
+Shows a HTML success message
.. code-block:: php
success('The process was finished successfully');
+ $flash->success("The process was finished successfully");
public **warning** (*mixed* $message) inherited from :doc:`Phalcon\\Flash `
-Shows a HTML warning message
+Shows a HTML warning message
.. code-block:: php
warning('Hey, this is important');
+ $flash->warning("Hey, this is important");
public *string* | *void* **outputMessage** (*mixed* $type, *string* | *array* $message) inherited from :doc:`Phalcon\\Flash `
-Outputs a message formatting it with HTML
+Outputs a message formatting it with HTML
.. code-block:: php
outputMessage('error', message);
+ $flash->outputMessage("error", $message);
diff --git a/en/api/Phalcon_Flash_Session.rst b/en/api/Phalcon_Flash_Session.rst
index f5205dfa4333..c64033e999d6 100644
--- a/en/api/Phalcon_Flash_Session.rst
+++ b/en/api/Phalcon_Flash_Session.rst
@@ -120,65 +120,65 @@ Set an array with CSS classes to format the messages
public **error** (*mixed* $message) inherited from :doc:`Phalcon\\Flash `
-Shows a HTML error message
+Shows a HTML error message
.. code-block:: php
error('This is an error');
+ $flash->error("This is an error");
public **notice** (*mixed* $message) inherited from :doc:`Phalcon\\Flash `
-Shows a HTML notice/information message
+Shows a HTML notice/information message
.. code-block:: php
notice('This is an information');
+ $flash->notice("This is an information");
public **success** (*mixed* $message) inherited from :doc:`Phalcon\\Flash `
-Shows a HTML success message
+Shows a HTML success message
.. code-block:: php
success('The process was finished successfully');
+ $flash->success("The process was finished successfully");
public **warning** (*mixed* $message) inherited from :doc:`Phalcon\\Flash `
-Shows a HTML warning message
+Shows a HTML warning message
.. code-block:: php
warning('Hey, this is important');
+ $flash->warning("Hey, this is important");
public *string* | *void* **outputMessage** (*mixed* $type, *string* | *array* $message) inherited from :doc:`Phalcon\\Flash `
-Outputs a message formatting it with HTML
+Outputs a message formatting it with HTML
.. code-block:: php
outputMessage('error', message);
+ $flash->outputMessage("error", $message);
diff --git a/en/api/Phalcon_Forms_Element.rst b/en/api/Phalcon_Forms_Element.rst
index dcd61de52682..5ea3b054a418 100644
--- a/en/api/Phalcon_Forms_Element.rst
+++ b/en/api/Phalcon_Forms_Element.rst
@@ -82,7 +82,8 @@ Returns the validators registered for the element
public **prepareAttributes** ([*array* $attributes], [*mixed* $useChecked])
-Returns an array of prepared attributes for Phalcon\\Tag helpers according to the element parameters
+Returns an array of prepared attributes for Phalcon\\Tag helpers
+according to the element parameters
@@ -154,7 +155,8 @@ Generate the HTML to label the element
public :doc:`Phalcon\\Forms\\ElementInterface ` **setDefault** (*mixed* $value)
-Sets a default value in case the form does not use an entity or there is no value available for the element in _POST
+Sets a default value in case the form does not use an entity
+or there is no value available for the element in _POST
@@ -172,7 +174,8 @@ Returns the element value
public **getMessages** ()
-Returns the messages that belongs to the element The element needs to be attached to a form
+Returns the messages that belongs to the element
+The element needs to be attached to a form
diff --git a/en/api/Phalcon_Forms_Element_Check.rst b/en/api/Phalcon_Forms_Element_Check.rst
index a216f03d7622..d6479dc71302 100644
--- a/en/api/Phalcon_Forms_Element_Check.rst
+++ b/en/api/Phalcon_Forms_Element_Check.rst
@@ -90,7 +90,8 @@ Returns the validators registered for the element
public **prepareAttributes** ([*array* $attributes], [*mixed* $useChecked]) inherited from :doc:`Phalcon\\Forms\\Element `
-Returns an array of prepared attributes for Phalcon\\Tag helpers according to the element parameters
+Returns an array of prepared attributes for Phalcon\\Tag helpers
+according to the element parameters
@@ -162,7 +163,8 @@ Generate the HTML to label the element
public :doc:`Phalcon\\Forms\\ElementInterface ` **setDefault** (*mixed* $value) inherited from :doc:`Phalcon\\Forms\\Element `
-Sets a default value in case the form does not use an entity or there is no value available for the element in _POST
+Sets a default value in case the form does not use an entity
+or there is no value available for the element in _POST
@@ -180,7 +182,8 @@ Returns the element value
public **getMessages** () inherited from :doc:`Phalcon\\Forms\\Element `
-Returns the messages that belongs to the element The element needs to be attached to a form
+Returns the messages that belongs to the element
+The element needs to be attached to a form
diff --git a/en/api/Phalcon_Forms_Element_Date.rst b/en/api/Phalcon_Forms_Element_Date.rst
index 81a1eda61726..00e6a0f10d8d 100644
--- a/en/api/Phalcon_Forms_Element_Date.rst
+++ b/en/api/Phalcon_Forms_Element_Date.rst
@@ -90,7 +90,8 @@ Returns the validators registered for the element
public **prepareAttributes** ([*array* $attributes], [*mixed* $useChecked]) inherited from :doc:`Phalcon\\Forms\\Element `
-Returns an array of prepared attributes for Phalcon\\Tag helpers according to the element parameters
+Returns an array of prepared attributes for Phalcon\\Tag helpers
+according to the element parameters
@@ -162,7 +163,8 @@ Generate the HTML to label the element
public :doc:`Phalcon\\Forms\\ElementInterface ` **setDefault** (*mixed* $value) inherited from :doc:`Phalcon\\Forms\\Element `
-Sets a default value in case the form does not use an entity or there is no value available for the element in _POST
+Sets a default value in case the form does not use an entity
+or there is no value available for the element in _POST
@@ -180,7 +182,8 @@ Returns the element value
public **getMessages** () inherited from :doc:`Phalcon\\Forms\\Element `
-Returns the messages that belongs to the element The element needs to be attached to a form
+Returns the messages that belongs to the element
+The element needs to be attached to a form
diff --git a/en/api/Phalcon_Forms_Element_Email.rst b/en/api/Phalcon_Forms_Element_Email.rst
index b90039addd71..a591d491e8fd 100644
--- a/en/api/Phalcon_Forms_Element_Email.rst
+++ b/en/api/Phalcon_Forms_Element_Email.rst
@@ -90,7 +90,8 @@ Returns the validators registered for the element
public **prepareAttributes** ([*array* $attributes], [*mixed* $useChecked]) inherited from :doc:`Phalcon\\Forms\\Element `
-Returns an array of prepared attributes for Phalcon\\Tag helpers according to the element parameters
+Returns an array of prepared attributes for Phalcon\\Tag helpers
+according to the element parameters
@@ -162,7 +163,8 @@ Generate the HTML to label the element
public :doc:`Phalcon\\Forms\\ElementInterface ` **setDefault** (*mixed* $value) inherited from :doc:`Phalcon\\Forms\\Element