Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phalcon\Mvc\Query\Builder's constructor sample code in comment + support... #1205

Merged
merged 1 commit into from
Sep 7, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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