/** * Set a param by its name or numeric index * * @param mixed $param * @param mixed $value */ PHP_METHOD(Phalcon_Dispatcher, setParam){ zval *param = NULL, *value = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", ¶m, &value) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_params"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update(&t0, param, &value, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_params"), t0 TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Adds parameters to views * * @param string $key * @param mixed $value */ PHP_METHOD(Phalcon_View, setVar){ zval *key = NULL, *value = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &key, &value) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_viewParams", sizeof("_viewParams")-1, PHALCON_NOISY TSRMLS_CC); phalcon_array_update(&t0, key, &value, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_update_property_zval(this_ptr, "_viewParams", strlen("_viewParams"), t0 TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Writes the meta-data to $_SESSION * * @param array $data */ PHP_METHOD(Phalcon_Model_MetaData_Session, write){ zval *data = NULL; zval *g0 = NULL; zval *r0 = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &data) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } phalcon_get_global(&g0, "_SESSION", sizeof("_SESSION") TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_suffix", sizeof("_suffix")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CONCAT_SV(r0, "$PMM$", t0); phalcon_array_update(&g0, r0, &data, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Dispatches a controller action taking into account the routing parameters * * @param Phalcon_Request $request * @param Phalcon_Response $response * @param Phalcon_View $view * @param Phalcon_Model_Manager $model * @return Phalcon_Controller */ PHP_METHOD(Phalcon_Dispatcher, dispatch){ zval *request = NULL, *response = NULL, *view = NULL, *model = NULL, *controllers_dir = NULL; zval *value = NULL, *controller = NULL, *number_dispatches = NULL; zval *controller_name = NULL, *controllers = NULL, *controller_class = NULL; zval *controller_path = NULL, *params = NULL, *action_name = NULL; zval *action_method = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL; zval *t7 = NULL, *t8 = NULL, *t9 = NULL, *t10 = NULL; zval *c0 = NULL, *c1 = NULL, *c2 = NULL; zval *i0 = NULL; zval *a0 = NULL, *a1 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; int eval_int; zend_class_entry *ce0; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|zz", &request, &response, &view, &model) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!view) { PHALCON_INIT_VAR(view); ZVAL_NULL(view); } if (!model) { PHALCON_INIT_VAR(model); ZVAL_NULL(model); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_basePath"), PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, SL("_controllersDir"), PHALCON_NOISY TSRMLS_CC); PHALCON_CONCAT_VV(r0, t0, t1); PHALCON_CPY_WRT(controllers_dir, r0); PHALCON_INIT_VAR(value); ZVAL_NULL(value); PHALCON_INIT_VAR(controller); ZVAL_NULL(controller); PHALCON_INIT_VAR(number_dispatches); ZVAL_LONG(number_dispatches, 0); phalcon_update_property_bool(this_ptr, SL("_finished"), 0 TSRMLS_CC); ws_e10f_0: PHALCON_INIT_VAR(t2); phalcon_read_property(&t2, this_ptr, SL("_finished"), PHALCON_NOISY TSRMLS_CC); if (zend_is_true(t2)) { goto we_e10f_0; } phalcon_update_property_bool(this_ptr, SL("_finished"), 1 TSRMLS_CC); PHALCON_INIT_VAR(t3); phalcon_read_property(&t3, this_ptr, SL("_controllerName"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(controller_name, t3); if (!zend_is_true(controller_name)) { PHALCON_INIT_VAR(t4); phalcon_read_property(&t4, this_ptr, SL("_defaultController"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(controller_name, t4); phalcon_update_property_zval(this_ptr, SL("_controllerName"), controller_name TSRMLS_CC); } PHALCON_INIT_VAR(t5); phalcon_read_property(&t5, this_ptr, SL("_controllers"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(controllers, t5); PHALCON_INIT_VAR(r1); PHALCON_INIT_VAR(r2); PHALCON_CALL_STATIC_PARAMS_1(r2, "phalcon_text", "camelize", controller_name); PHALCON_CONCAT_VS(r1, r2, "Controller"); PHALCON_CPY_WRT(controller_class, r1); eval_int = phalcon_array_isset(controllers, controller_class); if (!eval_int) { PHALCON_INIT_VAR(c0); ZVAL_BOOL(c0, 0); PHALCON_INIT_VAR(r3); PHALCON_CALL_FUNC_PARAMS_2(r3, "class_exists", controller_class, c0); if (!zend_is_true(r3)) { PHALCON_INIT_VAR(r4); PHALCON_CONCAT_VVS(r4, controllers_dir, controller_class, ".php"); PHALCON_CPY_WRT(controller_path, r4); if (phalcon_file_exists(controller_path TSRMLS_CC) == SUCCESS) { if (phalcon_require(controller_path TSRMLS_CC) == FAILURE) { return; } } else { PHALCON_INIT_VAR(r5); PHALCON_CONCAT_SVS(r5, "File for controller class ", controller_class, " doesn't exist"); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "_throwdispatchexception", response, r5, PHALCON_NO_CHECK); } PHALCON_INIT_VAR(c1); ZVAL_BOOL(c1, 0); PHALCON_INIT_VAR(r6); PHALCON_CALL_FUNC_PARAMS_2(r6, "class_exists", controller_class, c1); if (!zend_is_true(r6)) { PHALCON_INIT_VAR(r7); PHALCON_CONCAT_SVS(r7, "Class ", controller_class, " was not found on controller file"); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "_throwdispatchexception", response, r7, PHALCON_NO_CHECK); } } ce0 = phalcon_fetch_class(controller_class TSRMLS_CC); PHALCON_INIT_VAR(i0); object_init_ex(i0, ce0); p0[0] = this_ptr; p0[1] = request; p0[2] = response; p0[3] = view; p0[4] = model; PHALCON_CALL_METHOD_PARAMS_NORETURN(i0, "__construct", 5, p0, PHALCON_CHECK); PHALCON_CPY_WRT(controller, i0); if (phalcon_method_exists_ex(controller, SL("initialize") TSRMLS_CC) == SUCCESS) { PHALCON_CALL_METHOD_NORETURN(controller, "initialize", PHALCON_NO_CHECK); } PHALCON_INIT_VAR(t6); phalcon_read_property(&t6, this_ptr, SL("_controllers"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update(&t6, controller_class, &controller, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_controllers"), t6 TSRMLS_CC); } else { PHALCON_INIT_VAR(r8); phalcon_array_fetch(&r8, controllers, controller_class, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(controller, r8); } PHALCON_INIT_VAR(t7); phalcon_read_property(&t7, this_ptr, SL("_params"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(params, t7); PHALCON_INIT_VAR(t8); phalcon_read_property(&t8, this_ptr, SL("_actionName"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(action_name, t8); if (!zend_is_true(action_name)) { PHALCON_INIT_VAR(t9); phalcon_read_property(&t9, this_ptr, SL("_defaultAction"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(action_name, t9); phalcon_update_property_zval(this_ptr, SL("_actionName"), action_name TSRMLS_CC); } if (phalcon_method_exists_ex(controller, SL("beforedispatch") TSRMLS_CC) == SUCCESS) { PHALCON_INIT_VAR(r9); PHALCON_CALL_METHOD_PARAMS_3(r9, controller, "beforedispatch", controller_name, action_name, params, PHALCON_NO_CHECK); if (Z_TYPE_P(r9) == IS_BOOL && !Z_BVAL_P(r9)) { PHALCON_INIT_VAR(value); ZVAL_BOOL(value, 0); goto we_e10f_0; } } PHALCON_INIT_VAR(r10); PHALCON_CONCAT_VS(r10, action_name, "Action"); PHALCON_CPY_WRT(action_method, r10); if (phalcon_method_exists(controller, action_method TSRMLS_CC) == SUCCESS) { PHALCON_INIT_VAR(a0); array_init(a0); phalcon_array_append(&a0, controller, PHALCON_SEPARATE_PLZ TSRMLS_CC); phalcon_array_append(&a0, action_method, PHALCON_SEPARATE_PLZ TSRMLS_CC); PHALCON_INIT_VAR(value); PHALCON_CALL_FUNC_PARAMS_2(value, "call_user_func_array", a0, params); } else { if (phalcon_method_exists_ex(controller, SL("notfoundaction") TSRMLS_CC) == SUCCESS) { PHALCON_INIT_VAR(a1); array_init(a1); phalcon_array_append(&a1, controller, PHALCON_SEPARATE_PLZ TSRMLS_CC); add_next_index_stringl(a1, SL("notFoundAction"), 1); PHALCON_INIT_VAR(value); PHALCON_CALL_FUNC_PARAMS_2(value, "call_user_func_array", a1, params); } else { PHALCON_INIT_VAR(r11); PHALCON_CONCAT_SVSVS(r11, "Action '", action_name, "' was not found on controller '", controller_name, "'"); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "_throwdispatchexception", response, r11, PHALCON_NO_CHECK); } } if (phalcon_method_exists_ex(controller, SL("afterdispatch") TSRMLS_CC) == SUCCESS) { PHALCON_CALL_METHOD_PARAMS_3_NORETURN(controller, "afterdispatch", controller_name, action_name, params, PHALCON_NO_CHECK); } PHALCON_SEPARATE(number_dispatches); increment_function(number_dispatches); PHALCON_INIT_VAR(t10); ZVAL_LONG(t10, 256); PHALCON_INIT_VAR(r12); is_smaller_function(r12, t10, number_dispatches TSRMLS_CC); if (zend_is_true(r12)) { PHALCON_INIT_VAR(c2); ZVAL_STRING(c2, "Dispatcher has detected a cyclic routing causing stability problems", 1); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "_throwdispatchexception", response, c2, PHALCON_NO_CHECK); } goto ws_e10f_0; we_e10f_0: phalcon_update_property_zval(this_ptr, SL("_returnedValue"), value TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_lastController"), controller TSRMLS_CC); RETURN_CHECK_CTOR(controller); }
/** * Lists table references * * @param string $table * @param string $schema * @return Phalcon_Db_Reference[] */ PHP_METHOD(Phalcon_Db_Adapter_Mysql, describeReferences){ zval *table = NULL, *schema = NULL, *sql = NULL, *references = NULL, *describe = NULL; zval *reference = NULL, *constraint_name = NULL, *reference_objects = NULL; zval *array_reference = NULL, *name = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL; zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL, *a4 = NULL, *a5 = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL; zval *i0 = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table, &schema) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!schema) { PHALCON_INIT_VAR(schema); ZVAL_NULL(schema); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC_PARAMS_2(r0, "phalcon_db_dialect_mysql", "describereferences", table, schema); PHALCON_CPY_WRT(sql, r0); PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(references, a0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 1); PHALCON_CALL_METHOD_PARAMS_2(r1, this_ptr, "fetchall", sql, t0, PHALCON_NO_CHECK); PHALCON_CPY_WRT(describe, r1); if (phalcon_valid_foreach(describe TSRMLS_CC)) { ah0 = Z_ARRVAL_P(describe); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_321f_4: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_321f_4; } PHALCON_INIT_VAR(reference); ZVAL_ZVAL(reference, *hd, 1, 0); PHALCON_INIT_VAR(r2); phalcon_array_fetch_string(&r2, reference, SL("CONSTRAINT_NAME"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(constraint_name, r2); eval_int = phalcon_array_isset(references, constraint_name); if (!eval_int) { PHALCON_INIT_VAR(a1); array_init(a1); PHALCON_INIT_VAR(r3); phalcon_array_fetch_string(&r3, reference, SL("REFERENCED_TABLE_SCHEMA"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update_string(&a1, SL("referencedSchema"), &r3, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_INIT_VAR(r4); phalcon_array_fetch_string(&r4, reference, SL("REFERENCED_TABLE_NAME"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update_string(&a1, SL("referencedTable"), &r4, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_INIT_VAR(a2); array_init(a2); phalcon_array_update_string(&a1, SL("columns"), &a2, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_INIT_VAR(a3); array_init(a3); phalcon_array_update_string(&a1, SL("referencedColumns"), &a3, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_array_update(&references, constraint_name, &a1, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } PHALCON_INIT_VAR(r5); phalcon_array_fetch_string(&r5, reference, SL("COLUMN_NAME"), PHALCON_NOISY TSRMLS_CC); if (Z_TYPE_P(references) == IS_ARRAY) { PHALCON_INIT_VAR(t1); phalcon_array_fetch(&t1, references, constraint_name, PHALCON_SILENT TSRMLS_CC); } if (Z_REFCOUNT_P(t1) > 1) { phalcon_array_update(&references, constraint_name, &t1, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC); } if (Z_TYPE_P(t1) != IS_ARRAY) { convert_to_array(t1); phalcon_array_update(&references, constraint_name, &t1, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } if (Z_TYPE_P(t1) == IS_ARRAY) { PHALCON_INIT_VAR(t2); phalcon_array_fetch_string(&t2, t1, SL("columns"), PHALCON_SILENT TSRMLS_CC); } if (Z_REFCOUNT_P(t2) > 1) { phalcon_array_update_string(&t1, SL("columns"), &t2, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC); } if (Z_TYPE_P(t2) != IS_ARRAY) { convert_to_array(t2); phalcon_array_update_string(&t1, SL("columns"), &t2, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } phalcon_array_append(&t2, r5, PHALCON_NO_SEPARATE_THX TSRMLS_CC); PHALCON_INIT_VAR(r6); phalcon_array_fetch_string(&r6, reference, SL("REFERENCED_COLUMN_NAME"), PHALCON_NOISY TSRMLS_CC); if (Z_TYPE_P(references) == IS_ARRAY) { PHALCON_INIT_VAR(t3); phalcon_array_fetch(&t3, references, constraint_name, PHALCON_SILENT TSRMLS_CC); } if (Z_REFCOUNT_P(t3) > 1) { phalcon_array_update(&references, constraint_name, &t3, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC); } if (Z_TYPE_P(t3) != IS_ARRAY) { convert_to_array(t3); phalcon_array_update(&references, constraint_name, &t3, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } if (Z_TYPE_P(t3) == IS_ARRAY) { PHALCON_INIT_VAR(t4); phalcon_array_fetch_string(&t4, t3, SL("referencedColumns"), PHALCON_SILENT TSRMLS_CC); } if (Z_REFCOUNT_P(t4) > 1) { phalcon_array_update_string(&t3, SL("referencedColumns"), &t4, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC); } if (Z_TYPE_P(t4) != IS_ARRAY) { convert_to_array(t4); phalcon_array_update_string(&t3, SL("referencedColumns"), &t4, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } phalcon_array_append(&t4, r6, PHALCON_NO_SEPARATE_THX TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_321f_4; fee_321f_4: if(0){} } else { return; } PHALCON_INIT_VAR(a4); array_init(a4); PHALCON_CPY_WRT(reference_objects, a4); if (phalcon_valid_foreach(references TSRMLS_CC)) { ah1 = Z_ARRVAL_P(references); zend_hash_internal_pointer_reset_ex(ah1, &hp1); fes_321f_5: if(zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS){ goto fee_321f_5; } else { PHALCON_INIT_VAR(name); PHALCON_GET_FOREACH_KEY(name, ah1, hp1); } PHALCON_INIT_VAR(array_reference); ZVAL_ZVAL(array_reference, *hd, 1, 0); PHALCON_INIT_VAR(i0); object_init_ex(i0, phalcon_db_reference_ce); PHALCON_INIT_VAR(a5); array_init(a5); PHALCON_INIT_VAR(r7); phalcon_array_fetch_string(&r7, array_reference, SL("referencedSchema"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update_string(&a5, SL("referencedSchema"), &r7, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_INIT_VAR(r8); phalcon_array_fetch_string(&r8, array_reference, SL("referencedTable"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update_string(&a5, SL("referencedTable"), &r8, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_INIT_VAR(r9); phalcon_array_fetch_string(&r9, array_reference, SL("columns"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update_string(&a5, SL("columns"), &r9, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_INIT_VAR(r10); phalcon_array_fetch_string(&r10, array_reference, SL("referencedColumns"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update_string(&a5, SL("referencedColumns"), &r10, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(i0, "__construct", name, a5, PHALCON_CHECK); phalcon_array_update(&reference_objects, name, &i0, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); zend_hash_move_forward_ex(ah1, &hp1); goto fes_321f_5; fee_321f_5: if(0){} } else { return; } RETURN_CTOR(reference_objects); }
/** * Lists table indexes * * @param string $table * @param string $schema * @return Phalcon_Db_Index[] */ PHP_METHOD(Phalcon_Db_Adapter_Mysql, describeIndexes){ zval *table = NULL, *schema = NULL, *sql = NULL, *describe = NULL, *indexes = NULL, *index = NULL; zval *key_name = NULL, *index_objects = NULL, *index_columns = NULL; zval *name = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL; zval *t0 = NULL; zval *a0 = NULL, *a1 = NULL, *a2 = NULL; zval *i0 = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table, &schema) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!schema) { PHALCON_INIT_VAR(schema); ZVAL_NULL(schema); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC_PARAMS_2(r0, "phalcon_db_dialect_mysql", "describeindexes", table, schema); PHALCON_CPY_WRT(sql, r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 1); PHALCON_CALL_METHOD_PARAMS_2(r1, this_ptr, "fetchall", sql, t0, PHALCON_NO_CHECK); PHALCON_CPY_WRT(describe, r1); PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(indexes, a0); if (phalcon_valid_foreach(describe TSRMLS_CC)) { ah0 = Z_ARRVAL_P(describe); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_321f_2: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_321f_2; } PHALCON_INIT_VAR(index); ZVAL_ZVAL(index, *hd, 1, 0); PHALCON_INIT_VAR(r2); phalcon_array_fetch_string(&r2, index, SL("Key_name"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(key_name, r2); eval_int = phalcon_array_isset(indexes, key_name); if (!eval_int) { PHALCON_INIT_VAR(a1); array_init(a1); phalcon_array_update(&indexes, key_name, &a1, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } PHALCON_INIT_VAR(r3); phalcon_array_fetch_string(&r3, index, SL("Column_name"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update_multi_append_2(&indexes, key_name, r3, PHALCON_NO_SEPARATE_THX TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_321f_2; fee_321f_2: if(0){} } else { return; } PHALCON_INIT_VAR(a2); array_init(a2); PHALCON_CPY_WRT(index_objects, a2); if (phalcon_valid_foreach(indexes TSRMLS_CC)) { ah1 = Z_ARRVAL_P(indexes); zend_hash_internal_pointer_reset_ex(ah1, &hp1); fes_321f_3: if(zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS){ goto fee_321f_3; } else { PHALCON_INIT_VAR(name); PHALCON_GET_FOREACH_KEY(name, ah1, hp1); } PHALCON_INIT_VAR(index_columns); ZVAL_ZVAL(index_columns, *hd, 1, 0); PHALCON_INIT_VAR(i0); object_init_ex(i0, phalcon_db_index_ce); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(i0, "__construct", name, index_columns, PHALCON_CHECK); phalcon_array_update(&index_objects, name, &i0, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); zend_hash_move_forward_ex(ah1, &hp1); goto fes_321f_3; fee_321f_3: if(0){} } else { return; } RETURN_CTOR(index_objects); }
/** * Get the conditions of query * * @return string $query */ PHP_METHOD(Phalcon_Model_Query, getConditions){ zval *controller_front = NULL, *model_manager = NULL, *model_name = NULL; zval *entity = NULL, *meta_data = NULL, *attributes = NULL, *numeric_types = NULL; zval *i = NULL, *parameters = NULL, *conditions = NULL, *value = NULL, *param = NULL; zval *condition = NULL, *index = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL; zval *t7 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL, *r15 = NULL, *r16 = NULL, *r17 = NULL, *r18 = NULL; zval *i0 = NULL; zval *a0 = NULL, *a1 = NULL; zval *c0 = NULL; HashTable *ah0, *ah1, *ah2; HashPosition hp0, hp1, hp2; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; int eval_int; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_manager", sizeof("_manager")-1, PHALCON_NOISY TSRMLS_CC); if (!zend_is_true(t0)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC(r0, "phalcon_controller_front", "getinstance"); PHALCON_CPY_WRT(controller_front, r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_METHOD(r1, controller_front, "getmodelcomponent", PHALCON_NO_CHECK); PHALCON_CPY_WRT(model_manager, r1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setmanager", model_manager, PHALCON_NO_CHECK); } else { PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, "_manager", sizeof("_manager")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(model_manager, t1); } PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, "_models", sizeof("_models")-1, PHALCON_NOISY TSRMLS_CC); if (phalcon_valid_foreach(t2 TSRMLS_CC)) { ah0 = Z_ARRVAL_P(t2); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_a355_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_a355_0; } PHALCON_INIT_VAR(model_name); ZVAL_ZVAL(model_name, *hd, 1, 0); PHALCON_INIT_VAR(r2); PHALCON_CALL_METHOD_PARAMS_1(r2, model_manager, "getmodel", model_name, PHALCON_NO_CHECK); PHALCON_CPY_WRT(entity, r2); if (!zend_is_true(entity)) { PHALCON_INIT_VAR(i0); object_init_ex(i0, phalcon_model_exception_ce); PHALCON_INIT_VAR(r3); PHALCON_CONCAT_BOTH(r3, "The model ", model_name, " does not exist"); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", r3, PHALCON_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } PHALCON_INIT_VAR(r4); PHALCON_CALL_METHOD(r4, model_manager, "getmetadata", PHALCON_NO_CHECK); PHALCON_CPY_WRT(meta_data, r4); PHALCON_INIT_VAR(r5); PHALCON_CALL_METHOD_PARAMS_1(r5, meta_data, "getattributes", entity, PHALCON_NO_CHECK); PHALCON_CPY_WRT(attributes, r5); PHALCON_INIT_VAR(r6); PHALCON_CALL_METHOD_PARAMS_1(r6, meta_data, "getdatatypesnumeric", entity, PHALCON_NO_CHECK); PHALCON_CPY_WRT(numeric_types, r6); PHALCON_INIT_VAR(t3); phalcon_read_property(&t3, this_ptr, "_data", sizeof("_data")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_INIT_VAR(r7); phalcon_fast_count(r7, t3 TSRMLS_CC); if (zend_is_true(r7)) { PHALCON_INIT_VAR(i); ZVAL_LONG(i, 0); PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(parameters, a0); PHALCON_INIT_VAR(a1); array_init(a1); PHALCON_CPY_WRT(conditions, a1); PHALCON_INIT_VAR(t4); phalcon_read_property(&t4, this_ptr, "_data", sizeof("_data")-1, PHALCON_NOISY TSRMLS_CC); if (phalcon_valid_foreach(t4 TSRMLS_CC)) { ah1 = Z_ARRVAL_P(t4); zend_hash_internal_pointer_reset_ex(ah1, &hp1); fes_a355_1: if(zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS){ goto fee_a355_1; } else { PHALCON_INIT_VAR(param); PHALCON_GET_FOREACH_KEY(param, ah1, hp1); } PHALCON_INIT_VAR(value); ZVAL_ZVAL(value, *hd, 1, 0); PHALCON_INIT_VAR(r8); PHALCON_CALL_FUNC_PARAMS_2(r8, "in_array", param, attributes, 0x03E); if (zend_is_true(r8)) { PHALCON_INIT_VAR(t5); ZVAL_STRING(t5, "", 1); PHALCON_INIT_VAR(r9); is_not_identical_function(r9, t5, value TSRMLS_CC); PHALCON_INIT_VAR(r11); PHALCON_CALL_FUNC_PARAMS_1(r11, "is_null", value, 0x041); PHALCON_INIT_VAR(r10); boolean_not_function(r10, r11 TSRMLS_CC); PHALCON_INIT_VAR(r12); phalcon_and_function(r12, r9, r10); if (zend_is_true(r12)) { if (!PHALCON_COMPARE_STRING(value, "@")) { eval_int = phalcon_array_isset(numeric_types, param); if (eval_int) { PHALCON_INIT_VAR(r13); PHALCON_CONCAT_VBOTH(r13, param, " = ?", i); PHALCON_CPY_WRT(condition, r13); phalcon_array_update(¶meters, i, &value, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } else { PHALCON_INIT_VAR(r14); PHALCON_CONCAT_VBOTH(r14, param, " LIKE ?", i); PHALCON_CPY_WRT(condition, r14); PHALCON_INIT_VAR(r15); PHALCON_CONCAT_BOTH(r15, "%", value, "%"); phalcon_array_update(¶meters, i, &r15, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } phalcon_array_append(&conditions, condition, PHALCON_SEPARATE_PLZ TSRMLS_CC); } } } PHALCON_SEPARATE(i); increment_function(i); zend_hash_move_forward_ex(ah1, &hp1); goto fes_a355_1; fee_a355_1: if(0){} } else { return; } } else { PHALCON_INIT_VAR(t6); phalcon_read_property(&t6, this_ptr, "_parameters", sizeof("_parameters")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(parameters, t6); PHALCON_INIT_VAR(t7); phalcon_read_property(&t7, this_ptr, "_conditions", sizeof("_conditions")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(conditions, t7); } PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, " AND ", 1); PHALCON_INIT_VAR(r16); phalcon_fast_join(r16, c0, conditions TSRMLS_CC); PHALCON_CPY_WRT(conditions, r16); if (phalcon_valid_foreach(parameters TSRMLS_CC)) { ah2 = Z_ARRVAL_P(parameters); zend_hash_internal_pointer_reset_ex(ah2, &hp2); fes_a355_2: if(zend_hash_get_current_data_ex(ah2, (void**) &hd, &hp2) != SUCCESS){ goto fee_a355_2; } else { PHALCON_INIT_VAR(index); PHALCON_GET_FOREACH_KEY(index, ah2, hp2); } PHALCON_INIT_VAR(value); ZVAL_ZVAL(value, *hd, 1, 0); PHALCON_INIT_VAR(r17); PHALCON_INIT_VAR(r18); PHALCON_CONCAT_LEFT(r18, "?", index); PHALCON_CALL_FUNC_PARAMS_3(r17, "str_replace", r18, value, conditions, 0x003); PHALCON_CPY_WRT(conditions, r17); zend_hash_move_forward_ex(ah2, &hp2); goto fes_a355_2; fee_a355_2: if(0){} } else { return; } if (PHALCON_COMPARE_STRING(conditions, "")) { PHALCON_INIT_VAR(conditions); ZVAL_STRING(conditions, "1=1", 1); } PHALCON_RETURN_CHECK_CTOR(conditions); zend_hash_move_forward_ex(ah0, &hp0); goto fes_a355_0; fee_a355_0: if(0){} } else { return; } PHALCON_MM_RESTORE(); }
/** * Loads registered template engines, if none is registered use Phalcon_View_Engine_Php * * @return array */ PHP_METHOD(Phalcon_View, _loadTemplateEngines){ zval *engines = NULL, *registered_engines = NULL, *engine = NULL; zval *extension = NULL, *options = NULL, *name = NULL, *class_name = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL; zval *a0 = NULL, *a1 = NULL, *a2 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL; zval *i0 = NULL, *i1 = NULL, *i2 = 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(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_engines", sizeof("_engines")-1, PHALCON_NOISY TSRMLS_CC); if (!zend_is_true(t0)) { PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(engines, a0); PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, "_registeredEngines", sizeof("_registeredEngines")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(registered_engines, t1); PHALCON_ALLOC_ZVAL_MM(r0); phalcon_fast_count(r0, registered_engines TSRMLS_CC); if (!zend_is_true(r0)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_view_engine_php_ce); PHALCON_INIT_VAR(a1); array_init(a1); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(i0, "__construct", this_ptr, a1, PHALCON_CHECK); phalcon_array_update_string(&engines, ".phtml", strlen(".phtml"), &i0, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } else { if (phalcon_valid_foreach(registered_engines TSRMLS_CC)) { ah0 = Z_ARRVAL_P(registered_engines); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_b0d8_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_b0d8_0; } else { PHALCON_INIT_VAR(extension); PHALCON_GET_FOREACH_KEY(extension, ah0, hp0); } PHALCON_INIT_VAR(engine); ZVAL_ZVAL(engine, *hd, 1, 0); PHALCON_INIT_VAR(a2); array_init(a2); PHALCON_CPY_WRT(options, a2); if (Z_TYPE_P(engine) == IS_ARRAY) { eval_int = phalcon_array_isset_long(engine, 0); if (eval_int) { PHALCON_INIT_VAR(r1); phalcon_array_fetch_long(&r1, engine, 0, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(name, r1); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_view_exception_ce, "The template engine name is required"); return; } eval_int = phalcon_array_isset_long(engine, 1); if (eval_int) { PHALCON_INIT_VAR(r2); phalcon_array_fetch_long(&r2, engine, 1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(options, r2); } } else { if (Z_TYPE_P(engine) == IS_STRING) { PHALCON_CPY_WRT(name, engine); } else { if (Z_TYPE_P(engine) == IS_OBJECT) { PHALCON_CALL_METHOD_PARAMS_2_NORETURN(engine, "initialize", this_ptr, options, PHALCON_NO_CHECK); phalcon_array_update(&engines, extension, &engine, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); goto fes_b0d8_0; } else { PHALCON_THROW_EXCEPTION_STR(phalcon_view_exception_ce, "The template engine is invalid"); return; } } } PHALCON_INIT_VAR(r3); PHALCON_CONCAT_SV(r3, "Phalcon_View_Engine_", name); PHALCON_CPY_WRT(class_name, r3); PHALCON_INIT_VAR(r4); PHALCON_CALL_FUNC_PARAMS_1(r4, "class_exists", class_name, 0x012); if (zend_is_true(r4)) { ce0 = phalcon_fetch_class(class_name TSRMLS_CC); PHALCON_INIT_VAR(i1); object_init_ex(i1, ce0); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(i1, "__construct", this_ptr, options, PHALCON_CHECK); phalcon_array_update(&engines, extension, &i1, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } else { PHALCON_INIT_VAR(i2); object_init_ex(i2, phalcon_view_exception_ce); PHALCON_INIT_VAR(r5); PHALCON_CONCAT_SVS(r5, "Template engine '", class_name, "' cannot be loaded"); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i2, "__construct", r5, PHALCON_CHECK); phalcon_throw_exception(i2 TSRMLS_CC); return; } zend_hash_move_forward_ex(ah0, &hp0); goto fes_b0d8_0; fee_b0d8_0: if(0){} } else { return; } } phalcon_update_property_zval(this_ptr, "_engines", strlen("_engines"), engines TSRMLS_CC); } else { PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, "_engines", sizeof("_engines")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(engines, t2); } PHALCON_RETURN_CHECK_CTOR(engines); }
PHP_METHOD(Phalcon_Test, nice){ zval *v0 = NULL, *v1 = NULL, *v2 = NULL, *v3 = NULL; zval *a0 = NULL; zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; char *index; uint index_len; ulong num; int htype; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &v0) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(a0); array_init(a0); add_assoc_long_ex(a0, "hello1", strlen("hello1")+1, 1); add_assoc_long_ex(a0, "hello2", strlen("hello2")+1, 2); add_assoc_long_ex(a0, "hello3", strlen("hello3")+1, 3); PHALCON_CPY_WRT(v1, a0); if (Z_TYPE_P(v1) != IS_ARRAY) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument supplied for foreach()"); } else { ALLOC_HASHTABLE(ah0); zend_hash_init(ah0, 0, NULL, NULL, 0); zend_hash_copy(ah0, Z_ARRVAL_P(v1), NULL, NULL, sizeof(zval*)); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_2ebb_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_2ebb_0; } else { PHALCON_INIT_VAR(v3); htype = zend_hash_get_current_key_ex(ah0, &index, &index_len, &num, 0, &hp0); if (htype == HASH_KEY_IS_STRING) { ZVAL_STRINGL(v3, index, index_len-1, 1); } else { if (htype == HASH_KEY_IS_LONG) { ZVAL_LONG(v3, num); } } } PHALCON_INIT_VAR(v2); ZVAL_ZVAL(v2, *hd, 1, 0); PHALCON_INIT_VAR(r0); phalcon_array_fetch(&r0, v1, v3, PHALCON_NOISY_FETCH TSRMLS_CC); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 100); PHALCON_INIT_VAR(r1); phalcon_add_function(r1, r0, t0 TSRMLS_CC); Z_ADDREF_P(r1); if (Z_REFCOUNT_P(v1) > 1) { zval *new_zv; Z_DELREF_P(v1); ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, v1); v1 = new_zv; zval_copy_ctor(new_zv); } phalcon_array_update(v1, v3, r1 TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_2ebb_0; fee_2ebb_0: zend_hash_destroy(ah0); efree(ah0); } PHALCON_CALL_FUNC_PARAMS_1_NORETURN("print_r", v1, 0x015); PHALCON_MM_RESTORE(); RETURN_NULL(); }
PHP_METHOD(Phalcon_Model_MetaData, _initializeMetaData){ zval *model = NULL, *table = NULL, *schema = NULL, *key = NULL, *connection = NULL, *is_view = NULL; zval *exists = NULL, *meta_datas = NULL, *attributes = NULL, *primary_keys = NULL; zval *non_primary_keys = NULL, *numeric_typed = NULL, *not_null = NULL; zval *field_types = NULL, *identity_field = NULL, *meta_data = NULL; zval *field_name = NULL, *type = NULL, *table_metadata = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL, *r15 = NULL, *r16 = NULL, *r17 = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL; zval *i0 = NULL; zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL, *a4 = NULL, *a5 = NULL, *a6 = NULL; zval *a7 = NULL; zval *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &model, &table, &schema) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CONCAT_VV(r0, schema, table); PHALCON_CPY_WRT(key, r0); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_metaData"), PHALCON_NOISY TSRMLS_CC); eval_int = phalcon_array_isset(t0, key); if (!eval_int) { PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_METHOD(r1, model, "getconnection", PHALCON_NO_CHECK); PHALCON_CPY_WRT(connection, r1); PHALCON_ALLOC_ZVAL_MM(r2); PHALCON_CALL_METHOD(r2, model, "isview", PHALCON_NO_CHECK); PHALCON_CPY_WRT(is_view, r2); if (!zend_is_true(is_view)) { PHALCON_ALLOC_ZVAL_MM(r3); PHALCON_CALL_METHOD_PARAMS_2(r3, connection, "tableexists", table, schema, PHALCON_NO_CHECK); PHALCON_CPY_WRT(exists, r3); } else { PHALCON_ALLOC_ZVAL_MM(r4); PHALCON_CALL_METHOD_PARAMS_2(r4, connection, "viewexists", table, schema, PHALCON_NO_CHECK); PHALCON_CPY_WRT(exists, r4); } if (!zend_is_true(exists)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_model_exception_ce); PHALCON_ALLOC_ZVAL_MM(r5); PHALCON_ALLOC_ZVAL_MM(r6); phalcon_get_class(r6, model TSRMLS_CC); PHALCON_CONCAT_SVSVSV(r5, "Table \"", schema, "\".\"", table, "\" doesn't exist on database when dumping information for ", r6); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", r5, PHALCON_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } else { if (zend_is_true(is_view)) { PHALCON_ALLOC_ZVAL_MM(r7); PHALCON_CALL_METHOD_PARAMS_2(r7, connection, "describeview", table, schema, PHALCON_NO_CHECK); PHALCON_CPY_WRT(meta_datas, r7); } else { PHALCON_ALLOC_ZVAL_MM(r8); PHALCON_CALL_METHOD_PARAMS_2(r8, connection, "describetable", table, schema, PHALCON_NO_CHECK); PHALCON_CPY_WRT(meta_datas, r8); } PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(attributes, a0); PHALCON_INIT_VAR(a1); array_init(a1); PHALCON_CPY_WRT(primary_keys, a1); PHALCON_INIT_VAR(a2); array_init(a2); PHALCON_CPY_WRT(non_primary_keys, a2); PHALCON_INIT_VAR(a3); array_init(a3); PHALCON_CPY_WRT(numeric_typed, a3); PHALCON_INIT_VAR(a4); array_init(a4); PHALCON_CPY_WRT(not_null, a4); PHALCON_INIT_VAR(a5); array_init(a5); PHALCON_CPY_WRT(field_types, a5); PHALCON_INIT_VAR(identity_field); ZVAL_BOOL(identity_field, 0); if (phalcon_valid_foreach(meta_datas TSRMLS_CC)) { ah0 = Z_ARRVAL_P(meta_datas); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_f5c6_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_f5c6_0; } PHALCON_INIT_VAR(meta_data); ZVAL_ZVAL(meta_data, *hd, 1, 0); PHALCON_INIT_VAR(r9); phalcon_array_fetch_string(&r9, meta_data, SL("Field"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(field_name, r9); phalcon_array_append(&attributes, field_name, PHALCON_SEPARATE_PLZ TSRMLS_CC); PHALCON_INIT_VAR(r10); phalcon_array_fetch_string(&r10, meta_data, SL("Key"), PHALCON_NOISY TSRMLS_CC); if (PHALCON_COMPARE_STRING(r10, "PRI")) { phalcon_array_append(&primary_keys, field_name, PHALCON_SEPARATE_PLZ TSRMLS_CC); } else { phalcon_array_append(&non_primary_keys, field_name, PHALCON_SEPARATE_PLZ TSRMLS_CC); } PHALCON_INIT_VAR(r11); phalcon_array_fetch_string(&r11, meta_data, SL("Type"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(type, r11); phalcon_array_update(&field_types, field_name, &type, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, "char", 1); PHALCON_INIT_VAR(r12); phalcon_fast_strpos(r12, type, c0 TSRMLS_CC); if (Z_TYPE_P(r12) == IS_BOOL && !Z_BVAL_P(r12)) { PHALCON_INIT_VAR(c1); ZVAL_STRING(c1, "int", 1); PHALCON_INIT_VAR(r13); phalcon_fast_strpos(r13, type, c1 TSRMLS_CC); if (Z_TYPE_P(r13) != IS_BOOL || (Z_TYPE_P(r13) == IS_BOOL && Z_BVAL_P(r13))) { PHALCON_INIT_VAR(t1); ZVAL_BOOL(t1, 1); phalcon_array_update(&numeric_typed, field_name, &t1, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } else { PHALCON_INIT_VAR(c2); ZVAL_STRING(c2, "decimal", 1); PHALCON_INIT_VAR(r14); phalcon_fast_strpos(r14, type, c2 TSRMLS_CC); if (Z_TYPE_P(r14) != IS_BOOL || (Z_TYPE_P(r14) == IS_BOOL && Z_BVAL_P(r14))) { PHALCON_INIT_VAR(t2); ZVAL_BOOL(t2, 1); phalcon_array_update(&numeric_typed, field_name, &t2, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } else { PHALCON_INIT_VAR(c3); ZVAL_STRING(c3, "numeric", 1); PHALCON_INIT_VAR(r15); phalcon_fast_strpos(r15, type, c3 TSRMLS_CC); if (Z_TYPE_P(r15) != IS_BOOL || (Z_TYPE_P(r15) == IS_BOOL && Z_BVAL_P(r15))) { PHALCON_INIT_VAR(t3); ZVAL_BOOL(t3, 1); phalcon_array_update(&numeric_typed, field_name, &t3, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } } } } PHALCON_INIT_VAR(r16); phalcon_array_fetch_string(&r16, meta_data, SL("Null"), PHALCON_NOISY TSRMLS_CC); if (PHALCON_COMPARE_STRING(r16, "NO")) { phalcon_array_append(¬_null, field_name, PHALCON_SEPARATE_PLZ TSRMLS_CC); } PHALCON_INIT_VAR(r17); phalcon_array_fetch_string(&r17, meta_data, SL("Extra"), PHALCON_NOISY TSRMLS_CC); if (PHALCON_COMPARE_STRING(r17, "auto_increment")) { PHALCON_CPY_WRT(identity_field, field_name); } zend_hash_move_forward_ex(ah0, &hp0); goto fes_f5c6_0; fee_f5c6_0: if(0){} } else { return; } PHALCON_INIT_VAR(a6); array_init(a6); PHALCON_CPY_WRT(table_metadata, a6); phalcon_array_update_long(&table_metadata, 0, &attributes, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_array_update_long(&table_metadata, 1, &primary_keys, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_array_update_long(&table_metadata, 2, &non_primary_keys, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_array_update_long(&table_metadata, 3, ¬_null, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_array_update_long(&table_metadata, 4, &field_types, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_array_update_long(&table_metadata, 5, &numeric_typed, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_array_update_long(&table_metadata, 8, &identity_field, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(t4); phalcon_read_property(&t4, this_ptr, SL("_metaData"), PHALCON_NOISY TSRMLS_CC); phalcon_array_update(&t4, key, &table_metadata, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_metaData"), t4 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(t5); phalcon_read_property(&t5, this_ptr, SL("_changed"), PHALCON_NOISY TSRMLS_CC); if (!zend_is_true(t5)) { PHALCON_INIT_VAR(a7); array_init(a7); phalcon_array_append(&a7, this_ptr, PHALCON_SEPARATE_PLZ TSRMLS_CC); add_next_index_stringl(a7, SL("storeMetaData"), 1); PHALCON_CALL_FUNC_PARAMS_1_NORETURN("register_shutdown_function", a7); phalcon_update_property_bool(this_ptr, SL("_changed"), 1 TSRMLS_CC); } } } PHALCON_MM_RESTORE(); }
/** * Phalcon_Config_Adapter_Ini constructor * * @param string $filePath * @return Phalcon_Config_Adapter_Ini * */ PHP_METHOD(Phalcon_Config_Adapter_Ini, __construct){ zval *file_path = NULL, *config = NULL, *ini_config = NULL, *directives = NULL; zval *section = NULL, *value = NULL, *key = NULL, *directive_parts = NULL; zval *a0 = NULL; zval *c0 = NULL, *c1 = NULL, *c2 = NULL; zval *i0 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL; zval *t0 = NULL, *t1 = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &file_path) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(config, a0); PHALCON_INIT_VAR(c0); ZVAL_BOOL(c0, 1); PHALCON_INIT_VAR(ini_config); PHALCON_CALL_FUNC_PARAMS_2(ini_config, "parse_ini_file", file_path, c0); if (Z_TYPE_P(ini_config) == IS_BOOL && !Z_BVAL_P(ini_config)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_config_exception_ce); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_FUNC_PARAMS_1(r1, "basename", file_path); PHALCON_CONCAT_SVS(r0, "Configuration file ", r1, " can't be loaded"); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", r0, PHALCON_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } if (phalcon_valid_foreach(ini_config TSRMLS_CC)) { ah0 = Z_ARRVAL_P(ini_config); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_b840_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_b840_0; } else { PHALCON_INIT_VAR(section); PHALCON_GET_FOREACH_KEY(section, ah0, hp0); } PHALCON_INIT_VAR(directives); ZVAL_ZVAL(directives, *hd, 1, 0); if (phalcon_valid_foreach(directives TSRMLS_CC)) { ah1 = Z_ARRVAL_P(directives); zend_hash_internal_pointer_reset_ex(ah1, &hp1); fes_b840_1: if(zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS){ goto fee_b840_1; } else { PHALCON_INIT_VAR(key); PHALCON_GET_FOREACH_KEY(key, ah1, hp1); } PHALCON_INIT_VAR(value); ZVAL_ZVAL(value, *hd, 1, 0); PHALCON_INIT_VAR(c1); ZVAL_STRING(c1, ".", 1); PHALCON_INIT_VAR(r2); phalcon_fast_strpos(r2, key, c1 TSRMLS_CC); if (Z_TYPE_P(r2) != IS_BOOL || (Z_TYPE_P(r2) == IS_BOOL && Z_BVAL_P(r2))) { PHALCON_INIT_VAR(c2); ZVAL_STRING(c2, ".", 1); PHALCON_INIT_VAR(r3); phalcon_fast_explode(r3, c2, key TSRMLS_CC); PHALCON_CPY_WRT(directive_parts, r3); if (Z_TYPE_P(config) == IS_ARRAY) { PHALCON_INIT_VAR(t0); phalcon_array_fetch(&t0, config, section, PHALCON_SILENT TSRMLS_CC); } if (Z_REFCOUNT_P(t0) > 1) { phalcon_array_update(&config, section, &t0, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC); } if (Z_TYPE_P(t0) != IS_ARRAY) { convert_to_array(t0); phalcon_array_update(&config, section, &t0, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } PHALCON_INIT_VAR(r4); phalcon_array_fetch_long(&r4, directive_parts, 0, PHALCON_NOISY TSRMLS_CC); if (Z_TYPE_P(t0) == IS_ARRAY) { PHALCON_INIT_VAR(t1); phalcon_array_fetch(&t1, t0, r4, PHALCON_SILENT TSRMLS_CC); } if (Z_REFCOUNT_P(t1) > 1) { phalcon_array_update(&t0, r4, &t1, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC); } if (Z_TYPE_P(t1) != IS_ARRAY) { convert_to_array(t1); phalcon_array_update(&t0, r4, &t1, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } PHALCON_INIT_VAR(r5); phalcon_array_fetch_long(&r5, directive_parts, 1, PHALCON_NOISY TSRMLS_CC); phalcon_array_update(&t1, r5, &value, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } else { phalcon_array_update_multi_2(&config, section, key, &value, PHALCON_NO_SEPARATE_THX TSRMLS_CC); } zend_hash_move_forward_ex(ah1, &hp1); goto fes_b840_1; fee_b840_1: if(0){} } else { return; } zend_hash_move_forward_ex(ah0, &hp0); goto fes_b840_0; fee_b840_0: if(0){} } else { return; } PHALCON_CALL_PARENT_PARAMS_1_NORETURN(this_ptr, "Phalcon_Config_Adapter_Ini", "__construct", config); PHALCON_MM_RESTORE(); }
/** * Attaches Phalcon_Model_Base object to the active transaction * * @param int $pointer * @param Phalcon_Model_Base $object */ PHP_METHOD(Phalcon_Transaction, attachDependency){ zval *v0 = NULL, *v1 = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL; zval *r0 = NULL, *r1 = NULL; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &v0, &v1) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_SEPARATE_PARAM(v0); PHALCON_INIT_VAR(t0); ZVAL_NULL(t0); PHALCON_ALLOC_ZVAL_MM(r0); is_equal_function(r0, v0, t0 TSRMLS_CC); if (zend_is_true(r0)) { PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, "_pointer", sizeof("_pointer")-1, PHALCON_NOISY_FETCH TSRMLS_CC); PHALCON_SEPARATE_NMO(t1); increment_function(t1); phalcon_update_property_zval(this_ptr, "_pointer", strlen("_pointer"), t1 TSRMLS_CC); PHALCON_CPY_WRT(v0, t1); PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, "_dependencies", sizeof("_dependencies")-1, PHALCON_NOISY_FETCH TSRMLS_CC); Z_ADDREF_P(v1); phalcon_array_update(t2, v0, v1 TSRMLS_CC); phalcon_update_property_zval(this_ptr, "_dependencies", strlen("_dependencies"), t2 TSRMLS_CC); PHALCON_RETURN_CHECK_CTOR(v0); } else { PHALCON_ALLOC_ZVAL_MM(t3); phalcon_read_property(&t3, this_ptr, "_dependencies", sizeof("_dependencies")-1, PHALCON_NOISY_FETCH TSRMLS_CC); eval_int = phalcon_array_isset(t3, v0); PHALCON_INIT_VAR(r1); ZVAL_BOOL(r1, eval_int); if (!zend_is_true(r1)) { PHALCON_ALLOC_ZVAL_MM(t4); phalcon_read_property(&t4, this_ptr, "_dependencies", sizeof("_dependencies")-1, PHALCON_NOISY_FETCH TSRMLS_CC); Z_ADDREF_P(v1); phalcon_array_update(t4, v0, v1 TSRMLS_CC); phalcon_update_property_zval(this_ptr, "_dependencies", strlen("_dependencies"), t4 TSRMLS_CC); PHALCON_RETURN_CHECK_CTOR(v0); } else { PHALCON_ALLOC_ZVAL_MM(t5); phalcon_read_property(&t5, this_ptr, "_pointer", sizeof("_pointer")-1, PHALCON_NOISY_FETCH TSRMLS_CC); PHALCON_SEPARATE_NMO(t5); increment_function(t5); phalcon_update_property_zval(this_ptr, "_pointer", strlen("_pointer"), t5 TSRMLS_CC); PHALCON_CPY_WRT(v0, t5); PHALCON_ALLOC_ZVAL_MM(t6); phalcon_read_property(&t6, this_ptr, "_dependencies", sizeof("_dependencies")-1, PHALCON_NOISY_FETCH TSRMLS_CC); Z_ADDREF_P(v1); phalcon_array_update(t6, v0, v1 TSRMLS_CC); phalcon_update_property_zval(this_ptr, "_dependencies", strlen("_dependencies"), t6 TSRMLS_CC); PHALCON_RETURN_CHECK_CTOR(v0); } } PHALCON_MM_RESTORE(); RETURN_NULL(); }
/** * Updates data on a table using custom RBDM SQL syntax * * * * @param string $table * @param array $fields * @param array $values * @param string $whereCondition * @param boolean $automaticQuotes * @return boolean */ PHP_METHOD(Phalcon_Db, update){ zval *table = NULL, *fields = NULL, *values = NULL, *where_condition = NULL; zval *automatic_quotes = NULL, *i = NULL, *update_values = NULL, *update_sql = NULL; zval *field = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL, *r15 = NULL, *r16 = NULL, *r17 = NULL, *r18 = NULL; zval *a0 = NULL; zval *c0 = NULL; zval *t0 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|zz", &table, &fields, &values, &where_condition, &automatic_quotes) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_SEPARATE_PARAM(values); if (!where_condition) { PHALCON_INIT_VAR(where_condition); ZVAL_NULL(where_condition); } if (!automatic_quotes) { PHALCON_INIT_VAR(automatic_quotes); ZVAL_BOOL(automatic_quotes, 0); } PHALCON_ALLOC_ZVAL_MM(r0); phalcon_fast_count(r0, fields TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r1); phalcon_fast_count(r1, values TSRMLS_CC); PHALCON_INIT_VAR(r2); is_not_equal_function(r2, r0, r1 TSRMLS_CC); if (zend_is_true(r2)) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The number of values to update is not the same as fields"); return; } PHALCON_INIT_VAR(i); ZVAL_LONG(i, 0); PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(update_values, a0); PHALCON_ALLOC_ZVAL_MM(r3); PHALCON_CONCAT_SVS(r3, "UPDATE ", table, " SET "); PHALCON_CPY_WRT(update_sql, r3); if (phalcon_valid_foreach(fields TSRMLS_CC)) { ah0 = Z_ARRVAL_P(fields); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_e7f0_2: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_e7f0_2; } PHALCON_INIT_VAR(field); ZVAL_ZVAL(field, *hd, 1, 0); if (zend_is_true(automatic_quotes)) { PHALCON_INIT_VAR(r4); phalcon_array_fetch(&r4, values, i, PHALCON_NOISY TSRMLS_CC); if (Z_TYPE_P(r4) == IS_OBJECT) { PHALCON_INIT_VAR(r5); phalcon_array_fetch(&r5, values, i, PHALCON_NOISY TSRMLS_CC); PHALCON_INIT_VAR(r6); phalcon_instance_of(r6, r5, phalcon_db_rawvalue_ce TSRMLS_CC); if (zend_is_true(r6)) { PHALCON_INIT_VAR(r7); PHALCON_INIT_VAR(r8); PHALCON_INIT_VAR(r9); phalcon_array_fetch(&r9, values, i, PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r8, r9, "getvalue", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r7, this_ptr, "escapestring", r8, PHALCON_NO_CHECK); phalcon_array_update(&values, i, &r7, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); goto fes_e7f0_2; } } PHALCON_INIT_VAR(r10); PHALCON_INIT_VAR(r11); PHALCON_INIT_VAR(r12); phalcon_array_fetch(&r12, values, i, PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD_PARAMS_1(r11, this_ptr, "escapestring", r12, PHALCON_NO_CHECK); PHALCON_CONCAT_SVS(r10, "'", r11, "'"); phalcon_array_update(&values, i, &r10, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } PHALCON_INIT_VAR(r13); PHALCON_INIT_VAR(r14); phalcon_array_fetch(&r14, values, i, PHALCON_NOISY TSRMLS_CC); PHALCON_CONCAT_VSV(r13, field, " = ", r14); phalcon_array_append(&update_values, r13, PHALCON_SEPARATE_PLZ TSRMLS_CC); PHALCON_SEPARATE(i); increment_function(i); zend_hash_move_forward_ex(ah0, &hp0); goto fes_e7f0_2; fee_e7f0_2: if(0){} } else { return; } PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, ", ", 1); PHALCON_ALLOC_ZVAL_MM(r15); phalcon_fast_join(r15, c0, update_values TSRMLS_CC); phalcon_concat_self(&update_sql, r15 TSRMLS_CC); PHALCON_INIT_VAR(t0); ZVAL_NULL(t0); PHALCON_INIT_VAR(r16); is_not_equal_function(r16, where_condition, t0 TSRMLS_CC); if (zend_is_true(r16)) { PHALCON_ALLOC_ZVAL_MM(r17); PHALCON_CONCAT_SV(r17, " WHERE ", where_condition); phalcon_concat_self(&update_sql, r17 TSRMLS_CC); } PHALCON_ALLOC_ZVAL_MM(r18); PHALCON_CALL_METHOD_PARAMS_1(r18, this_ptr, "query", update_sql, PHALCON_NO_CHECK); PHALCON_RETURN_DZVAL(r18); }
/** * Inserts data into a table using custom RBDM SQL syntax * * * * @param string $table * @param array $values * @param array $fields * @param boolean $automaticQuotes * @return boolean */ PHP_METHOD(Phalcon_Db, insert){ zval *table = NULL, *values = NULL, *fields = NULL, *automatic_quotes = NULL; zval *value = NULL, *key = NULL, *joined_values = NULL, *insert_sql = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL; zval *i0 = NULL; zval *c0 = NULL, *c1 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|zz", &table, &values, &fields, &automatic_quotes) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_SEPARATE_PARAM(values); if (!fields) { PHALCON_INIT_VAR(fields); ZVAL_NULL(fields); } if (!automatic_quotes) { PHALCON_INIT_VAR(automatic_quotes); ZVAL_BOOL(automatic_quotes, 0); } if (Z_TYPE_P(values) == IS_ARRAY) { PHALCON_ALLOC_ZVAL_MM(r0); phalcon_fast_count(r0, values TSRMLS_CC); if (!zend_is_true(r0)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_db_exception_ce); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CONCAT_SVS(r1, "Unable to insert into ", table, " without data"); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", r1, PHALCON_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } else { if (zend_is_true(automatic_quotes)) { if (phalcon_valid_foreach(values TSRMLS_CC)) { ALLOC_HASHTABLE(ah0); zend_hash_init(ah0, 0, NULL, NULL, 0); zend_hash_copy(ah0, Z_ARRVAL_P(values), NULL, NULL, sizeof(zval*)); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_e7f0_1: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_e7f0_1; } else { PHALCON_INIT_VAR(key); PHALCON_GET_FOREACH_KEY(key, ah0, hp0); } PHALCON_INIT_VAR(value); ZVAL_ZVAL(value, *hd, 1, 0); if (Z_TYPE_P(value) == IS_OBJECT) { PHALCON_INIT_VAR(r2); phalcon_instance_of(r2, value, phalcon_db_rawvalue_ce TSRMLS_CC); if (zend_is_true(r2)) { PHALCON_INIT_VAR(r3); PHALCON_CALL_METHOD_PARAMS_1(r3, this_ptr, "escapestring", value, PHALCON_NO_CHECK); phalcon_array_update(&values, key, &r3, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); goto fes_e7f0_1; } } PHALCON_INIT_VAR(r4); PHALCON_INIT_VAR(r5); PHALCON_CALL_METHOD_PARAMS_1(r5, this_ptr, "escapestring", value, PHALCON_NO_CHECK); PHALCON_CONCAT_SVS(r4, "'", r5, "'"); phalcon_array_update(&values, key, &r4, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_e7f0_1; fee_e7f0_1: zend_hash_destroy(ah0); efree(ah0); } else { return; } } } PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, ", ", 1); PHALCON_ALLOC_ZVAL_MM(r6); phalcon_fast_join(r6, c0, values TSRMLS_CC); PHALCON_CPY_WRT(joined_values, r6); if (Z_TYPE_P(fields) == IS_ARRAY) { PHALCON_ALLOC_ZVAL_MM(r7); PHALCON_INIT_VAR(c1); ZVAL_STRING(c1, ", ", 1); PHALCON_ALLOC_ZVAL_MM(r8); phalcon_fast_join(r8, c1, fields TSRMLS_CC); PHALCON_CONCAT_SVSVSVS(r7, "INSERT INTO ", table, " (", r8, ") VALUES (", joined_values, ")"); PHALCON_CPY_WRT(insert_sql, r7); } else { PHALCON_ALLOC_ZVAL_MM(r9); PHALCON_CONCAT_SVSVS(r9, "INSERT INTO ", table, " VALUES (", joined_values, ")"); PHALCON_CPY_WRT(insert_sql, r9); } PHALCON_ALLOC_ZVAL_MM(r10); PHALCON_CALL_METHOD_PARAMS_1(r10, this_ptr, "query", insert_sql, PHALCON_NO_CHECK); PHALCON_RETURN_DZVAL(r10); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The second parameter for insert isn't an Array"); return; } PHALCON_MM_RESTORE(); }
PHP_METHOD(Phalcon_Request, _getQualityHeader){ zval *server_index = NULL, *name = NULL, *http_server = NULL, *parts = NULL; zval *returned_parts = NULL, *part = NULL, *header_parts = NULL, *quality = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL; zval *c0 = NULL, *c1 = NULL, *c2 = NULL; zval *a0 = NULL, *a1 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &server_index, &name) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_METHOD_PARAMS_1(r0, this_ptr, "getserver", server_index, PHALCON_NO_CHECK); PHALCON_CPY_WRT(http_server, r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, "/,\\s*/", 1); PHALCON_CALL_FUNC_PARAMS_2(r1, "preg_split", c0, http_server, 0x048); PHALCON_CPY_WRT(parts, r1); PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(returned_parts, a0); if (phalcon_valid_foreach(parts TSRMLS_CC)) { ah0 = Z_ARRVAL_P(parts); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_9aea_1: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_9aea_1; } PHALCON_INIT_VAR(part); ZVAL_ZVAL(part, *hd, 1, 0); PHALCON_INIT_VAR(c1); ZVAL_STRING(c1, ";", 1); PHALCON_INIT_VAR(r2); phalcon_fast_explode(r2, c1, part TSRMLS_CC); PHALCON_CPY_WRT(header_parts, r2); eval_int = phalcon_array_isset_long(header_parts, 1); if (eval_int) { PHALCON_INIT_VAR(r3); PHALCON_INIT_VAR(r4); phalcon_array_fetch_long(&r4, header_parts, 1, PHALCON_NOISY TSRMLS_CC); PHALCON_INIT_VAR(c2); ZVAL_LONG(c2, 2); PHALCON_CALL_FUNC_PARAMS_2(r3, "substr", r4, c2, 0x002); PHALCON_CPY_WRT(quality, r3); } else { PHALCON_INIT_VAR(quality); ZVAL_DOUBLE(quality, 1); } PHALCON_INIT_VAR(a1); array_init(a1); PHALCON_INIT_VAR(r5); phalcon_array_fetch_long(&r5, header_parts, 0, PHALCON_NOISY TSRMLS_CC); phalcon_array_update(&a1, name, &r5, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_array_update_string(&a1, "quality", strlen("quality"), &quality, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_array_append(&returned_parts, a1, PHALCON_SEPARATE_PLZ TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_9aea_1; fee_9aea_1: if(0){} } else { return; } PHALCON_RETURN_CTOR(returned_parts); }