Skip to content

Commit

Permalink
Merge pull request #1205 from Emanuel1989/1.3.0
Browse files Browse the repository at this point in the history
Phalcon\Mvc\Query\Builder's constructor sample code in comment + support...
  • Loading branch information
Phalcon committed Sep 7, 2013
2 parents b5d6267 + a870ae7 commit b6729c4
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions ext/mvc/model/query/builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,29 @@ PHALCON_INIT_CLASS(Phalcon_Mvc_Model_Query_Builder){
/**
* Phalcon\Mvc\Model\Query\Builder constructor
*
*<code>
* $params = array(
* 'models' => array('Users'),
* 'columns' => array('id', 'name', 'status'),
* 'conditions' => "created > '2013-01-01' AND created < '2014-01-01'",
* 'group' => array('id', 'name'),
* 'having' => "name = 'Kamil'",
* 'order' => array('name', 'id'),
* 'limit' => 20,
* 'offset' => 20,
*);
*$queryBuilder = new Phalcon\Mvc\Model\Query\Builder($params);
*</code>
*
* @param array $params
* @param Phalcon\DI $dependencyInjector
*/
PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, __construct){

zval *params = NULL, *dependency_injector = NULL, *conditions = NULL;
zval *columns, *group_clause, *having_clause;
zval *order_clause, *limit_clause, *for_update;
zval *shared_lock;
zval *models, *columns, *group_clause;
zval *having_clause, *order_clause, *limit_clause;
zval *offset_clause, *for_update, *shared_lock;

phalcon_fetch_params(0, 0, 2, &params, &dependency_injector);

Expand All @@ -115,7 +129,14 @@ PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, __construct){
} else if (phalcon_array_isset_string_fetch(&conditions, params, SS("conditions"))) {
phalcon_update_property_this(this_ptr, SL("_conditions"), conditions TSRMLS_CC);
}


/**
* Assign 'FROM' clause
*/
if (phalcon_array_isset_string_fetch(&models, params, SS("models"))) {
phalcon_update_property_this(this_ptr, SL("_models"), models TSRMLS_CC);
}

/**
* Assign COLUMNS clause
*/
Expand Down Expand Up @@ -150,7 +171,14 @@ PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, __construct){
if (phalcon_array_isset_string_fetch(&limit_clause, params, SS("limit"))) {
phalcon_update_property_this(this_ptr, SL("_limit"), limit_clause TSRMLS_CC);
}


/**
* Assign OFFSET clause
*/
if (phalcon_array_isset_string_fetch(&offset_clause, params, SS("offset"))) {
phalcon_update_property_this(this_ptr, SL("_offset"), offset_clause TSRMLS_CC);
}

/**
* Assign FOR UPDATE clause
*/
Expand Down

0 comments on commit b6729c4

Please sign in to comment.