/** * Writes meta-data for certain model using a MODEL_* constant * * @param Phalcon\Mvc\ModelInterface $model * @param int $index * @param mixed $data */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, writeMetaDataIndex){ zval *model, *index, *data, *table, *schema, *key, *meta_data = NULL; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &model, &index, &data) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (Z_TYPE_P(model) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "A model instance is required to retrieve the meta-data"); return; } if (Z_TYPE_P(index) != IS_LONG) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Index must be a valid integer constant"); return; } if (Z_TYPE_P(data) != IS_ARRAY) { if (Z_TYPE_P(data) != IS_STRING) { if (Z_TYPE_P(data) != IS_BOOL) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Invalid data for index"); return; } } } PHALCON_INIT_VAR(table); PHALCON_CALL_METHOD(table, model, "getsource", PH_NO_CHECK); PHALCON_INIT_VAR(schema); PHALCON_CALL_METHOD(schema, model, "getschema", PH_NO_CHECK); PHALCON_INIT_VAR(key); PHALCON_CONCAT_VV(key, schema, table); PHALCON_INIT_VAR(meta_data); phalcon_read_property(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC); eval_int = phalcon_array_isset(meta_data, key); if (!eval_int) { PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_initialize", model, key, table, schema, PH_NO_CHECK); PHALCON_INIT_NVAR(meta_data); phalcon_read_property(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC); } phalcon_array_update_multi_2(&meta_data, key, index, &data, 0 TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_metaData"), meta_data TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Reads meta-data for certain model using a MODEL_* constant * *<code> * print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name'))); *</code> * * @param Phalcon\Mvc\ModelInterface $model * @param int $index * @return array */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex){ zval *model, *index, *table, *schema, *class_name; zval *key, *meta_data = NULL, *meta_data_index, *attributes; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &model, &index) == FAILURE) { RETURN_MM_NULL(); } if (Z_TYPE_P(model) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "A model instance is required to retrieve the meta-data"); return; } if (Z_TYPE_P(index) != IS_LONG) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Index must be a valid integer constant"); return; } PHALCON_INIT_VAR(table); PHALCON_CALL_METHOD(table, model, "getsource"); PHALCON_INIT_VAR(schema); PHALCON_CALL_METHOD(schema, model, "getschema"); PHALCON_INIT_VAR(class_name); phalcon_get_class(class_name, model, 1 TSRMLS_CC); /** * Unique key for meta-data is created using class-name-schema-table */ PHALCON_INIT_VAR(key); PHALCON_CONCAT_VSVV(key, class_name, "-", schema, table); PHALCON_OBS_VAR(meta_data); phalcon_read_property(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC); if (!phalcon_array_isset(meta_data, key)) { PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_initialize", model, key, table, schema); PHALCON_OBS_NVAR(meta_data); phalcon_read_property(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC); } PHALCON_OBS_VAR(meta_data_index); phalcon_array_fetch(&meta_data_index, meta_data, key, PH_NOISY_CC); PHALCON_OBS_VAR(attributes); phalcon_array_fetch(&attributes, meta_data_index, index, PH_NOISY_CC); RETURN_CCTOR(attributes); }
/** * Reads meta-data for certain model using a MODEL_* constant * * @param Phalcon\Mvc\Model $model * @param int $index */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex){ zval *model, *index, *table, *schema, *key, *meta_data = NULL; zval *attributes; zval *r0 = NULL; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &model, &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (Z_TYPE_P(model) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "A model instance is required to retrieve the meta-data"); return; } if (Z_TYPE_P(index) != IS_LONG) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Index must be a valid integer constant"); return; } PHALCON_INIT_VAR(table); PHALCON_CALL_METHOD(table, model, "getsource", PH_NO_CHECK); PHALCON_INIT_VAR(schema); PHALCON_CALL_METHOD(schema, model, "getschema", PH_NO_CHECK); PHALCON_INIT_VAR(key); PHALCON_CONCAT_VV(key, schema, table); PHALCON_INIT_VAR(meta_data); phalcon_read_property(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC); eval_int = phalcon_array_isset(meta_data, key); if (!eval_int) { PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_initializemetadata", model, key, table, schema, PH_NO_CHECK); PHALCON_INIT_NVAR(meta_data); phalcon_read_property(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC); } PHALCON_INIT_VAR(r0); phalcon_array_fetch(&r0, meta_data, key, PH_NOISY_CC); PHALCON_INIT_VAR(attributes); phalcon_array_fetch(&attributes, r0, index, PH_NOISY_CC); RETURN_CCTOR(attributes); }
/** * Stores cached content into the APC backend and stops the frontend * * @param string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */ PHP_METHOD(Phalcon_Cache_Multiple, save){ zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL; zval *backends, *backend = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zzzz", &key_name, &content, &lifetime, &stop_buffer) == FAILURE) { RETURN_MM_NULL(); } if (!key_name) { PHALCON_INIT_VAR(key_name); } if (!content) { PHALCON_INIT_VAR(content); } if (!lifetime) { PHALCON_INIT_VAR(lifetime); } if (!stop_buffer) { PHALCON_INIT_VAR(stop_buffer); ZVAL_BOOL(stop_buffer, 1); } PHALCON_OBS_VAR(backends); phalcon_read_property(&backends, this_ptr, SL("_backends"), PH_NOISY_CC); if (!phalcon_is_iterable(backends, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_VALUE(backend); PHALCON_CALL_METHOD_PARAMS_4_NORETURN(backend, "save", key_name, content, lifetime, stop_buffer); zend_hash_move_forward_ex(ah0, &hp0); } PHALCON_MM_RESTORE(); }
/** * Reads column-map information for certain model using a MODEL_* constant * * @param Phalcon\Mvc\ModelInterface $model * @param int $index */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMapIndex){ zval *model, *index, *class_name, *column_map = NULL, *null_value; zval *attributes; zval *r0 = NULL; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &model, &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (Z_TYPE_P(model) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "A model instance is required to retrieve the meta-data"); return; } if (Z_TYPE_P(index) != IS_LONG) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Index must be a valid integer constant"); return; } PHALCON_INIT_VAR(class_name); phalcon_get_class(class_name, model TSRMLS_CC); PHALCON_INIT_VAR(column_map); phalcon_read_property(&column_map, this_ptr, SL("_columnMap"), PH_NOISY_CC); eval_int = phalcon_array_isset(column_map, class_name); if (!eval_int) { PHALCON_INIT_VAR(null_value); PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_initialize", model, null_value, null_value, null_value, PH_NO_CHECK); PHALCON_INIT_NVAR(column_map); phalcon_read_property(&column_map, this_ptr, SL("_columnMap"), PH_NOISY_CC); } PHALCON_INIT_VAR(r0); phalcon_array_fetch(&r0, column_map, class_name, PH_NOISY_CC); PHALCON_INIT_VAR(attributes); phalcon_array_fetch(&attributes, r0, index, PH_NOISY_CC); RETURN_CCTOR(attributes); }
/** * Reads the ordered/reversed column map for certain model * *<code> * print_r($metaData->readColumnMap(new Robots())); *</code> * * @param Phalcon\Mvc\ModelInterface $model * @return array */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMap){ zval *model, *class_name, *key_name, *column_map = NULL; zval *null_value, *data; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &model) == FAILURE) { RETURN_MM_NULL(); } if (Z_TYPE_P(model) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "A model instance is required to retrieve the meta-data"); return; } PHALCON_INIT_VAR(class_name); phalcon_get_class(class_name, model, 0 TSRMLS_CC); PHALCON_INIT_VAR(key_name); phalcon_fast_strtolower(key_name, class_name); PHALCON_OBS_VAR(column_map); phalcon_read_property(&column_map, this_ptr, SL("_columnMap"), PH_NOISY_CC); if (!phalcon_array_isset(column_map, key_name)) { PHALCON_INIT_VAR(null_value); PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_initialize", model, null_value, null_value, null_value); PHALCON_OBS_NVAR(column_map); phalcon_read_property(&column_map, this_ptr, SL("_columnMap"), PH_NOISY_CC); } PHALCON_OBS_VAR(data); phalcon_array_fetch(&data, column_map, key_name, PH_NOISY_CC); RETURN_CCTOR(data); }
/** * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. * Call it when you need to restore a database connection * * @param array $descriptor * @return boolean */ PHP_METHOD(Phalcon_Db_Adapter_Pdo, connect){ zval *descriptor = NULL, *username = NULL, *password = NULL, *dsn_parts = NULL; zval *value = NULL, *key = NULL, *dsn_attribute = NULL, *dot_comma = NULL, *dsn_attributes = NULL; zval *pdo_type = NULL, *dsn = NULL, *options = NULL, *persistent = NULL, *pdo = NULL; HashTable *ah0; HashPosition hp0; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; int eval_int; zend_class_entry *ce0; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &descriptor) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!descriptor) { PHALCON_ALLOC_ZVAL_MM(descriptor); ZVAL_NULL(descriptor); } else { PHALCON_SEPARATE_PARAM(descriptor); } if (Z_TYPE_P(descriptor) == IS_NULL) { PHALCON_INIT_VAR(descriptor); phalcon_read_property(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC); } eval_int = phalcon_array_isset_string(descriptor, SS("username")); if (eval_int) { PHALCON_INIT_VAR(username); phalcon_array_fetch_string(&username, descriptor, SL("username"), PH_NOISY_CC); PHALCON_SEPARATE_PARAM(descriptor); phalcon_array_unset_string(descriptor, SS("username")); } else { PHALCON_INIT_VAR(username); ZVAL_NULL(username); } eval_int = phalcon_array_isset_string(descriptor, SS("password")); if (eval_int) { PHALCON_INIT_VAR(password); phalcon_array_fetch_string(&password, descriptor, SL("password"), PH_NOISY_CC); PHALCON_SEPARATE_PARAM(descriptor); phalcon_array_unset_string(descriptor, SS("password")); } else { PHALCON_INIT_VAR(password); ZVAL_NULL(password); } eval_int = phalcon_array_isset_string(descriptor, SS("dsn")); if (!eval_int) { PHALCON_INIT_VAR(dsn_parts); array_init(dsn_parts); if (!phalcon_valid_foreach(descriptor TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(descriptor); zend_hash_internal_pointer_reset_ex(ah0, &hp0); ph_cycle_start_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto ph_cycle_end_0; } PHALCON_INIT_VAR(key); PHALCON_GET_FOREACH_KEY(key, ah0, hp0); PHALCON_GET_FOREACH_VALUE(value); PHALCON_INIT_VAR(dsn_attribute); PHALCON_CONCAT_VSV(dsn_attribute, key, "=", value); phalcon_array_append(&dsn_parts, dsn_attribute, PH_SEPARATE TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto ph_cycle_start_0; ph_cycle_end_0: PHALCON_INIT_VAR(dot_comma); ZVAL_STRING(dot_comma, ";", 1); PHALCON_INIT_VAR(dsn_attributes); phalcon_fast_join(dsn_attributes, dot_comma, dsn_parts TSRMLS_CC); } else { PHALCON_INIT_VAR(dsn_attributes); phalcon_array_fetch_string(&dsn_attributes, descriptor, SL("dsn"), PH_NOISY_CC); } PHALCON_INIT_VAR(pdo_type); phalcon_read_property(&pdo_type, this_ptr, SL("_type"), PH_NOISY_CC); PHALCON_INIT_VAR(dsn); PHALCON_CONCAT_VSV(dsn, pdo_type, ":", dsn_attributes); PHALCON_INIT_VAR(options); array_init(options); add_index_long(options, PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION); add_index_long(options, PDO_ATTR_CASE, PDO_CASE_LOWER); add_index_long(options, PDO_ATTR_CURSOR, PDO_CURSOR_SCROLL); eval_int = phalcon_array_isset_string(descriptor, SS("persistent")); if (eval_int) { PHALCON_INIT_VAR(persistent); phalcon_array_fetch_string(&persistent, descriptor, SL("persistent"), PH_NOISY_CC); if (zend_is_true(persistent)) { phalcon_array_update_long_bool(&options, PDO_ATTR_PERSISTENT, 1, PH_SEPARATE TSRMLS_CC); } } ce0 = zend_fetch_class(SL("PDO"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); PHALCON_INIT_VAR(pdo); object_init_ex(pdo, ce0); PHALCON_CALL_METHOD_PARAMS_4_NORETURN(pdo, "__construct", dsn, username, password, options, PH_CHECK); phalcon_update_property_zval(this_ptr, SL("_pdo"), pdo TSRMLS_CC); PHALCON_MM_RESTORE();}
/** * 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){ zval *descriptor = NULL, *username = NULL, *password = NULL, *dsn_parts; zval *value = NULL, *key = NULL, *dsn_attribute = NULL, *dsn_attributes = NULL; zval *pdo_type, *dsn, *options = NULL, *persistent, *pdo; zend_class_entry *ce; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &descriptor) == FAILURE) { RETURN_MM_NULL(); } if (!descriptor) { PHALCON_INIT_VAR(descriptor); } else { PHALCON_SEPARATE_PARAM(descriptor); } if (Z_TYPE_P(descriptor) == IS_NULL) { PHALCON_OBS_NVAR(descriptor); phalcon_read_property(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC); } /** * Check for a username or use null as default */ if (phalcon_array_isset_string(descriptor, SS("username"))) { PHALCON_OBS_VAR(username); phalcon_array_fetch_string(&username, descriptor, SL("username"), PH_NOISY_CC); phalcon_array_unset_string(&descriptor, SS("username"), PH_SEPARATE); } else { PHALCON_INIT_NVAR(username); } /** * Check for a password or use null as default */ if (phalcon_array_isset_string(descriptor, SS("password"))) { PHALCON_OBS_VAR(password); phalcon_array_fetch_string(&password, descriptor, SL("password"), PH_NOISY_CC); phalcon_array_unset_string(&descriptor, SS("password"), PH_SEPARATE); } else { PHALCON_INIT_NVAR(password); } /** * Check if the user has defined a custom dsn */ if (!phalcon_array_isset_string(descriptor, SS("dsn"))) { PHALCON_INIT_VAR(dsn_parts); array_init(dsn_parts); if (!phalcon_is_iterable(descriptor, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_KEY(key, ah0, hp0); PHALCON_GET_FOREACH_VALUE(value); PHALCON_INIT_NVAR(dsn_attribute); PHALCON_CONCAT_VSV(dsn_attribute, key, "=", value); phalcon_array_append(&dsn_parts, dsn_attribute, PH_SEPARATE TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); } PHALCON_INIT_VAR(dsn_attributes); phalcon_fast_join_str(dsn_attributes, SL(";"), dsn_parts TSRMLS_CC); } else { PHALCON_OBS_NVAR(dsn_attributes); phalcon_array_fetch_string(&dsn_attributes, descriptor, SL("dsn"), PH_NOISY_CC); } PHALCON_OBS_VAR(pdo_type); phalcon_read_property(&pdo_type, this_ptr, SL("_type"), PH_NOISY_CC); PHALCON_INIT_VAR(dsn); PHALCON_CONCAT_VSV(dsn, pdo_type, ":", dsn_attributes); /** * Check if the developer has defined custom options or create one from scratch */ if (phalcon_array_isset_string(descriptor, SS("options"))) { PHALCON_OBS_VAR(options); phalcon_array_fetch_string(&options, descriptor, SL("options"), PH_NOISY_CC); } else { PHALCON_INIT_NVAR(options); array_init(options); } phalcon_array_update_long_long(&options, PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION, PH_SEPARATE TSRMLS_CC); //phalcon_array_update_long_long(&options, PDO_ATTR_CASE, PDO_CASE_LOWER, PH_SEPARATE TSRMLS_CC); phalcon_array_update_long_long(&options, PDO_ATTR_CURSOR, PDO_CURSOR_SCROLL, PH_SEPARATE TSRMLS_CC); /** * Check if the connection must be persistent */ if (phalcon_array_isset_string(descriptor, SS("persistent"))) { PHALCON_OBS_VAR(persistent); phalcon_array_fetch_string(&persistent, descriptor, SL("persistent"), PH_NOISY_CC); if (zend_is_true(persistent)) { phalcon_array_update_long_bool(&options, PDO_ATTR_PERSISTENT, 1, PH_SEPARATE TSRMLS_CC); } } /** * Create the connection using PDO */ ce = zend_fetch_class(SL("PDO"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); PHALCON_INIT_VAR(pdo); object_init_ex(pdo, ce); PHALCON_CALL_METHOD_PARAMS_4_NORETURN(pdo, "__construct", dsn, username, password, options); phalcon_update_property_zval(this_ptr, SL("_pdo"), pdo TSRMLS_CC); PHALCON_MM_RESTORE();}
/** * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. * Call it when you need to restore a database connection * * @param array $descriptor * @return boolean */ PHP_METHOD(Phalcon_Db_Adapter_Pdo, connect){ zval *descriptor = NULL, *username = NULL, *password = NULL, *dsn_parts = NULL; zval *value = NULL, *key = NULL, *dsn = NULL, *options = NULL, *persistent = NULL; zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; zval *c0 = NULL; zval *i0 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; int eval_int; zend_class_entry *ce0; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &descriptor) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!descriptor) { PHALCON_ALLOC_ZVAL_MM(descriptor); ZVAL_NULL(descriptor); } else { PHALCON_SEPARATE_PARAM(descriptor); } if (!zend_is_true(descriptor)) { PHALCON_INIT_VAR(descriptor); phalcon_read_property(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC); } eval_int = phalcon_array_isset_string(descriptor, SL("username")+1); if (eval_int) { PHALCON_INIT_VAR(username); phalcon_array_fetch_string(&username, descriptor, SL("username"), PH_NOISY_CC); PHALCON_SEPARATE_PARAM(descriptor); phalcon_array_unset_string(descriptor, SL("username")+1); } else { PHALCON_INIT_VAR(username); ZVAL_NULL(username); } eval_int = phalcon_array_isset_string(descriptor, SL("password")+1); if (eval_int) { PHALCON_INIT_VAR(password); phalcon_array_fetch_string(&password, descriptor, SL("password"), PH_NOISY_CC); PHALCON_SEPARATE_PARAM(descriptor); phalcon_array_unset_string(descriptor, SL("password")+1); } else { PHALCON_INIT_VAR(password); ZVAL_NULL(password); } PHALCON_INIT_VAR(dsn_parts); array_init(dsn_parts); if (!phalcon_valid_foreach(descriptor TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(descriptor); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_7f5d_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_7f5d_0; } PHALCON_INIT_VAR(key); PHALCON_GET_FOREACH_KEY(key, ah0, hp0); PHALCON_INIT_VAR(value); ZVAL_ZVAL(value, *hd, 1, 0); PHALCON_INIT_VAR(r0); PHALCON_CONCAT_VSV(r0, key, "=", value); phalcon_array_append(&dsn_parts, r0, PH_SEPARATE TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_7f5d_0; fee_7f5d_0: if(0){} PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_type"), PH_NOISY_CC); PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, ";", 1); PHALCON_ALLOC_ZVAL_MM(r1); phalcon_fast_join(r1, c0, dsn_parts TSRMLS_CC); PHALCON_INIT_VAR(dsn); PHALCON_CONCAT_VSV(dsn, t0, ":", r1); PHALCON_INIT_VAR(options); array_init(options); add_index_long(options, 3, 0); add_index_long(options, 8, 2); add_index_long(options, 10, 1); eval_int = phalcon_array_isset_string(descriptor, SL("persistent")+1); if (eval_int) { PHALCON_INIT_VAR(persistent); phalcon_array_fetch_string(&persistent, descriptor, SL("persistent"), PH_NOISY_CC); if (zend_is_true(persistent)) { phalcon_array_update_long_bool(&options, 12, 1, PH_SEPARATE TSRMLS_CC); } } ce0 = zend_fetch_class(SL("PDO"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, ce0); PHALCON_CALL_METHOD_PARAMS_4_NORETURN(i0, "__construct", dsn, username, password, options, PH_CHECK); phalcon_update_property_zval(this_ptr, SL("_pdo"), i0 TSRMLS_CC); PHALCON_CALL_PARENT_PARAMS_1_NORETURN(this_ptr, "Phalcon\\Db\\Adapter\\Pdo", "__construct", descriptor); PHALCON_MM_RESTORE(); }
/** * Executes the dispatch loop * * @return Phalcon_View */ PHP_METHOD(Phalcon_Controller_Front, dispatchLoop){ zval *dispatcher = NULL, *router = NULL, *base_path = NULL, *view = NULL, *model = NULL; zval *response = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_dispatcher"), PH_NOISY_CC); if (!zend_is_true(t0)) { PHALCON_INIT_VAR(dispatcher); object_init_ex(dispatcher, phalcon_dispatcher_ce); PHALCON_CALL_METHOD_NORETURN(dispatcher, "__construct", PH_CHECK); PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, SL("_controllersDir"), PH_NOISY_CC); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(dispatcher, "setcontrollersdir", t1, PH_NO_CHECK); } else { PHALCON_INIT_VAR(dispatcher); phalcon_read_property(&dispatcher, this_ptr, SL("_dispatcher"), PH_NOISY_CC); } PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, SL("_request"), PH_NOISY_CC); if (!zend_is_true(t2)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC(r0, "phalcon\\request", "getinstance"); phalcon_update_property_zval(this_ptr, SL("_request"), r0 TSRMLS_CC); } PHALCON_ALLOC_ZVAL_MM(t3); phalcon_read_property(&t3, this_ptr, SL("_response"), PH_NOISY_CC); if (!zend_is_true(t3)) { PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_STATIC(r1, "phalcon\\response", "getinstance"); phalcon_update_property_zval(this_ptr, SL("_response"), r1 TSRMLS_CC); } PHALCON_ALLOC_ZVAL_MM(t4); phalcon_read_property(&t4, this_ptr, SL("_router"), PH_NOISY_CC); if (!zend_is_true(t4)) { PHALCON_INIT_VAR(router); object_init_ex(router, phalcon_router_rewrite_ce); PHALCON_CALL_METHOD_NORETURN(router, "__construct", PH_CHECK); PHALCON_CALL_METHOD_NORETURN(router, "handle", PH_NO_CHECK); } else { PHALCON_INIT_VAR(router); phalcon_read_property(&router, this_ptr, SL("_router"), PH_NOISY_CC); } PHALCON_INIT_VAR(base_path); phalcon_read_property(&base_path, this_ptr, SL("_basePath"), PH_NOISY_CC); PHALCON_INIT_VAR(view); PHALCON_CALL_METHOD(view, this_ptr, "getviewcomponent", PH_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(view, "setbasepath", base_path, PH_NO_CHECK); PHALCON_CALL_METHOD_NORETURN(view, "start", PH_NO_CHECK); PHALCON_INIT_VAR(model); PHALCON_CALL_METHOD(model, this_ptr, "getmodelcomponent", PH_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(model, "setbasepath", base_path, PH_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(dispatcher, "setbasepath", base_path, PH_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r2); PHALCON_CALL_METHOD(r2, router, "getcontrollername", PH_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(dispatcher, "setcontrollername", r2, PH_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r3); PHALCON_CALL_METHOD(r3, router, "getactionname", PH_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(dispatcher, "setactionname", r3, PH_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r4); PHALCON_CALL_METHOD(r4, router, "getparams", PH_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(dispatcher, "setparams", r4, PH_NO_CHECK); phalcon_update_property_zval(this_ptr, SL("_dispatcher"), dispatcher TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_router"), router TSRMLS_CC); PHALCON_INIT_VAR(response); phalcon_read_property(&response, this_ptr, SL("_response"), PH_NOISY_CC); PHALCON_ALLOC_ZVAL_MM(t5); phalcon_read_property(&t5, this_ptr, SL("_request"), PH_NOISY_CC); PHALCON_CALL_METHOD_PARAMS_4_NORETURN(dispatcher, "dispatch", t5, response, view, model, PH_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r5); PHALCON_CALL_METHOD(r5, dispatcher, "getcontrollername", PH_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r6); PHALCON_CALL_METHOD(r6, dispatcher, "getactionname", PH_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r7); PHALCON_CALL_METHOD(r7, dispatcher, "getparams", PH_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_3_NORETURN(view, "render", r5, r6, r7, PH_NO_CHECK); PHALCON_CALL_METHOD_NORETURN(view, "finish", PH_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r8); PHALCON_CALL_METHOD(r8, view, "getcontent", PH_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(response, "setcontent", r8, PH_NO_CHECK); PHALCON_CALL_METHOD_NORETURN(response, "sendheaders", PH_NO_CHECK); RETURN_CCTOR(response); }