/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_StringLength, validate) { zend_bool _1; zephir_fcall_cache_entry *_10 = NULL, *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *isSetMin = NULL, *isSetMax = NULL, *value = NULL, *length = NULL, *message = NULL, *minimum = NULL, *maximum = NULL, *label = NULL, *replacePairs = NULL, *code = NULL, *_0 = NULL, *_2$$4, *_3$$6, *_4$$9, *_5$$10, *_6$$11 = NULL, *_9$$11 = NULL, *_11$$11, *_7$$12, *_8$$13, *_13$$14, *_14$$15, *_15$$16 = NULL, *_18$$16 = NULL, *_19$$16, *_16$$17, *_17$$18; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMin, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMax, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _1 = !zephir_is_true(isSetMin); if (_1) { _1 = !zephir_is_true(isSetMax); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A minimum or maximum must be set", "phalcon/validation/validator/stringlength.zep", 92); return; } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(label) == IS_ARRAY) { zephir_array_fetch(&_2$$4, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 98 TSRMLS_CC); ZEPHIR_CPY_WRT(label, _2$$4); } if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(code) == IS_ARRAY) { zephir_array_fetch(&_3$$6, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 106 TSRMLS_CC); ZEPHIR_CPY_WRT(code, _3$$6); } if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 382, value); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(value)); } if (zephir_is_true(isSetMax)) { ZEPHIR_INIT_VAR(_4$$9); ZVAL_STRING(_4$$9, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _4$$9); zephir_check_temp_parameter(_4$$9); zephir_check_call_status(); if (Z_TYPE_P(maximum) == IS_ARRAY) { zephir_array_fetch(&_5$$10, maximum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 123 TSRMLS_CC); ZEPHIR_CPY_WRT(maximum, _5$$10); } if (ZEPHIR_GT(length, maximum)) { ZEPHIR_INIT_VAR(_6$$11); ZVAL_STRING(_6$$11, "messageMaximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _6$$11); zephir_check_temp_parameter(_6$$11); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_7$$12, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 132 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _7$$12); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_8$$13); ZVAL_STRING(_8$$13, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _8$$13); zephir_check_temp_parameter(_8$$13); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_6$$11); object_init_ex(_6$$11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_9$$11, "strtr", &_10, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_11$$11); ZVAL_STRING(_11$$11, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _6$$11, "__construct", &_12, 466, _9$$11, field, _11$$11, code); zephir_check_temp_parameter(_11$$11); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _6$$11); zephir_check_call_status(); RETURN_MM_BOOL(0); } } if (zephir_is_true(isSetMin)) { ZEPHIR_INIT_VAR(_13$$14); ZVAL_STRING(_13$$14, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _13$$14); zephir_check_temp_parameter(_13$$14); zephir_check_call_status(); if (Z_TYPE_P(minimum) == IS_ARRAY) { zephir_array_fetch(&_14$$15, minimum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 159 TSRMLS_CC); ZEPHIR_CPY_WRT(minimum, _14$$15); } if (ZEPHIR_LT(length, minimum)) { ZEPHIR_INIT_VAR(_15$$16); ZVAL_STRING(_15$$16, "messageMinimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _15$$16); zephir_check_temp_parameter(_15$$16); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_16$$17, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 168 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _16$$17); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_17$$18); ZVAL_STRING(_17$$18, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _17$$18); zephir_check_temp_parameter(_17$$18); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_15$$16); object_init_ex(_15$$16, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_18$$16, "strtr", &_10, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_19$$16); ZVAL_STRING(_19$$16, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _15$$16, "__construct", &_12, 466, _18$$16, field, _19$$16, code); zephir_check_temp_parameter(_19$$16); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _15$$16); zephir_check_call_status(); RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); }
/** * 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> * //Querying data * $resultset = $connection->query("SELECT * FROM robots WHERE type='mechanical'"); * $resultset = $connection->query("SELECT * FROM robots WHERE type=?", array("mechanical")); *</code> * * @param string sqlStatement * @param array bindParams * @param array bindTypes * @return Phalcon\Db\ResultInterface|bool */ PHP_METHOD(Phalcon_Db_Adapter_Pdo, query) { zephir_nts_static zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *sqlStatement_param = NULL, *bindParams = NULL, *bindTypes = NULL, *eventsManager = NULL, *pdo = NULL, *statement = NULL, *_0, *_1 = NULL, *_2 = NULL; zval *sqlStatement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &sqlStatement_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(sqlStatement_param) != IS_STRING && Z_TYPE_P(sqlStatement_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlStatement' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { zephir_get_strval(sqlStatement, sqlStatement_param); } else { ZEPHIR_INIT_VAR(sqlStatement); ZVAL_EMPTY_STRING(sqlStatement); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_sqlStatement"), sqlStatement TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlVariables"), bindParams TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlBindTypes"), bindTypes TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "db:beforeQuery", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, _2, this_ptr, bindParams); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdo"), PH_NOISY_CC); ZEPHIR_CPY_WRT(pdo, _0); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&statement, pdo, "prepare", NULL, sqlStatement); zephir_check_call_status(); if (Z_TYPE_P(statement) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_1, this_ptr, "executeprepared", NULL, statement, bindParams, bindTypes); zephir_check_call_status(); ZEPHIR_CPY_WRT(statement, _1); } } else { ZEPHIR_CALL_METHOD(&statement, pdo, "query", NULL, sqlStatement); zephir_check_call_status(); } if (Z_TYPE_P(statement) == IS_OBJECT) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "db:afterQuery", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, _2, this_ptr, bindParams); zephir_check_temp_parameter(_2); zephir_check_call_status(); } object_init_ex(return_value, phalcon_db_result_pdo_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_3, this_ptr, statement, sqlStatement, bindParams, bindTypes); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(statement); }
/** * Converts bound parameters such as :name: or ?1 into PDO bind params ? * *<code> * print_r($connection->convertBoundParams('SELECT * FROM robots WHERE name = :name:', array('Bender'))); *</code> */ PHP_METHOD(Phalcon_Db_Adapter_Pdo, convertBoundParams) { HashTable *_4; HashPosition _3; zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_8 = NULL; int setOrder, ZEPHIR_LAST_CALL_STATUS; zval *params = NULL; zval *sql_param = NULL, *params_param = NULL, *boundSql = NULL, *placeHolders, *bindPattern, *matches, *placeMatch = NULL, *value = NULL, *_0 = NULL, *_1 = NULL, **_5, *_6, *_7; zval *sql = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &sql_param, ¶ms_param); if (unlikely(Z_TYPE_P(sql_param) != IS_STRING && Z_TYPE_P(sql_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sql' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sql_param) == IS_STRING)) { zephir_get_strval(sql, sql_param); } else { ZEPHIR_INIT_VAR(sql); ZVAL_EMPTY_STRING(sql); } if (!params_param) { ZEPHIR_INIT_VAR(params); array_init(params); } else { zephir_get_arrval(params, params_param); } ZEPHIR_INIT_VAR(placeHolders); array_init(placeHolders); ZEPHIR_INIT_VAR(bindPattern); ZVAL_STRING(bindPattern, "/\\?([0-9]+)|:([a-zA-Z0-9_]+):/", 1); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); setOrder = 2; ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, setOrder); Z_SET_ISREF_P(matches); ZEPHIR_CALL_FUNCTION(&_1, "preg_match_all", &_2, bindPattern, sql, matches, _0); Z_UNSET_ISREF_P(matches); zephir_check_call_status(); if (zephir_is_true(_1)) { zephir_is_iterable(matches, &_4, &_3, 0, 0, "phalcon/db/adapter/pdo.zep", 438); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(placeMatch, _5); ZEPHIR_OBS_NVAR(value); zephir_array_fetch_long(&_6, placeMatch, 1, PH_READONLY, "phalcon/db/adapter/pdo.zep", 424 TSRMLS_CC); if (!(zephir_array_isset_fetch(&value, params, _6, 0 TSRMLS_CC))) { if (zephir_array_isset_long(placeMatch, 2)) { ZEPHIR_OBS_NVAR(value); zephir_array_fetch_long(&_7, placeMatch, 2, PH_READONLY, "phalcon/db/adapter/pdo.zep", 426 TSRMLS_CC); if (!(zephir_array_isset_fetch(&value, params, _7, 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter wasn't found in parameters list", "phalcon/db/adapter/pdo.zep", 427); return; } } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter wasn't found in parameters list", "phalcon/db/adapter/pdo.zep", 430); return; } } zephir_array_append(&placeHolders, value, PH_SEPARATE, "phalcon/db/adapter/pdo.zep", 434); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "?", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&boundSql, "preg_replace", &_8, bindPattern, _0, sql); zephir_check_temp_parameter(_0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(boundSql, sql); } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_update_string(&return_value, SL("sql"), &boundSql, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("params"), &placeHolders, PH_COPY | PH_SEPARATE); RETURN_MM(); }
/** * Returns a complete resultset as an array, if the resultset has a big number of rows * it could consume more memory than currently it does. Export the resultset to an array * couldn't be faster with a large number of records */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray) { zephir_fcall_cache_entry *_10 = NULL; HashTable *_3, *_6; HashPosition _2, _5; int ZEPHIR_LAST_CALL_STATUS; zval *renameColumns_param = NULL, *result = NULL, *records = NULL, *record = NULL, *renamed = NULL, *renamedKey = NULL, *key = NULL, *value = NULL, *renamedRecords, *columnMap, *_0, *_1, **_4, **_7, *_8 = NULL, *_9 = NULL; zend_bool renameColumns; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &renameColumns_param); if (!renameColumns_param) { renameColumns = 1; } else { renameColumns = zephir_get_boolval(renameColumns_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_OBS_VAR(result); zephir_read_property_this(&result, this_ptr, SL("_result"), PH_NOISY_CC); if (Z_TYPE_P(result) == IS_OBJECT) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_row"), PH_NOISY_CC); if (Z_TYPE_P(_1) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, result, "execute", NULL); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&records, result, "fetchall", NULL); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_row"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(records); array_init(records); } } else { ZEPHIR_OBS_NVAR(records); zephir_read_property_this(&records, this_ptr, SL("_rows"), PH_NOISY_CC); if (Z_TYPE_P(records) != IS_ARRAY) { ZEPHIR_OBS_NVAR(result); zephir_read_property_this(&result, this_ptr, SL("_result"), PH_NOISY_CC); if (Z_TYPE_P(result) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&records, result, "fetchall", NULL); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_rows"), records TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(records); array_init(records); } } } if (renameColumns) { ZEPHIR_OBS_VAR(columnMap); zephir_read_property_this(&columnMap, this_ptr, SL("_columnMap"), PH_NOISY_CC); if (Z_TYPE_P(columnMap) != IS_ARRAY) { RETURN_CCTOR(records); } ZEPHIR_INIT_VAR(renamedRecords); array_init(renamedRecords); if (Z_TYPE_P(records) == IS_ARRAY) { zephir_is_iterable(records, &_3, &_2, 0, 0, "phalcon/mvc/model/resultset/simple.zep", 263); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(record, _4); ZEPHIR_INIT_NVAR(renamed); array_init(renamed); zephir_is_iterable(record, &_6, &_5, 0, 0, "phalcon/mvc/model/resultset/simple.zep", 261); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HMKEY(key, _6, _5); ZEPHIR_GET_HVALUE(value, _7); ZEPHIR_OBS_NVAR(renamedKey); if (!(zephir_array_isset_fetch(&renamedKey, columnMap, key, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVS(_9, "Column '", key, "' is not part of the column map"); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", &_10, _9); zephir_check_call_status(); zephir_throw_exception_debug(_8, "phalcon/mvc/model/resultset/simple.zep", 249 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_array_update_zval(&renamed, renamedKey, &value, PH_COPY | PH_SEPARATE); } zephir_array_append(&renamedRecords, renamed, PH_SEPARATE, "phalcon/mvc/model/resultset/simple.zep", 261); } } RETURN_CCTOR(renamedRecords); } RETURN_CCTOR(records); }
/** * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. * Call it when you need to restore a database connection * *<code> * //Make a connection * $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array( * 'host' => '192.168.0.11', * 'username' => 'sigma', * 'password' => 'secret', * 'dbname' => 'blog', * )); * * //Reconnect * $connection->connect(); * </code> * * @param array descriptor * @return boolean */ PHP_METHOD(Phalcon_Db_Adapter_Pdo, connect) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *descriptor = NULL, *username = NULL, *password = NULL, *dsnParts, *dsnAttributes = NULL, *persistent, *options = NULL, *key = NULL, *value = NULL, **_2, *_3 = NULL, *_4, *_5, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &descriptor); if (!descriptor) { ZEPHIR_CPY_WRT(descriptor, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(descriptor); } if (Z_TYPE_P(descriptor) == IS_NULL) { ZEPHIR_OBS_NVAR(descriptor); zephir_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(username); if (zephir_array_isset_string_fetch(&username, descriptor, SS("username"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("username"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(username); ZVAL_NULL(username); } ZEPHIR_OBS_VAR(password); if (zephir_array_isset_string_fetch(&password, descriptor, SS("password"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("password"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(password); ZVAL_NULL(password); } ZEPHIR_OBS_VAR(options); if (zephir_array_isset_string_fetch(&options, descriptor, SS("options"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("options"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(options); array_init(options); } ZEPHIR_OBS_VAR(dsnAttributes); if (!(zephir_array_isset_string_fetch(&dsnAttributes, descriptor, SS("dsn"), 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(dsnParts); array_init(dsnParts); zephir_is_iterable(descriptor, &_1, &_0, 0, 0, "phalcon/db/adapter/pdo.zep", 130); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_VSV(_3, key, "=", value); zephir_array_append(&dsnParts, _3, PH_SEPARATE, "phalcon/db/adapter/pdo.zep", 128); } ZEPHIR_INIT_NVAR(dsnAttributes); zephir_fast_join_str(dsnAttributes, SL(";"), dsnParts TSRMLS_CC); } ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, 2); zephir_array_update_long(&options, 3, &_4, PH_COPY | PH_SEPARATE, "phalcon/db/adapter/pdo.zep", 133); if (zephir_array_isset_string_fetch(&persistent, descriptor, SS("persistent"), 1 TSRMLS_CC)) { if (zephir_is_true(persistent)) { zephir_array_update_long(&options, 12, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE, "phalcon/db/adapter/pdo.zep", 140); } } ZEPHIR_INIT_VAR(_5); object_init_ex(_5, php_pdo_get_dbh_ce()); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_VSV(_3, _6, ":", dsnAttributes); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", NULL, _3, username, password, options); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_pdo"), _5 TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Produce the routing parameters from the rewrite information */ PHP_METHOD(Phalcon_Mvc_Router_Annotations, handle) { zephir_nts_static zephir_fcall_cache_entry *_19 = NULL; zephir_fcall_cache_entry *_6 = NULL, *_10 = NULL, *_18 = NULL; HashTable *_2, *_8, *_12, *_16; HashPosition _1, _7, _11, _15; int ZEPHIR_LAST_CALL_STATUS; zval *uri_param = NULL, *realUri = NULL, *annotationsService = NULL, *handlers, *controllerSuffix, *scope = NULL, *prefix = NULL, *dependencyInjector = NULL, *handler = NULL, *controllerName = NULL, *lowerControllerName = NULL, *namespaceName = NULL, *moduleName = NULL, *sufixed = NULL, *handlerAnnotations = NULL, *classAnnotations = NULL, *annotations = NULL, *annotation = NULL, *methodAnnotations = NULL, *lowercased = NULL, *method = NULL, *collection = NULL, *_0, **_3, *_4, *_5 = NULL, **_9, **_13, *_14 = NULL, **_17; zval *uri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri_param); if (!uri_param) { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } else { if (unlikely(Z_TYPE_P(uri_param) != IS_STRING && Z_TYPE_P(uri_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'uri' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(uri_param) == IS_STRING)) { zephir_get_strval(uri, uri_param); } else { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } } if (!(uri && Z_STRLEN_P(uri))) { ZEPHIR_CALL_METHOD(&realUri, this_ptr, "getrewriteuri", NULL); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_processed"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_INIT_VAR(annotationsService); ZVAL_NULL(annotationsService); ZEPHIR_OBS_VAR(handlers); zephir_read_property_this(&handlers, this_ptr, SL("_handlers"), PH_NOISY_CC); if (Z_TYPE_P(handlers) == IS_ARRAY) { ZEPHIR_OBS_VAR(controllerSuffix); zephir_read_property_this(&controllerSuffix, this_ptr, SL("_controllerSuffix"), PH_NOISY_CC); zephir_is_iterable(handlers, &_2, &_1, 0, 0, "phalcon/mvc/router/annotations.zep", 208); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(scope, _3); if (Z_TYPE_P(scope) == IS_ARRAY) { ZEPHIR_OBS_NVAR(prefix); zephir_array_fetch_long(&prefix, scope, 0, PH_NOISY, "phalcon/mvc/router/annotations.zep", 117 TSRMLS_CC); if (!(ZEPHIR_IS_EMPTY(prefix))) { if (!(zephir_start_with(realUri, prefix, NULL))) { continue; } } if (Z_TYPE_P(annotationsService) != IS_OBJECT) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _4); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'annotations' service", "phalcon/mvc/router/annotations.zep", 129); return; } ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&annotationsService, dependencyInjector, "getshared", &_6, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); } ZEPHIR_OBS_NVAR(handler); zephir_array_fetch_long(&handler, scope, 1, PH_NOISY, "phalcon/mvc/router/annotations.zep", 138 TSRMLS_CC); if (zephir_memnstr_str(handler, SL("\\"), "phalcon/mvc/router/annotations.zep", 140)) { ZEPHIR_INIT_NVAR(controllerName); zephir_get_class_ns(controllerName, handler, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(lowerControllerName); zephir_uncamelize(lowerControllerName, controllerName); ZEPHIR_INIT_NVAR(namespaceName); zephir_get_ns_class(namespaceName, handler, 0 TSRMLS_CC); } else { ZEPHIR_CPY_WRT(controllerName, handler); ZEPHIR_INIT_NVAR(lowerControllerName); zephir_uncamelize(lowerControllerName, controllerName); ZEPHIR_INIT_NVAR(namespaceName); ZVAL_NULL(namespaceName); } zephir_update_property_this(this_ptr, SL("_routePrefix"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_OBS_NVAR(moduleName); zephir_array_isset_long_fetch(&moduleName, scope, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(sufixed); ZEPHIR_CONCAT_VV(sufixed, handler, controllerSuffix); ZEPHIR_CALL_METHOD(&handlerAnnotations, annotationsService, "get", NULL, sufixed); zephir_check_call_status(); if (Z_TYPE_P(handlerAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&classAnnotations, handlerAnnotations, "getclassannotations", NULL); zephir_check_call_status(); if (Z_TYPE_P(classAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&annotations, classAnnotations, "getannotations", NULL); zephir_check_call_status(); if (Z_TYPE_P(annotations) == IS_ARRAY) { zephir_is_iterable(annotations, &_8, &_7, 0, 0, "phalcon/mvc/router/annotations.zep", 187); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HVALUE(annotation, _9); ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_10, controllerName, annotation); zephir_check_call_status(); } } } ZEPHIR_CALL_METHOD(&methodAnnotations, handlerAnnotations, "getmethodsannotations", NULL); zephir_check_call_status(); if (Z_TYPE_P(methodAnnotations) == IS_ARRAY) { ZEPHIR_INIT_NVAR(lowercased); zephir_uncamelize(lowercased, handler); zephir_is_iterable(methodAnnotations, &_12, &_11, 0, 0, "phalcon/mvc/router/annotations.zep", 203); for ( ; zephir_hash_get_current_data_ex(_12, (void**) &_13, &_11) == SUCCESS ; zephir_hash_move_forward_ex(_12, &_11) ) { ZEPHIR_GET_HMKEY(method, _12, _11); ZEPHIR_GET_HVALUE(collection, _13); if (Z_TYPE_P(collection) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_14, collection, "getannotations", NULL); zephir_check_call_status(); zephir_is_iterable(_14, &_16, &_15, 0, 0, "phalcon/mvc/router/annotations.zep", 201); for ( ; zephir_hash_get_current_data_ex(_16, (void**) &_17, &_15) == SUCCESS ; zephir_hash_move_forward_ex(_16, &_15) ) { ZEPHIR_GET_HVALUE(annotation, _17); ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_18, moduleName, namespaceName, lowerControllerName, method, annotation); zephir_check_call_status(); } } } } } } } } zephir_update_property_this(this_ptr, SL("_processed"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_router_annotations_ce, this_ptr, "handle", &_19, realUri); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Email, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, _3, *_4 = NULL, *_5 = NULL, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 274); ZEPHIR_CALL_FUNCTION(&_4, "filter_var", NULL, 190, value, &_3); zephir_check_call_status(); if (!(zephir_is_true(_4))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Email", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_5, "strtr", NULL, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "Email", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 432, _5, field, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
PHP_METHOD(Test_FortyTwo, proof) { zend_bool _3$$3; zval _0; int i = 0, j = 0, _4$$3, _5$$3; zval box, side, _1, *_2, _6$$4; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&box); ZVAL_UNDEF(&side); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_6$$4); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&box); zephir_create_array(&box, 15, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(&_1); ZVAL_LONG(&_1, 10); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 24); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 8); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 8); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 15); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 19); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 19); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 17); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 6); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 6); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 16); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 20); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 20); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 13); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 9); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 9); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 11); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 22); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 22); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 2); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 18); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 18); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 4); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 20); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 5); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 21); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 16); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 16); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 3); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 23); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 23); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 7); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 12); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 12); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 25); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 5); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 24); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 7); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 11); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 11); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 27); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 4); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); ZEPHIR_INIT_NVAR(&_0); zephir_create_array(&_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 11); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 27); zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_LONG(&_1, 4); zephir_array_fast_append(&_0, &_1); zephir_array_fast_append(&box, &_0); zephir_is_iterable(&box, 0, "test/fortytwo.zep", 32); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&box), _2) { ZEPHIR_INIT_NVAR(&side); ZVAL_COPY(&side, _2); j = 0; _5$$3 = 2; _4$$3 = 0; _3$$3 = 0; if (_4$$3 <= _5$$3) { while (1) { if (_3$$3) { _4$$3++; if (!(_4$$3 <= _5$$3)) { break; } } else { _3$$3 = 1; } i = _4$$3; zephir_array_fetch_long(&_6$$4, &side, i, PH_NOISY | PH_READONLY, "test/fortytwo.zep", 26 TSRMLS_CC); j += zephir_get_numberval(&_6$$4); } } if (j != 42) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_exception_ce, "not true", "test/fortytwo.zep", 29); return; } } ZEND_HASH_FOREACH_END();
PHP_METHOD(PhalconPlus_Db_Mysql, getConnection) { zval __$true, __$false, tryTimes, e, _0, _1$$4, _2$$4, _4$$3, _5$$5, _6$$5, _7$$5, _9$$5, _12$$6, _14$$6, _15$$6, _16$$6, _17$$6, _18$$7, _19$$7, _20$$7; zephir_fcall_cache_entry *_3 = NULL, *_8 = NULL, *_10 = NULL, *_13 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS, _11$$5; zval *this_ptr = getThis(); ZVAL_BOOL(&__$true, 1); ZVAL_BOOL(&__$false, 0); ZVAL_UNDEF(&tryTimes); ZVAL_UNDEF(&e); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$4); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_5$$5); ZVAL_UNDEF(&_6$$5); ZVAL_UNDEF(&_7$$5); ZVAL_UNDEF(&_9$$5); ZVAL_UNDEF(&_12$$6); ZVAL_UNDEF(&_14$$6); ZVAL_UNDEF(&_15$$6); ZVAL_UNDEF(&_16$$6); ZVAL_UNDEF(&_17$$6); ZVAL_UNDEF(&_18$$7); ZVAL_UNDEF(&_19$$7); ZVAL_UNDEF(&_20$$7); ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(&tryTimes); zephir_read_property(&tryTimes, this_ptr, SL("retryTimes"), PH_NOISY_CC); while (1) { zephir_read_property(&_0, this_ptr, SL("connected"), PH_NOISY_CC | PH_READONLY); if (!(!(zephir_is_true(&_0)))) { break; } /* try_start_1: */ ZEPHIR_INIT_NVAR(&_1$$4); object_init_ex(&_1$$4, zephir_get_internal_ce(SL("phalcon\\db\\adapter\\pdo\\mysql"))); zephir_read_property(&_2$$4, this_ptr, SL("descriptor"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", &_3, 0, &_2$$4); zephir_check_call_status_or_jump(try_end_1); zephir_update_property_zval(this_ptr, SL("connection"), &_1$$4); if (1) { zephir_update_property_zval(this_ptr, SL("connected"), &__$true); } else { zephir_update_property_zval(this_ptr, SL("connected"), &__$false); } try_end_1: if (EG(exception)) { ZEPHIR_INIT_NVAR(&_4$$3); ZVAL_OBJ(&_4$$3, EG(exception)); Z_ADDREF_P(&_4$$3); if (zephir_instance_of_ev(&_4$$3, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_CPY_WRT(&e, &_4$$3); ZEPHIR_INIT_NVAR(&_5$$5); zephir_read_property(&_6$$5, this_ptr, SL("descriptor"), PH_NOISY_CC | PH_READONLY); zephir_json_encode(&_5$$5, &_6$$5, 0 ); ZEPHIR_CALL_FUNCTION(&_7$$5, "strval", &_8, 27, &tryTimes); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_9$$5); ZEPHIR_CONCAT_SVSVS(&_9$$5, "PHP Fatal error: PhalconPlus::Db::MySQL::connect() failed to connect to MySQL. Detail: ", &_5$$5, ". We will try ", &_7$$5, " times for you."); ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_10, 50, &_9$$5); zephir_check_call_status(); _11$$5 = (zephir_get_numberval(&tryTimes) - 1); ZEPHIR_INIT_NVAR(&tryTimes); ZVAL_LONG(&tryTimes, _11$$5); if (ZEPHIR_GT_LONG(&tryTimes, 0)) { zephir_read_property(&_12$$6, this_ptr, SL("retryInterval"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_FUNCTION(NULL, "usleep", &_13, 57, &_12$$6); zephir_check_call_status(); zephir_read_property(&_14$$6, this_ptr, SL("retryTimes"), PH_NOISY_CC | PH_READONLY); ZEPHIR_SINIT_NVAR(_15$$6); zephir_sub_function(&_15$$6, &_14$$6, &tryTimes); ZEPHIR_CALL_FUNCTION(&_16$$6, "strval", &_8, 27, &_15$$6); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_17$$6); ZEPHIR_CONCAT_SVS(&_17$$6, "PHP Notice: PhalconPlus::Db::MySQL::connnect() retry to connect to MySQL for the ", &_16$$6, " time ... "); ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_10, 50, &_17$$6); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(&_18$$7); zephir_read_property(&_19$$7, this_ptr, SL("descriptor"), PH_NOISY_CC | PH_READONLY); zephir_json_encode(&_18$$7, &_19$$7, 0 ); ZEPHIR_INIT_LNVAR(_20$$7); ZEPHIR_CONCAT_SV(&_20$$7, "PHP Fatal error: PhalconPlus::Db::MySQL::connect() finally failed to connect to MySQL. Detail: ", &_18$$7); ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_10, 50, &_20$$7); zephir_check_call_status(); zephir_throw_exception_debug(&e, "phalconplus/Db/Mysql.zep", 77 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } } RETURN_MM_MEMBER(getThis(), "connection"); }
/** * Initialize the metadata for certain table */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initialize) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *model, *key, *table, *schema, *strategy = NULL, *className, *metaData, *data = NULL, *modelMetadata = NULL, *modelColumnMap = NULL, *dependencyInjector = NULL, *keyName, *prefixKey = NULL, *_0, *_1, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); ZEPHIR_INIT_VAR(strategy); ZVAL_NULL(strategy); ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 0 TSRMLS_CC); if (Z_TYPE_P(key) != IS_NULL) { ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); if (!(zephir_array_isset(metaData, key))) { ZEPHIR_INIT_VAR(prefixKey); ZEPHIR_CONCAT_SV(prefixKey, "meta-", key); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, prefixKey); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_metaData"), key, data TSRMLS_CC); } else { if ((zephir_method_exists_ex(model, SS("metadata") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(modelMetadata) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "Invalid meta-data for model ", className); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/metadata.zep", 119 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", &_2, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&modelMetadata, strategy, "getmetadata", NULL, 0, model, dependencyInjector); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_metaData"), key, modelMetadata TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, prefixKey, modelMetadata); zephir_check_call_status(); } } } if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(keyName); zephir_fast_strtolower(keyName, className); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC); if (zephir_array_isset(_3, keyName)) { RETURN_MM_NULL(); } ZEPHIR_INIT_NVAR(prefixKey); ZEPHIR_CONCAT_SV(prefixKey, "map-", keyName); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, prefixKey); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_columnMap"), keyName, data TSRMLS_CC); RETURN_MM_NULL(); } if (Z_TYPE_P(strategy) != IS_OBJECT) { ZEPHIR_OBS_NVAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", &_2, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&modelColumnMap, strategy, "getcolumnmaps", NULL, 0, model, dependencyInjector); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_columnMap"), keyName, modelColumnMap TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, prefixKey, modelColumnMap); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * Phalcon\Config\Adapter\Yaml constructor * * @throws \Phalcon\Config\Exception */ PHP_METHOD(Phalcon_Config_Adapter_Yaml, __construct) { zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; int ndocs = 0, ZEPHIR_LAST_CALL_STATUS; zval *callbacks = NULL; zval *filePath_param = NULL, *callbacks_param = NULL, *yamlConfig = NULL, _0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_5; zval *filePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &filePath_param, &callbacks_param); if (unlikely(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(filePath_param) == IS_STRING)) { zephir_get_strval(filePath, filePath_param); } else { ZEPHIR_INIT_VAR(filePath); ZVAL_EMPTY_STRING(filePath); } if (!callbacks_param) { ZEPHIR_INIT_VAR(callbacks); array_init(callbacks); } else { callbacks = callbacks_param; } ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "yaml", 0); ZEPHIR_CALL_FUNCTION(&_1, "extension_loaded", NULL, 63, &_0); zephir_check_call_status(); if (!(zephir_is_true(_1))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_config_exception_ce, "Yaml extension not loaded", "phalcon/config/adapter/yaml.zep", 62); return; } if (!ZEPHIR_IS_STRING_IDENTICAL(callbacks, "")) { ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, ndocs); Z_SET_ISREF_P(_3); ZEPHIR_CALL_FUNCTION(&yamlConfig, "yaml_parse_file", &_4, 64, filePath, _2, _3, callbacks); Z_UNSET_ISREF_P(_3); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&yamlConfig, "yaml_parse_file", &_4, 64, filePath); zephir_check_call_status(); } if (ZEPHIR_IS_FALSE_IDENTICAL(yamlConfig)) { ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_config_exception_ce); ZEPHIR_INIT_NVAR(_3); zephir_basename(_3, filePath TSRMLS_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVS(_5, "Configuration file ", _3, " can't be loaded"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 2, _5); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/config/adapter/yaml.zep", 72 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_PARENT(NULL, phalcon_config_adapter_yaml_ce, this_ptr, "__construct", &_6, 58, yamlConfig); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * Returns current row in the resultset */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, current) { zend_class_entry *_5$$6; zval *row = NULL, *hydrateMode = NULL, *columnMap = NULL, *activeRow = NULL, *modelName = NULL, *_0$$6, *_2$$6, *_3$$6, *_4$$6, *_1$$7, *_7$$9, *_8$$9, *_9$$9; zephir_fcall_cache_entry *_6 = NULL, *_10 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(activeRow); zephir_read_property_this(&activeRow, this_ptr, SL("_activeRow"), PH_NOISY_CC); if (Z_TYPE_P(activeRow) != IS_NULL) { RETURN_CCTOR(activeRow); } ZEPHIR_OBS_VAR(row); zephir_read_property_this(&row, this_ptr, SL("_row"), PH_NOISY_CC); if (Z_TYPE_P(row) != IS_ARRAY) { if (0) { zephir_update_property_this(getThis(), SL("_activeRow"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(getThis(), SL("_activeRow"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(hydrateMode); zephir_read_property_this(&hydrateMode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC); ZEPHIR_OBS_VAR(columnMap); zephir_read_property_this(&columnMap, this_ptr, SL("_columnMap"), PH_NOISY_CC); do { if (ZEPHIR_IS_LONG(hydrateMode, 0)) { if (ZEPHIR_GLOBAL(orm).late_state_binding) { ZEPHIR_OBS_VAR(_0$$6); zephir_read_property_this(&_0$$6, this_ptr, SL("_model"), PH_NOISY_CC); if (zephir_instance_of_ev(_0$$6, phalcon_mvc_model_ce TSRMLS_CC)) { _1$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); ZEPHIR_INIT_VAR(modelName); zephir_get_class(modelName, _1$$7, 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(modelName); ZVAL_STRING(modelName, "Phalcon\\Mvc\\Model", 1); } _2$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); _3$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_4$$6); ZVAL_LONG(_4$$6, 0); _5$$6 = zephir_fetch_class(modelName TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&activeRow, _5$$6, "cloneresultmap", NULL, 0, _2$$6, row, columnMap, _4$$6, _3$$6); zephir_check_call_status(); } else { _7$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); _8$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_9$$9); ZVAL_LONG(_9$$9, 0); ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmap", &_6, 388, _7$$9, row, columnMap, _9$$9, _8$$9); zephir_check_call_status(); } break; } ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_10, 389, row, columnMap, hydrateMode); zephir_check_call_status(); break; } while(0); zephir_update_property_this(getThis(), SL("_activeRow"), activeRow TSRMLS_CC); RETURN_CCTOR(activeRow); }
/** * Returns a complete resultset as an array, if the resultset has a big number of rows * it could consume more memory than currently it does. Export the resultset to an array * couldn't be faster with a large number of records */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray) { HashTable *_2$$7, *_5$$8; HashPosition _1$$7, _4$$8; zephir_fcall_cache_entry *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *renameColumns_param = NULL, *result = NULL, *records = NULL, *record = NULL, *renamed = NULL, *renamedKey = NULL, *key = NULL, *value = NULL, *renamedRecords = NULL, *columnMap = NULL, *_0$$3, **_3$$7, **_6$$8, *_7$$10 = NULL, *_8$$10 = NULL, *_10$$12 = NULL, *_11$$12 = NULL; zend_bool renameColumns; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &renameColumns_param); if (!renameColumns_param) { renameColumns = 1; } else { renameColumns = zephir_get_boolval(renameColumns_param); } ZEPHIR_OBS_VAR(records); zephir_read_property_this(&records, this_ptr, SL("_rows"), PH_NOISY_CC); if (Z_TYPE_P(records) != IS_ARRAY) { ZEPHIR_OBS_VAR(result); zephir_read_property_this(&result, this_ptr, SL("_result"), PH_NOISY_CC); _0$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_row"), PH_NOISY_CC); if (Z_TYPE_P(_0$$3) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, result, "execute", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&records, result, "fetchall", NULL, 0); zephir_check_call_status(); zephir_update_property_this(getThis(), SL("_row"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); zephir_update_property_this(getThis(), SL("_rows"), records TSRMLS_CC); } if (renameColumns) { ZEPHIR_OBS_VAR(columnMap); zephir_read_property_this(&columnMap, this_ptr, SL("_columnMap"), PH_NOISY_CC); if (Z_TYPE_P(columnMap) != IS_ARRAY) { RETURN_CCTOR(records); } ZEPHIR_INIT_VAR(renamedRecords); array_init(renamedRecords); if (Z_TYPE_P(records) == IS_ARRAY) { zephir_is_iterable(records, &_2$$7, &_1$$7, 0, 0, "phalcon/mvc/model/resultset/simple.zep", 217); for ( ; zend_hash_get_current_data_ex(_2$$7, (void**) &_3$$7, &_1$$7) == SUCCESS ; zend_hash_move_forward_ex(_2$$7, &_1$$7) ) { ZEPHIR_GET_HVALUE(record, _3$$7); ZEPHIR_INIT_NVAR(renamed); array_init(renamed); zephir_is_iterable(record, &_5$$8, &_4$$8, 0, 0, "phalcon/mvc/model/resultset/simple.zep", 215); for ( ; zend_hash_get_current_data_ex(_5$$8, (void**) &_6$$8, &_4$$8) == SUCCESS ; zend_hash_move_forward_ex(_5$$8, &_4$$8) ) { ZEPHIR_GET_HMKEY(key, _5$$8, _4$$8); ZEPHIR_GET_HVALUE(value, _6$$8); ZEPHIR_OBS_NVAR(renamedKey); if (!(zephir_array_isset_fetch(&renamedKey, columnMap, key, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_7$$10); object_init_ex(_7$$10, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_8$$10); ZEPHIR_CONCAT_SVS(_8$$10, "Column '", key, "' is not part of the column map"); ZEPHIR_CALL_METHOD(NULL, _7$$10, "__construct", &_9, 9, _8$$10); zephir_check_call_status(); zephir_throw_exception_debug(_7$$10, "phalcon/mvc/model/resultset/simple.zep", 199 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(renamedKey) == IS_ARRAY) { ZEPHIR_OBS_NVAR(renamedKey); if (!(zephir_array_isset_long_fetch(&renamedKey, renamedKey, 0, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_10$$12); object_init_ex(_10$$12, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_11$$12); ZEPHIR_CONCAT_SVS(_11$$12, "Column '", key, "' is not part of the column map"); ZEPHIR_CALL_METHOD(NULL, _10$$12, "__construct", &_9, 9, _11$$12); zephir_check_call_status(); zephir_throw_exception_debug(_10$$12, "phalcon/mvc/model/resultset/simple.zep", 205 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } zephir_array_update_zval(&renamed, renamedKey, &value, PH_COPY | PH_SEPARATE); } zephir_array_append(&renamedRecords, renamed, PH_SEPARATE, "phalcon/mvc/model/resultset/simple.zep", 215); } } RETURN_CCTOR(renamedRecords); } RETURN_CCTOR(records); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Confirmation, validate) { int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *fieldWith = NULL, *value = NULL, *valueWith = NULL, *message = NULL, *label = NULL, *labelWith = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "with", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&fieldWith, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&valueWith, validation, "getvalue", NULL, 0, fieldWith); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, this_ptr, "compare", NULL, 439, value, valueWith); zephir_check_call_status(); if (!(zephir_is_true(_1))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "labelWith", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&labelWith, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(labelWith)) { ZEPHIR_CALL_METHOD(&labelWith, validation, "getlabel", NULL, 0, fieldWith); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":with"), &labelWith, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Confirmation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_2, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "Confirmation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 436, _2, field, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Numericality, validate) { int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *code = NULL, *_0, *_1, _2, *_3$$3 = NULL, *_8$$3 = NULL, *_9$$3, *_4$$4, *_5$$6, *_6$$7, *_7$$8; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "/^-?\\d+\\.?\\d*$/", 0); zephir_preg_match(_1, &_2, value, _0, 0, 0 , 0 TSRMLS_CC); if (!(zephir_is_true(_1))) { ZEPHIR_INIT_VAR(_3$$3); ZVAL_STRING(_3$$3, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _3$$3); zephir_check_temp_parameter(_3$$3); zephir_check_call_status(); if (Z_TYPE_P(label) == IS_ARRAY) { zephir_array_fetch(&_4$$4, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/numericality.zep", 75 TSRMLS_CC); ZEPHIR_CPY_WRT(label, _4$$4); } if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_3$$3); ZVAL_STRING(_3$$3, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _3$$3); zephir_check_temp_parameter(_3$$3); zephir_check_call_status(); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_5$$6, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/numericality.zep", 83 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _5$$6); } ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_6$$7); ZVAL_STRING(_6$$7, "Numericality", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _6$$7); zephir_check_temp_parameter(_6$$7); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_3$$3); ZVAL_STRING(_3$$3, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, _3$$3); zephir_check_temp_parameter(_3$$3); zephir_check_call_status(); if (Z_TYPE_P(code) == IS_ARRAY) { zephir_array_fetch(&_7$$8, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/numericality.zep", 92 TSRMLS_CC); ZEPHIR_CPY_WRT(code, _7$$8); } ZEPHIR_INIT_NVAR(_3$$3); object_init_ex(_3$$3, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_8$$3, "strtr", NULL, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_9$$3); ZVAL_STRING(_9$$3, "Numericality", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _3$$3, "__construct", NULL, 464, _8$$3, field, _9$$3, code); zephir_check_temp_parameter(_9$$3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _3$$3); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Throws an internal exception */ PHP_METHOD(Phalcon_Mvc_Dispatcher, _throwDispatchException) { zend_long exceptionCode, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *exceptionCode_param = NULL, *dependencyInjector = NULL, *response = NULL, *exception = NULL, *_3 = NULL, *_4 = NULL, *_5, *_0$$3, *_1$$3, *_2$$3; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &exceptionCode_param); if (UNEXPECTED(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!exceptionCode_param) { exceptionCode = 0; } else { exceptionCode = zephir_get_intval(exceptionCode_param); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_VAR(_0$$3); object_init_ex(_0$$3, phalcon_mvc_dispatcher_exception_ce); ZEPHIR_INIT_VAR(_1$$3); ZVAL_STRING(_1$$3, "A dependency injection container is required to access the 'response' service", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2$$3); ZVAL_LONG(_2$$3, 0); ZEPHIR_CALL_METHOD(NULL, _0$$3, "__construct", NULL, 9, _1$$3, _2$$3); zephir_check_temp_parameter(_1$$3); zephir_check_call_status(); zephir_throw_exception_debug(_0$$3, "phalcon/mvc/dispatcher.zep", 127 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, dependencyInjector, "getshared", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CPY_WRT(response, _3); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, 404); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "Not Found", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "setstatuscode", NULL, 0, _4, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_INIT_VAR(exception); object_init_ex(exception, phalcon_mvc_dispatcher_exception_ce); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, exceptionCode); ZEPHIR_CALL_METHOD(NULL, exception, "__construct", NULL, 9, message, _4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_handleexception", NULL, 0, exception); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } zephir_throw_exception_debug(exception, "phalcon/mvc/dispatcher.zep", 149 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; }
/** * Initialize the metadata for certain table */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initialize) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *model, model_sub, *key, key_sub, *table, table_sub, *schema, schema_sub, strategy, className, metaData, data, modelMetadata, modelColumnMap, dependencyInjector, keyName, prefixKey, _2, _0$$8, _1$$8; zval *this_ptr = getThis(); ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&key_sub); ZVAL_UNDEF(&table_sub); ZVAL_UNDEF(&schema_sub); ZVAL_UNDEF(&strategy); ZVAL_UNDEF(&className); ZVAL_UNDEF(&metaData); ZVAL_UNDEF(&data); ZVAL_UNDEF(&modelMetadata); ZVAL_UNDEF(&modelColumnMap); ZVAL_UNDEF(&dependencyInjector); ZVAL_UNDEF(&keyName); ZVAL_UNDEF(&prefixKey); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_0$$8); ZVAL_UNDEF(&_1$$8); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); ZEPHIR_INIT_VAR(&strategy); ZVAL_NULL(&strategy); ZEPHIR_INIT_VAR(&className); zephir_get_class(&className, model, 0 TSRMLS_CC); if (Z_TYPE_P(key) != IS_NULL) { ZEPHIR_OBS_VAR(&metaData); zephir_read_property(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); if (!(zephir_array_isset(&metaData, key))) { ZEPHIR_INIT_VAR(&prefixKey); ZEPHIR_CONCAT_SV(&prefixKey, "meta-", key); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); zephir_check_call_status(); if (Z_TYPE_P(&data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_metaData"), key, &data TSRMLS_CC); } else { if ((zephir_method_exists_ex(model, SL("metadata") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(&modelMetadata) != IS_ARRAY) { ZEPHIR_INIT_VAR(&_0$$8); object_init_ex(&_0$$8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(&_1$$8); ZEPHIR_CONCAT_SV(&_1$$8, "Invalid meta-data for model ", &className); ZEPHIR_CALL_METHOD(NULL, &_0$$8, "__construct", NULL, 4, &_1$$8); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$8, "phalcon/mvc/model/metadata.zep", 113 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_OBS_VAR(&dependencyInjector); zephir_read_property(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&modelMetadata, &strategy, "getmetadata", NULL, 0, model, &dependencyInjector); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_metaData"), key, &modelMetadata TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelMetadata); zephir_check_call_status(); } } } if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(&keyName); zephir_fast_strtolower(&keyName, &className); zephir_read_property(&_2, this_ptr, SL("_columnMap"), PH_NOISY_CC | PH_READONLY); if (zephir_array_isset(&_2, &keyName)) { RETURN_MM_NULL(); } ZEPHIR_INIT_NVAR(&prefixKey); ZEPHIR_CONCAT_SV(&prefixKey, "map-", &keyName); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); zephir_check_call_status(); if (Z_TYPE_P(&data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_columnMap"), &keyName, &data TSRMLS_CC); RETURN_MM_NULL(); } if (Z_TYPE_P(&strategy) != IS_OBJECT) { ZEPHIR_OBS_NVAR(&dependencyInjector); zephir_read_property(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&modelColumnMap, &strategy, "getcolumnmaps", NULL, 0, model, &dependencyInjector); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_columnMap"), &keyName, &modelColumnMap TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelColumnMap); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * Resize the image to the given size */ PHP_METHOD(Phalcon_Image_Adapter, resize) { zephir_fcall_cache_entry *_12 = NULL; zend_bool _0, _4; double ratio; zval *width_param = NULL, *height_param = NULL, *master_param = NULL, *_1 = NULL, *_2, *_3, *_5, *_6, *_7 = NULL, *_8, _9, *_10 = NULL, *_11 = NULL, _13, *_14 = NULL, *_15 = NULL, *_16; int width, height, master, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &width_param, &height_param, &master_param); if (!width_param) { width = 0; } else { width = zephir_get_intval(width_param); } if (!height_param) { height = 0; } else { height = zephir_get_intval(height_param); } if (!master_param) { master = 4; } else { master = zephir_get_intval(master_param); } if (master == 7) { _0 = !width; if (!(_0)) { _0 = !height; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 80); return; } } else { if (master == 4) { _0 = !width; if (!(_0)) { _0 = !height; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 88); return; } ZEPHIR_INIT_VAR(_1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if ((zephir_safe_div_zval_long(_2, width TSRMLS_CC)) > (int) (zephir_safe_div_zval_long(_3, height TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 2); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 3); } master = zephir_get_numberval(_1); } if (master == 5) { _4 = !width; if (!(_4)) { _4 = !height; } if (_4) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 97); return; } ZEPHIR_INIT_LNVAR(_1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if ((zephir_safe_div_zval_long(_2, width TSRMLS_CC)) > (int) (zephir_safe_div_zval_long(_3, height TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 3); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 2); } master = zephir_get_numberval(_1); } do { if (master == 2) { if (!(width)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width must be specified", "phalcon/image/adapter.zep", 107); return; } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * width), _3 TSRMLS_CC)); break; } if (master == 3) { if (!(height)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "height must be specified", "phalcon/image/adapter.zep", 114); return; } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * height), _3 TSRMLS_CC)); break; } if (master == 6) { _4 = !width; if (!(_4)) { _4 = !height; } if (_4) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 121); return; } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_1); div_function(_1, _2, _3 TSRMLS_CC); ratio = zephir_get_numberval(_1); if ((zephir_safe_div_long_long(width, height TSRMLS_CC)) > ratio) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * width), _3 TSRMLS_CC)); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_5) * height), _6 TSRMLS_CC)); } break; } if (master == 1) { if (!(width)) { ZEPHIR_OBS_VAR(_7); zephir_read_property_this(&_7, this_ptr, SL("_width"), PH_NOISY_CC); width = zephir_get_intval(_7); } if (!(height)) { ZEPHIR_OBS_NVAR(_7); zephir_read_property_this(&_7, this_ptr, SL("_height"), PH_NOISY_CC); width = zephir_get_intval(_7); } break; } } while(0); } ZEPHIR_INIT_VAR(_8); ZEPHIR_SINIT_VAR(_9); ZVAL_LONG(&_9, width); zephir_round(_8, &_9, NULL, NULL TSRMLS_CC); ZEPHIR_INIT_VAR(_10); ZVAL_LONG(_10, 1); ZEPHIR_CALL_FUNCTION(&_11, "max", &_12, 68, _8, _10); zephir_check_call_status(); width = zephir_get_intval(_11); ZEPHIR_INIT_NVAR(_10); ZEPHIR_SINIT_VAR(_13); ZVAL_LONG(&_13, height); zephir_round(_10, &_13, NULL, NULL TSRMLS_CC); ZEPHIR_INIT_VAR(_14); ZVAL_LONG(_14, 1); ZEPHIR_CALL_FUNCTION(&_15, "max", &_12, 68, _10, _14); zephir_check_call_status(); height = zephir_get_intval(_15); ZEPHIR_INIT_NVAR(_14); ZVAL_LONG(_14, width); ZEPHIR_INIT_VAR(_16); ZVAL_LONG(_16, height); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resize", NULL, 0, _14, _16); zephir_check_call_status(); RETURN_THIS(); }
/** * Checks for annotations in the public methods of the controller * * @param string module * @param string namespaceName * @param string controller * @param string action * @param Phalcon\Annotations\Annotation annotation */ PHP_METHOD(Phalcon_Mvc_Router_Annotations, processActionAnnotation) { zephir_fcall_cache_entry *_7 = NULL, *_11 = NULL; HashTable *_5, *_9; HashPosition _4, _8; int ZEPHIR_LAST_CALL_STATUS; zend_bool isRoute; zval *module_param = NULL, *namespaceName_param = NULL, *controller_param = NULL, *action_param = NULL, *annotation, *name = NULL, *actionName, *routePrefix, *paths = NULL, *value = NULL, *uri = NULL, *route = NULL, *methods = NULL, *converts = NULL, *param = NULL, *convert = NULL, *conversorParam = NULL, *routeName = NULL, *_0, *_1, _2, *_3 = NULL, **_6, **_10; zval *module = NULL, *namespaceName = NULL, *controller = NULL, *action = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 5, 0, &module_param, &namespaceName_param, &controller_param, &action_param, &annotation); if (unlikely(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(module_param) == IS_STRING)) { zephir_get_strval(module, module_param); } else { ZEPHIR_INIT_VAR(module); ZVAL_EMPTY_STRING(module); } if (unlikely(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(namespaceName_param) == IS_STRING)) { zephir_get_strval(namespaceName, namespaceName_param); } else { ZEPHIR_INIT_VAR(namespaceName); ZVAL_EMPTY_STRING(namespaceName); } if (unlikely(Z_TYPE_P(controller_param) != IS_STRING && Z_TYPE_P(controller_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controller' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controller_param) == IS_STRING)) { zephir_get_strval(controller, controller_param); } else { ZEPHIR_INIT_VAR(controller); ZVAL_EMPTY_STRING(controller); } if (unlikely(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(action_param) == IS_STRING)) { zephir_get_strval(action, action_param); } else { ZEPHIR_INIT_VAR(action); ZVAL_EMPTY_STRING(action); } isRoute = 0; ZEPHIR_INIT_VAR(methods); ZVAL_NULL(methods); ZEPHIR_CALL_METHOD(&name, annotation, "getname", NULL); zephir_check_call_status(); if (ZEPHIR_IS_STRING(name, "Route")) { isRoute = 1; } else { if (ZEPHIR_IS_STRING(name, "Get")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "GET", 1); } else { if (ZEPHIR_IS_STRING(name, "Post")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "POST", 1); } else { if (ZEPHIR_IS_STRING(name, "Put")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "PUT", 1); } else { if (ZEPHIR_IS_STRING(name, "Options")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "OPTIONS", 1); } } } } } if (isRoute == 1) { ZEPHIR_INIT_VAR(actionName); ZEPHIR_INIT_VAR(_0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_actionSuffix"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "", 0); zephir_fast_str_replace(&_0, _1, &_2, action TSRMLS_CC); zephir_fast_strtolower(actionName, _0); ZEPHIR_OBS_VAR(routePrefix); zephir_read_property_this(&routePrefix, this_ptr, SL("_routePrefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "paths", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&paths, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(paths) != IS_ARRAY) { ZEPHIR_INIT_NVAR(paths); array_init(paths); } if (!(ZEPHIR_IS_EMPTY(module))) { zephir_array_update_string(&paths, SL("module"), &module, PH_COPY | PH_SEPARATE); } if (!(ZEPHIR_IS_EMPTY(namespaceName))) { zephir_array_update_string(&paths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } zephir_array_update_string(&paths, SL("controller"), &controller, PH_COPY | PH_SEPARATE); zephir_array_update_string(&paths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(&value, annotation, "getargument", NULL, _3); zephir_check_call_status(); if (Z_TYPE_P(value) != IS_NULL) { if (!ZEPHIR_IS_STRING(value, "/")) { ZEPHIR_INIT_VAR(uri); ZEPHIR_CONCAT_VV(uri, routePrefix, value); } else { ZEPHIR_CPY_WRT(uri, routePrefix); } } else { ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, routePrefix, actionName); } ZEPHIR_CALL_METHOD(&route, this_ptr, "add", NULL, uri, paths); zephir_check_call_status(); if (Z_TYPE_P(methods) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, methods); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "methods", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&methods, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(methods) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, methods); zephir_check_call_status(); } else { if (Z_TYPE_P(methods) == IS_STRING) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, methods); zephir_check_call_status(); } } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "converts", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(converts) == IS_ARRAY) { zephir_is_iterable(converts, &_5, &_4, 0, 0, "phalcon/mvc/router/annotations.zep", 348); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HMKEY(param, _5, _4); ZEPHIR_GET_HVALUE(convert, _6); ZEPHIR_CALL_METHOD(NULL, route, "convert", &_7, param, convert); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "conversors", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(converts) == IS_ARRAY) { zephir_is_iterable(converts, &_9, &_8, 0, 0, "phalcon/mvc/router/annotations.zep", 358); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(conversorParam, _9, _8); ZEPHIR_GET_HVALUE(convert, _10); ZEPHIR_CALL_METHOD(NULL, route, "convert", &_11, conversorParam, convert); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "name", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&routeName, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(routeName) == IS_STRING) { ZEPHIR_CALL_METHOD(NULL, route, "setname", NULL, routeName); zephir_check_call_status(); } RETURN_MM_BOOL(1); } ZEPHIR_MM_RESTORE(); }
/** * Add a text to an image with a specified opacity */ PHP_METHOD(Phalcon_Image_Adapter, text) { zend_bool _0; int opacity, size, ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *offsetX = NULL, *offsetY = NULL, *opacity_param = NULL, *color_param = NULL, *size_param = NULL, *fontfile_param = NULL, *colors = NULL, _1, _2, *_3, _4 = zval_used_for_init, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8, *_9, *_10; zval *text = NULL, *color = NULL, *fontfile = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 6, &text_param, &offsetX, &offsetY, &opacity_param, &color_param, &size_param, &fontfile_param); zephir_get_strval(text, text_param); if (!offsetX) { offsetX = ZEPHIR_GLOBAL(global_false); } if (!offsetY) { offsetY = ZEPHIR_GLOBAL(global_false); } if (!opacity_param) { opacity = 100; } else { opacity = zephir_get_intval(opacity_param); } if (!color_param) { ZEPHIR_INIT_VAR(color); ZVAL_STRING(color, "000000", 1); } else { zephir_get_strval(color, color_param); } if (!size_param) { size = 12; } else { size = zephir_get_intval(size_param); } if (!fontfile_param) { ZEPHIR_INIT_VAR(fontfile); ZVAL_EMPTY_STRING(fontfile); } else { zephir_get_strval(fontfile, fontfile_param); } if (opacity < 0) { opacity = 0; } else { if (opacity > 100) { opacity = 100; } } _0 = zephir_fast_strlen_ev(color) > 1; if (_0) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, 1); ZEPHIR_INIT_VAR(_3); zephir_substr(_3, color, 0 , 1 , 0); _0 = ZEPHIR_IS_STRING_IDENTICAL(_3, "#"); } if (_0) { ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_VAR(_5); zephir_substr(_5, color, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(color, _5); } if (zephir_fast_strlen_ev(color) == 3) { ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "/./", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "$0$0", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_7, "preg_replace", NULL, 29, _5, _6, color); zephir_check_temp_parameter(_5); zephir_check_temp_parameter(_6); zephir_check_call_status(); zephir_get_strval(color, _7); } ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 2); ZEPHIR_CALL_FUNCTION(&_7, "str_split", NULL, 69, color, &_4); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_4); ZVAL_STRING(&_4, "hexdec", 0); ZEPHIR_CALL_FUNCTION(&colors, "array_map", NULL, 70, &_4, _7); zephir_check_call_status(); zephir_array_fetch_long(&_8, colors, 0, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 335 TSRMLS_CC); zephir_array_fetch_long(&_9, colors, 1, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 335 TSRMLS_CC); zephir_array_fetch_long(&_10, colors, 2, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 335 TSRMLS_CC); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, opacity); ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, size); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_text", NULL, 0, text, offsetX, offsetY, _5, _8, _9, _10, _6, fontfile); zephir_check_call_status(); RETURN_THIS(); }
/** * Returns current row in the resultset */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, current) { zephir_nts_static zephir_fcall_cache_entry *_6 = NULL, *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *result, *row = NULL, *hydrateMode, *columnMap, *activeRow = NULL, *_0, *_1, *_2 = NULL, *_3, *_4, *_5, *_7; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(activeRow); zephir_read_property_this(&activeRow, this_ptr, SL("_activeRow"), PH_NOISY_CC); if (Z_TYPE_P(activeRow) != IS_NULL) { RETURN_CCTOR(activeRow); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_OBS_VAR(row); zephir_read_property_this(&row, this_ptr, SL("_row"), PH_NOISY_CC); } else { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_rows"), PH_NOISY_CC); if (Z_TYPE_P(_1) == IS_NULL) { ZEPHIR_OBS_VAR(result); zephir_read_property_this(&result, this_ptr, SL("_result"), PH_NOISY_CC); if (Z_TYPE_P(result) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_2, result, "fetchall", NULL); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_rows"), _2 TSRMLS_CC); } } ZEPHIR_OBS_VAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_rows"), PH_NOISY_CC); if (Z_TYPE_P(_3) == IS_ARRAY) { ZEPHIR_OBS_NVAR(row); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_rows"), PH_NOISY_CC); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_pointer"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&row, _4, _5, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(row); ZVAL_BOOL(row, 0); } } else { ZEPHIR_INIT_NVAR(row); ZVAL_BOOL(row, 0); } } if (Z_TYPE_P(row) != IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_activeRow"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(hydrateMode); zephir_read_property_this(&hydrateMode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC); ZEPHIR_OBS_VAR(columnMap); zephir_read_property_this(&columnMap, this_ptr, SL("_columnMap"), PH_NOISY_CC); do { if (ZEPHIR_IS_LONG(hydrateMode, 0)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_7); ZVAL_LONG(_7, 0); ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmap", &_6, _1, row, columnMap, _7, _4); zephir_check_call_status(); break; } ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_8, row, columnMap, hydrateMode); zephir_check_call_status(); break; } while(0); zephir_update_property_this(this_ptr, SL("_activeRow"), activeRow TSRMLS_CC); RETURN_CCTOR(activeRow); }
/** * Set the background color of an image */ PHP_METHOD(Phalcon_Image_Adapter, background) { zend_bool _0; int opacity, ZEPHIR_LAST_CALL_STATUS; zval *color_param = NULL, *opacity_param = NULL, *colors = NULL, _1, _2, *_3, _4 = zval_used_for_init, *_5 = NULL, *_6, *_7 = NULL, *_8, *_9, *_10; zval *color = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &color_param, &opacity_param); zephir_get_strval(color, color_param); if (!opacity_param) { opacity = 100; } else { opacity = zephir_get_intval(opacity_param); } _0 = zephir_fast_strlen_ev(color) > 1; if (_0) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, 1); ZEPHIR_INIT_VAR(_3); zephir_substr(_3, color, 0 , 1 , 0); _0 = ZEPHIR_IS_STRING_IDENTICAL(_3, "#"); } if (_0) { ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_VAR(_5); zephir_substr(_5, color, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(color, _5); } if (zephir_fast_strlen_ev(color) == 3) { ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "/./", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "$0$0", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_7, "preg_replace", NULL, 29, _5, _6, color); zephir_check_temp_parameter(_5); zephir_check_temp_parameter(_6); zephir_check_call_status(); zephir_get_strval(color, _7); } ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 2); ZEPHIR_CALL_FUNCTION(&_7, "str_split", NULL, 69, color, &_4); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_4); ZVAL_STRING(&_4, "hexdec", 0); ZEPHIR_CALL_FUNCTION(&colors, "array_map", NULL, 70, &_4, _7); zephir_check_call_status(); zephir_array_fetch_long(&_8, colors, 0, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 366 TSRMLS_CC); zephir_array_fetch_long(&_9, colors, 1, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 366 TSRMLS_CC); zephir_array_fetch_long(&_10, colors, 2, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 366 TSRMLS_CC); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, opacity); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_background", NULL, 0, _8, _9, _10, _5); zephir_check_call_status(); RETURN_THIS(); }
/** * Stores cached content into the file backend and stops the frontend * * @param int|string keyName * @param string content * @param long lifetime * @param boolean stopBuffer */ PHP_METHOD(Phalcon_Cache_Backend_Xcache, save) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastKey = NULL, *frontend, *cachedContent = NULL, *preparedContent = NULL, *tmp, *tt1 = NULL, *success = NULL, *isBuffering = NULL, *options, *keys = NULL, *specialKey, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCX", _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/xcache.zep", 119); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); if (!(zephir_is_true(content))) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } if (!(zephir_is_numeric(cachedContent))) { ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); } if (!(zephir_is_true(lifetime))) { ZEPHIR_OBS_VAR(tmp); zephir_read_property_this(&tmp, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(tmp))) { ZEPHIR_CALL_METHOD(&tt1, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(tt1, tmp); } } else { ZEPHIR_CPY_WRT(tt1, lifetime); } if (zephir_is_numeric(cachedContent)) { ZEPHIR_CALL_FUNCTION(&success, "xcache_set", &_1, 82, lastKey, cachedContent, tt1); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&success, "xcache_set", &_1, 82, lastKey, preparedContent, tt1); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } zephir_update_property_this(this_ptr, SL("_started"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); if (zephir_is_true(success)) { ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&specialKey, _0, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/xcache.zep", 169); return; } ZEPHIR_CALL_FUNCTION(&keys, "xcache_get", NULL, 81, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) != IS_ARRAY) { ZEPHIR_INIT_NVAR(keys); array_init(keys); } zephir_array_update_zval(&keys, lastKey, &tt1, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(NULL, "xcache_set", &_1, 82, specialKey, keys); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
PHP_METHOD(Test_Quantum, Harmos) { zend_bool _14, _17, _33, _36; zval *_11 = NULL, *_12 = NULL, *_13 = NULL; zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_37 = NULL; int i, j, n, ZEPHIR_LAST_CALL_STATUS, _15, _16, _18, _19, _34, _35; zval *x_param = NULL, *psr, *psi, *p2, *v, *paramater, *fp = NULL, *_0 = NULL, _1 = zval_used_for_init, _2 = zval_used_for_init, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_10 = NULL, *tmp, *_20, *_21, *_22, *_23, *_24, *_25, *_26, *_27, _28 = zval_used_for_init, *_29, *_30, *_31, *_32; double x, dt, dx, k0, item_psr, item_psi; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &x_param); x = zephir_get_doubleval(x_param); dx = 0.02; k0 = (3.0 * 3.14159265358979323846); dt = ((dx * dx) / 4.0); ZEPHIR_INIT_VAR(paramater); array_init_size(paramater, 7); ZEPHIR_INIT_VAR(_0); ZVAL_DOUBLE(_0, dx); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_DOUBLE(_0, k0); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_DOUBLE(_0, dt); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_DOUBLE(_0, x); zephir_array_fast_append(paramater, _0); i = 0; ZEPHIR_INIT_VAR(psr); array_init(psr); ZEPHIR_INIT_VAR(psi); array_init(psi); ZEPHIR_INIT_VAR(p2); array_init(p2); ZEPHIR_INIT_VAR(v); array_init(v); ZEPHIR_INIT_VAR(fp); array_init(fp); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "harmos.txt", 0); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "w", 0); ZEPHIR_CALL_FUNCTION(&fp, "fopen", &_3, &_1, &_2); zephir_check_call_status(); if (!zephir_is_true(fp)) { RETURN_MM_LONG(1); } while (1) { if (!(i <= 751)) { break; } ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, (k0 * x)); ZEPHIR_CALL_FUNCTION(&_4, "sin", &_5, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, ((x * x) * 2.0)); ZEPHIR_CALL_FUNCTION(&_6, "exp", &_7, &_1); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_8); div_function(_8, _4, _6 TSRMLS_CC); item_psi = zephir_get_numberval(_8); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, (k0 * x)); ZEPHIR_CALL_FUNCTION(&_4, "cos", &_9, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, ((x * x) * 2.0)); ZEPHIR_CALL_FUNCTION(&_6, "exp", &_7, &_1); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_10); div_function(_10, _4, _6 TSRMLS_CC); item_psr = zephir_get_numberval(_10); ZEPHIR_INIT_NVAR(_11); array_init_size(_11, 2); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, item_psr); zephir_array_fast_append(_11, _0); zephir_array_update_long(&psr, i, &_11, PH_COPY | PH_SEPARATE, "test/quantum.zep", 37); ZEPHIR_INIT_NVAR(_12); array_init_size(_12, 2); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, item_psi); zephir_array_fast_append(_12, _0); zephir_array_update_long(&psi, i, &_12, PH_COPY | PH_SEPARATE, "test/quantum.zep", 38); ZEPHIR_INIT_NVAR(_13); array_init_size(_13, 2); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, (double) ((double) (5.0 * x) * x)); zephir_array_fast_append(_13, _0); zephir_array_update_long(&v, i, &_13, PH_COPY | PH_SEPARATE, "test/quantum.zep", 39); x = (x + dx); i++; } i = 1; j = 1; ZEPHIR_INIT_VAR(tmp); array_init_size(tmp, 2); ZEPHIR_INIT_BNVAR(_0); ZVAL_DOUBLE(_0, 2.0); zephir_array_fast_append(tmp, _0); _16 = 20000; _15 = 0; _14 = 0; if (_15 <= _16) { while (1) { if (_14) { _15++; if (!(_15 <= _16)) { break; } } else { _14 = 1; } n = _15; _19 = (751 - 1); _18 = 1; _17 = 0; if (_18 <= _19) { while (1) { if (_17) { _18++; if (!(_18 <= _19)) { break; } } else { _17 = 1; } i = _18; zephir_array_fetch_long(&_20, psr, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_21, _20, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_23, psi, (i + 1), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _23, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_25, psi, (i - 1), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_26, _25, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function(&_1, _24, _26 TSRMLS_CC); zephir_array_fetch_long(&_24, tmp, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_26, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_27, _26, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _24, _27 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); zephir_sub_function(_8, &_1, &_2 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _22, _8 TSRMLS_CC); zephir_array_fetch_long(&_22, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); mul_function(_8, _22, _24 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); div_function(&_2, &_1, _8 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_sub_function(&_1, _21, &_2 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, v, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _22, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _21, _24 TSRMLS_CC); zephir_array_fetch_long(&_21, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _21, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_28); mul_function(&_28, &_2, _24 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); zephir_add_function(_8, &_1, &_28 TSRMLS_CC); zephir_array_update_multi(&psr, &_8 TSRMLS_CC, SL("ll"), 2, i, 1); zephir_array_fetch_long(&_24, psr, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_27, _24, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_29, psr, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_30, _29, 1, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _27, _30 TSRMLS_CC); zephir_array_fetch_long(&_27, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_30, _27, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_31, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_32, _31, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _30, _32 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); zephir_add_function(_8, &_1, &_2 TSRMLS_CC); zephir_array_update_long(&p2, i, &_8, PH_COPY | PH_SEPARATE, "test/quantum.zep", 51); } } _35 = (751 - 1); _34 = 1; _33 = 0; if (_34 <= _35) { while (1) { if (_33) { _34++; if (!(_34 <= _35)) { break; } } else { _33 = 1; } j = _34; ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 0, 1); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 751, 1); zephir_array_fetch_long(&_20, psi, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_21, _20, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_23, psr, (j + 1), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _23, 1, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_25, psr, (j - 1), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_26, _25, 1, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function(&_1, _24, _26 TSRMLS_CC); zephir_array_fetch_long(&_24, tmp, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_26, psr, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_27, _26, 1, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _24, _27 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); zephir_sub_function(_10, &_1, &_2 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _22, _10 TSRMLS_CC); zephir_array_fetch_long(&_22, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); mul_function(_10, _22, _24 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); div_function(&_2, &_1, _10 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function(&_1, _21, &_2 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, v, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _22, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _21, _24 TSRMLS_CC); zephir_array_fetch_long(&_21, psr, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _21, 1, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_28); mul_function(&_28, &_2, _24 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); zephir_sub_function(_10, &_1, &_28 TSRMLS_CC); zephir_array_update_multi(&psi, &_10 TSRMLS_CC, SL("ll"), 2, j, 1); } } _36 = n == 0; if (!(_36)) { _36 = (n % 2000) == 0; } if (_36) { i = 1; while (1) { if (!(i < (751 - 1))) { break; } zephir_array_fetch_long(&_20, p2, i, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "%16.8lf %16.8lf %16.8lf \n", 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_DOUBLE(&_2, ((double) i * dx)); ZEPHIR_SINIT_NVAR(_28); ZVAL_DOUBLE(&_28, ((double) n * dt)); ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_37, fp, &_1, &_2, &_28, _20); zephir_check_call_status(); i = (i + 10); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "\n", 0); ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_37, fp, &_1); zephir_check_call_status(); } j = 1; while (1) { if (!(j < (751 - 1))) { break; } zephir_array_fetch_long(&_20, psi, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_21, _20, 1, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_update_multi(&psi, &_21 TSRMLS_CC, SL("ll"), 2, j, 0); zephir_array_fetch_long(&_21, psr, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, _21, 1, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_update_multi(&psr, &_22 TSRMLS_CC, SL("ll"), 2, j, 0); j++; } } } RETURN_MM_BOOL(1); }
/** * Executes a prepared statement binding. This function uses integer indexes starting from zero * *<code> * $statement = $db->prepare('SELECT * FROM robots WHERE name = :name'); * $result = $connection->executePrepared($statement, array('name' => 'Voltron')); *</code> * * @param \PDOStatement statement * @param array placeholders * @param array dataTypes * @return \PDOStatement */ PHP_METHOD(Phalcon_Db_Adapter_Pdo, executePrepared) { zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *statement, *placeholders, *dataTypes, *wildcard = NULL, *value = NULL, *type = NULL, *castValue = NULL, *parameter = NULL, **_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &statement, &placeholders, &dataTypes); if (Z_TYPE_P(placeholders) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Placeholders must be an array", "phalcon/db/adapter/pdo.zep", 181); return; } zephir_is_iterable(placeholders, &_1, &_0, 0, 0, "phalcon/db/adapter/pdo.zep", 225); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(wildcard, _1, _0); ZEPHIR_GET_HVALUE(value, _2); if (Z_TYPE_P(wildcard) == IS_LONG) { ZEPHIR_INIT_NVAR(parameter); ZVAL_LONG(parameter, (zephir_get_numberval(wildcard) + 1)); } else { if (Z_TYPE_P(wildcard) == IS_STRING) { ZEPHIR_CPY_WRT(parameter, wildcard); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid bind parameter (1)", "phalcon/db/adapter/pdo.zep", 192); return; } } if (Z_TYPE_P(dataTypes) == IS_ARRAY) { ZEPHIR_OBS_NVAR(type); if (!(zephir_array_isset_fetch(&type, dataTypes, wildcard, 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid bind type parameter (2)", "phalcon/db/adapter/pdo.zep", 199); return; } if (ZEPHIR_IS_LONG(type, 32)) { ZEPHIR_INIT_NVAR(castValue); ZVAL_DOUBLE(castValue, zephir_get_doubleval(value)); ZEPHIR_INIT_NVAR(type); ZVAL_LONG(type, 1024); } else { ZEPHIR_CPY_WRT(castValue, value); } if (ZEPHIR_IS_LONG(type, 1024)) { ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_3, parameter, castValue); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_3, parameter, castValue, type); zephir_check_call_status(); } } else { ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_3, parameter, value); zephir_check_call_status(); } } ZEPHIR_CALL_METHOD(NULL, statement, "execute", NULL); zephir_check_call_status(); RETVAL_ZVAL(statement, 1, 0); RETURN_MM(); }
/** * Executes the validator */ PHP_METHOD(Phalcon_Mvc_Model_Validator_Url, validate) { zval *_6$$5; zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *value = NULL, *message = NULL, *_0 = NULL, *_1 = NULL, _3, *_4 = NULL, *_5$$5 = NULL, *_7$$5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/url.zep", 62); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _2 = zephir_is_true(_1); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 273); ZEPHIR_CALL_FUNCTION(&_4, "filter_var", NULL, 193, value, &_3); zephir_check_call_status(); if (!(zephir_is_true(_4))) { ZEPHIR_INIT_VAR(_5$$5); ZVAL_STRING(_5$$5, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _5$$5); zephir_check_temp_parameter(_5$$5); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, ":field does not have a valid url format", 1); } ZEPHIR_INIT_VAR(_6$$5); zephir_create_array(_6$$5, 1, 0 TSRMLS_CC); zephir_array_update_string(&_6$$5, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_7$$5, "strtr", NULL, 55, message, _6$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5$$5); ZVAL_STRING(_5$$5, "Url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _7$$5, field, _5$$5); zephir_check_temp_parameter(_5$$5); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * 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 row * *<code> * //Inserting data * $success = $connection->execute("INSERT INTO robots VALUES (1, 'Astro Boy')"); * $success = $connection->execute("INSERT INTO robots VALUES (?, ?)", array(1, 'Astro Boy')); *</code> * * @param string sqlStatement * @param array bindParams * @param array bindTypes * @return boolean */ PHP_METHOD(Phalcon_Db_Adapter_Pdo, execute) { int ZEPHIR_LAST_CALL_STATUS; zval *sqlStatement_param = NULL, *bindParams = NULL, *bindTypes = NULL, *eventsManager = NULL, *affectedRows = NULL, *pdo = NULL, *newStatement = NULL, *statement = NULL, *_0, *_1 = NULL, *_2 = NULL; zval *sqlStatement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &sqlStatement_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(sqlStatement_param) != IS_STRING && Z_TYPE_P(sqlStatement_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlStatement' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { zephir_get_strval(sqlStatement, sqlStatement_param); } else { ZEPHIR_INIT_VAR(sqlStatement); ZVAL_EMPTY_STRING(sqlStatement); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_sqlStatement"), sqlStatement TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlVariables"), bindParams TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlBindTypes"), bindTypes TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "db:beforeQuery", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, _2, this_ptr, bindParams); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(affectedRows); ZVAL_LONG(affectedRows, 0); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdo"), PH_NOISY_CC); ZEPHIR_CPY_WRT(pdo, _0); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&statement, pdo, "prepare", NULL, sqlStatement); zephir_check_call_status(); if (Z_TYPE_P(statement) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&newStatement, this_ptr, "executeprepared", NULL, statement, bindParams, bindTypes); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&affectedRows, newStatement, "rowcount", NULL); zephir_check_call_status(); } } else { ZEPHIR_CALL_METHOD(&affectedRows, pdo, "exec", NULL, sqlStatement); zephir_check_call_status(); } if (Z_TYPE_P(affectedRows) == IS_LONG) { zephir_update_property_this(this_ptr, SL("_affectedRows"), affectedRows TSRMLS_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "db:afterQuery", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, _2, this_ptr, bindParams); zephir_check_temp_parameter(_2); zephir_check_call_status(); } } RETURN_MM_BOOL(1); }
PHP_METHOD(Test_Fannkuch, process) { zend_bool _0, _4, _9; zval *n_param = NULL, *perm, *perm0, *perm1, *count, *temp, *_3 = NULL, *_7, *_8 = NULL, *_12, *_13 = NULL, *_14; int n, maxFlipsCount = 0, permCount = 0, checksum = 0, i, j, flipsCount, k, r, k2, _1, _2, _5, _6, _10, _11; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n_param); n = zephir_get_intval(n_param); ZEPHIR_INIT_VAR(perm); array_init(perm); ZEPHIR_INIT_VAR(perm1); array_init(perm1); ZEPHIR_INIT_VAR(count); array_init(count); _2 = n; _1 = 0; _0 = 0; if (_1 <= _2) { while (1) { if (_0) { _1++; if (!(_1 <= _2)) { break; } } else { _0 = 1; } i = _1; ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, i); zephir_array_update_long(&perm1, i, &_3, PH_COPY | PH_SEPARATE, "test/fannkuch.zep", 27); } } r = n; while (1) { if (0) { break; } while (1) { if (!(r != 1)) { break; } ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, r); zephir_array_update_long(&count, (r - 1), &_3, PH_COPY | PH_SEPARATE, "test/fannkuch.zep", 39); r--; } _6 = n; _5 = 0; _4 = 0; if (_5 <= _6) { while (1) { if (_4) { _5++; if (!(_5 <= _6)) { break; } } else { _4 = 1; } i = _5; zephir_array_fetch_long(&_7, perm1, i, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 43 TSRMLS_CC); zephir_array_update_long(&perm, i, &_7, PH_COPY | PH_SEPARATE, "test/fannkuch.zep", 43); } } flipsCount = 0; k = 0; while (1) { zephir_array_fetch_long(&_7, perm, 0, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 48 TSRMLS_CC); if (!(!ZEPHIR_IS_LONG(_7, 0))) { break; } ZEPHIR_OBS_NVAR(_8); zephir_array_fetch_long(&_8, perm, 0, PH_NOISY, "test/fannkuch.zep", 49 TSRMLS_CC); k = zephir_get_intval(_8); k2 = (((((k + 1)) / 2)) - 1); _11 = k2; _10 = 0; _9 = 0; if (_10 <= _11) { while (1) { if (_9) { _10++; if (!(_10 <= _11)) { break; } } else { _9 = 1; } i = _10; zephir_array_fetch_long(&temp, perm, i, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_12, perm, (k - i), PH_NOISY | PH_READONLY, "test/fannkuch.zep", 51 TSRMLS_CC); zephir_array_update_long(&perm, i, &_12, PH_COPY | PH_SEPARATE, "test/fannkuch.zep", 51); zephir_array_update_long(&perm, (k - i), &temp, PH_COPY | PH_SEPARATE, "test/fannkuch.zep", 51); } } flipsCount++; } if (maxFlipsCount < flipsCount) { maxFlipsCount = flipsCount; } if ((permCount % 2) == 0) { checksum += flipsCount; } else { checksum -= flipsCount; } while (1) { if (r == n) { array_init_size(return_value, 5); ZEPHIR_INIT_NVAR(_13); ZVAL_LONG(_13, checksum); zephir_array_fast_append(return_value, _13); ZEPHIR_INIT_NVAR(_13); ZVAL_LONG(_13, n); zephir_array_fast_append(return_value, _13); ZEPHIR_INIT_NVAR(_13); ZVAL_LONG(_13, maxFlipsCount); zephir_array_fast_append(return_value, _13); RETURN_MM(); } zephir_array_fetch_long(&perm0, perm1, 0, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 75 TSRMLS_CC); i = 0; while (1) { if (!(i < r)) { break; } j = (i + 1); zephir_array_fetch_long(&_7, perm1, j, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 78 TSRMLS_CC); zephir_array_update_long(&perm1, i, &_7, PH_COPY | PH_SEPARATE, "test/fannkuch.zep", 78); i = j; } zephir_array_update_long(&perm1, r, &perm0, PH_COPY | PH_SEPARATE, "test/fannkuch.zep", 82); zephir_array_fetch_long(&_12, count, r, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 82 TSRMLS_CC); ZEPHIR_INIT_NVAR(_13); ZVAL_LONG(_13, (zephir_get_numberval(_12) - 1)); zephir_array_update_long(&count, r, &_13, PH_COPY | PH_SEPARATE, "test/fannkuch.zep", 82); zephir_array_fetch_long(&_14, count, r, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 83 TSRMLS_CC); if (ZEPHIR_GT_LONG(_14, 0)) { break; } r++; } permCount++; } ZEPHIR_MM_RESTORE(); }
/** * Starts a transaction in the connection */ PHP_METHOD(Phalcon_Db_Adapter_Pdo, begin) { int transactionLevel, ZEPHIR_LAST_CALL_STATUS; zval *nesting_param = NULL, *pdo, *eventsManager = NULL, *savepointName = NULL, *_0, *_1, *_2 = NULL, *_5 = NULL; zend_bool nesting, _3, _4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &nesting_param); if (!nesting_param) { nesting = 1; } else { nesting = zephir_get_boolval(nesting_param); } ZEPHIR_OBS_VAR(pdo); zephir_read_property_this(&pdo, this_ptr, SL("_pdo"), PH_NOISY_CC); if (Z_TYPE_P(pdo) != IS_OBJECT) { RETURN_MM_BOOL(0); } RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_transactionLevel") TSRMLS_CC)); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_transactionLevel"), PH_NOISY_CC); transactionLevel = zephir_get_intval(_0); if (transactionLevel == 1) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _1); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "db:beginTransaction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, _2, this_ptr); zephir_check_temp_parameter(_2); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_METHOD(pdo, "begintransaction", NULL); zephir_check_call_status(); RETURN_MM(); } else { _3 = (transactionLevel) ? 1 : 0; if (_3) { _3 = nesting; } _4 = _3; if (_4) { ZEPHIR_CALL_METHOD(&_5, this_ptr, "isnestedtransactionswithsavepoints", NULL); zephir_check_call_status(); _4 = zephir_is_true(_5); } if (_4) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _1); ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "db:createSavepoint", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, _2, this_ptr, savepointName); zephir_check_temp_parameter(_2); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "createsavepoint", NULL, savepointName); zephir_check_call_status(); RETURN_MM(); } } RETURN_MM_BOOL(0); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Confirmation, validate) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *fieldWith = NULL, *value = NULL, *valueWith = NULL, *message = NULL, *label = NULL, *labelWith = NULL, *replacePairs = NULL, *code = NULL, *_0, *_2 = NULL, *_1$$3, *_3$$4 = NULL, *_5$$4 = NULL, *_6$$4, *_4$$5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (UNEXPECTED(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "with", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&fieldWith, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(fieldWith) == IS_ARRAY) { zephir_array_fetch(&_1$$3, fieldWith, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/confirmation.zep", 78 TSRMLS_CC); ZEPHIR_CPY_WRT(fieldWith, _1$$3); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&valueWith, validation, "getvalue", NULL, 0, fieldWith); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "compare", NULL, 482, value, valueWith); zephir_check_call_status(); if (!(zephir_is_true(_2))) { ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3$$4); ZVAL_STRING(_3$$4, "Confirmation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _3$$4); zephir_check_temp_parameter(_3$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&code, this_ptr, "preparecode", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3$$4); ZVAL_STRING(_3$$4, "labelWith", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&labelWith, this_ptr, "getoption", NULL, 0, _3$$4); zephir_check_temp_parameter(_3$$4); zephir_check_call_status(); if (Z_TYPE_P(labelWith) == IS_ARRAY) { zephir_array_fetch(&_4$$5, labelWith, fieldWith, PH_NOISY | PH_READONLY, "phalcon/validation/validator/confirmation.zep", 91 TSRMLS_CC); ZEPHIR_CPY_WRT(labelWith, _4$$5); } if (ZEPHIR_IS_EMPTY(labelWith)) { ZEPHIR_CALL_METHOD(&labelWith, validation, "getlabel", NULL, 0, fieldWith); zephir_check_call_status(); } ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":with"), &labelWith, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3$$4); object_init_ex(_3$$4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_5$$4, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6$$4); ZVAL_STRING(_6$$4, "Confirmation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _3$$4, "__construct", NULL, 479, _5$$4, field, _6$$4, code); zephir_check_temp_parameter(_6$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _3$$4); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }