diff --git a/phalcon/db.zep b/phalcon/db.zep index 0b526094486..56fec211598 100644 --- a/phalcon/db.zep +++ b/phalcon/db.zep @@ -33,11 +33,14 @@ use \PDO as Pdo; * * Phalcon\Db is an abstract class. You only can use it with a database adapter like Phalcon\Db\Adapter\Pdo * - * + * + *use Phalcon\Db; + *use Phalcon\Db\Exception; + *use Phalcon\Db\Adapter\Pdo\Mysql as MysqlConnection; * *try { * - * $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array( + * $connection = new MysqlConnection(array( * 'host' => '192.168.0.11', * 'username' => 'sigma', * 'password' => 'secret', @@ -46,15 +49,14 @@ use \PDO as Pdo; * )); * * $result = $connection->query("SELECT * FROM robots LIMIT 5"); - * $result->setFetchMode(Phalcon\Db::FETCH_NUM); + * $result->setFetchMode(Db::FETCH_NUM); * while ($robot = $result->fetch()) { * print_r($robot); * } * - *} catch (Phalcon\Db\Exception $e) { + *} catch (Exception $e) { * echo $e->getMessage(), PHP_EOL; - *} - * + *} * */ abstract class Db diff --git a/phalcon/image.zep b/phalcon/image.zep index c2bc23909db..c536714461e 100644 --- a/phalcon/image.zep +++ b/phalcon/image.zep @@ -21,10 +21,7 @@ namespace Phalcon; class Image { - - /* - * Resizing constraints - */ + // Resizing constraints const NONE = 1; const WIDTH = 2; const HEIGHT = 3; diff --git a/phalcon/mvc/model/criteria.zep b/phalcon/mvc/model/criteria.zep index c1e2ce41f6f..1244b01e018 100644 --- a/phalcon/mvc/model/criteria.zep +++ b/phalcon/mvc/model/criteria.zep @@ -26,7 +26,6 @@ use Phalcon\Di\InjectionAwareInterface; use Phalcon\Mvc\Model\CriteriaInterface; use Phalcon\Mvc\Model\ResultsetInterface; - /** * Phalcon\Mvc\Model\Criteria * diff --git a/phalcon/mvc/model/query.zep b/phalcon/mvc/model/query.zep index 6be8ba06b5a..de456846e0e 100644 --- a/phalcon/mvc/model/query.zep +++ b/phalcon/mvc/model/query.zep @@ -753,15 +753,12 @@ class Query implements QueryInterface, InjectionAwareInterface /** * Resolves a column from its intermediate representation into an array used to determine * if the resultset produced is simple or complex - * - * @param array column - * @return array */ - protected final function _getSelectColumn(array! column) + protected final function _getSelectColumn(array! column) -> array { var sqlColumns, columnType, sqlAliases, modelName, source, columnDomain, sqlColumnAlias, preparedAlias, sqlExprColumn, - sqlAliasesModels, sqlColumn, columnData, balias; + sqlAliasesModels, sqlColumn, columnData, balias, eager; if !fetch columnType, column["type"] { throw new Exception("Corrupted SELECT AST"); @@ -769,16 +766,29 @@ class Query implements QueryInterface, InjectionAwareInterface let sqlColumns = []; + /** + * Check if column is eager loaded + */ + fetch eager, column["eager"]; + /** * Check for select * (all) */ if columnType == PHQL_T_STARALL { for modelName, source in this->_models { - let sqlColumns[] = [ + + let sqlColumn = [ "type" : "object", "model" : modelName, - "column": source + "column": source, + "balias": lcfirst(modelName) ]; + + if eager !== null { + let sqlColumn["eager"] = eager; + } + + let sqlColumns[] = sqlColumn; } return sqlColumns; } @@ -826,13 +836,19 @@ class Query implements QueryInterface, InjectionAwareInterface /** * Each item is a complex type returning a complete object */ - let sqlColumns[] = [ + let sqlColumn = [ "type": "object", "model": modelName, "column": sqlColumnAlias, "balias": preparedAlias ]; + if eager !== null { + let sqlColumn["eager"] = eager; + } + + let sqlColumns[] = sqlColumn; + return sqlColumns; } @@ -856,6 +872,10 @@ class Query implements QueryInterface, InjectionAwareInterface sqlColumn["sqlAlias"] = balias; } + if eager !== null { + let sqlColumn["eager"] = eager; + } + let sqlColumn["column"] = sqlExprColumn, sqlColumns[] = sqlColumn; @@ -1834,7 +1854,8 @@ class Query implements QueryInterface, InjectionAwareInterface let selectColumns[] = [ "type": PHQL_T_DOMAINALL, - "column": "AA" . number + "column": "AA" . number, + "eager": alias ]; let automaticJoins[] = [ @@ -1928,7 +1949,7 @@ class Query implements QueryInterface, InjectionAwareInterface } else { /** - * "balias" is the best alias selected for the column + * "balias" is the best alias choosen for the column */ if fetch alias, sqlColumn["balias"] { let sqlColumns[alias] = sqlColumn; diff --git a/phalcon/mvc/model/resultset/complex.zep b/phalcon/mvc/model/resultset/complex.zep index 2fc56e25efb..d3414d338eb 100644 --- a/phalcon/mvc/model/resultset/complex.zep +++ b/phalcon/mvc/model/resultset/complex.zep @@ -1,31 +1,31 @@ /* +------------------------------------------------------------------------+ - | Phalcon Framework | + | Phalcon Framework | +------------------------------------------------------------------------+ - | Copyright (c) 2011-2015 Phalcon Team (http://www.phalconphp.com) | + | Copyright (c) 2011-2015 Phalcon Team (http://www.phalconphp.com) | +------------------------------------------------------------------------+ | This source file is subject to the New BSD License that is bundled | - | with this package in the file docs/LICENSE.txt. | - | | | - | If you did not receive a copy of the license and are unable to | - | obtain it through the world-wide-web, please send an email | - | to license@phalconphp.com so we can send you a copy immediately. | + | with this package in the file docs/LICENSE.txt. | + | | + | If you did not receive a copy of the license and are unable to | + | obtain it through the world-wide-web, please send an email | + | to license@phalconphp.com so we can send you a copy immediately. | +------------------------------------------------------------------------+ - | Authors: Andres Gutierrez | - | Eduar Carvajal | + | Authors: Andres Gutierrez | + | Eduar Carvajal | +------------------------------------------------------------------------+ */ namespace Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model; +use Phalcon\Mvc\Model\Row; +use Phalcon\Db\ResultInterface; use Phalcon\Mvc\Model\Resultset; -use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\Exception; use Phalcon\Cache\BackendInterface; -use Phalcon\Db\ResultInterface; -use Phalcon\Mvc\Model\Row; +use Phalcon\Mvc\Model\ResultsetInterface; /** * Phalcon\Mvc\Model\Resultset\Complex @@ -196,7 +196,7 @@ class Complex extends Resultset implements ResultsetInterface // Other kinds of hydrations let value = Model::cloneResultMapHydrate(rowModel, columnMap, hydrateMode); break; - } + } /** * The complete object is assigned to an attribute with the name of the alias or the model name