Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutierrez committed Aug 6, 2015
1 parent 3ca2504 commit 47b392c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 34 deletions.
14 changes: 8 additions & 6 deletions phalcon/db.zep
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
* <code>
*<code>
*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',
Expand All @@ -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;
*}
*
*}
* </code>
*/
abstract class Db
Expand Down
5 changes: 1 addition & 4 deletions phalcon/image.zep
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ namespace Phalcon;

class Image
{

/*
* Resizing constraints
*/
// Resizing constraints
const NONE = 1;
const WIDTH = 2;
const HEIGHT = 3;
Expand Down
1 change: 0 additions & 1 deletion phalcon/mvc/model/criteria.zep
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use Phalcon\Di\InjectionAwareInterface;
use Phalcon\Mvc\Model\CriteriaInterface;
use Phalcon\Mvc\Model\ResultsetInterface;


/**
* Phalcon\Mvc\Model\Criteria
*
Expand Down
41 changes: 31 additions & 10 deletions phalcon/mvc/model/query.zep
Original file line number Diff line number Diff line change
Expand Up @@ -753,32 +753,42 @@ 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");
}

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;
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;

Expand Down Expand Up @@ -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[] = [
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 13 additions & 13 deletions phalcon/mvc/model/resultset/complex.zep
Original file line number Diff line number Diff line change
@@ -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 <andres@phalconphp.com> |
| Eduar Carvajal <eduar@phalconphp.com> |
| Authors: Andres Gutierrez <andres@phalconphp.com> |
| Eduar Carvajal <eduar@phalconphp.com> |
+------------------------------------------------------------------------+
*/

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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 47b392c

Please sign in to comment.