/** * Renders the element widget * * @param array $attributes * @return string */ PHP_METHOD(Phalcon_Forms_Element_Select, render){ zval *attributes = NULL, *options, *widget_attributes; zval *code; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &attributes) == FAILURE) { RETURN_MM_NULL(); } if (!attributes) { PHALCON_INIT_VAR(attributes); } PHALCON_OBS_VAR(options); phalcon_read_property(&options, this_ptr, SL("_options"), PH_NOISY_CC); PHALCON_INIT_VAR(widget_attributes); PHALCON_CALL_METHOD_PARAMS_1(widget_attributes, this_ptr, "prepareattributes", attributes); PHALCON_INIT_VAR(code); PHALCON_CALL_STATIC_PARAMS_2(code, "phalcon\\tag\\select", "selectfield", widget_attributes, options); RETURN_CCTOR(code); }
/** * Generates SQL checking for the existence of a schema.table * * * * @param string $tableName * @param string $schemaName * @return string */ PHP_METHOD(Phalcon_Db_Adapter_Mysql, tableExists){ zval *table_name = NULL, *schema_name = NULL, *sql = NULL, *num = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table_name, &schema_name) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!schema_name) { PHALCON_INIT_VAR(schema_name); ZVAL_NULL(schema_name); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC_PARAMS_2(r0, "phalcon_db_dialect_mysql", "tableexists", table_name, schema_name); PHALCON_CPY_WRT(sql, r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 2); PHALCON_CALL_METHOD_PARAMS_2(r1, this_ptr, "fetchone", sql, t0, PHALCON_NO_CHECK); PHALCON_CPY_WRT(num, r1); PHALCON_ALLOC_ZVAL_MM(r2); phalcon_array_fetch_long(&r2, num, 0, PHALCON_NOISY TSRMLS_CC); RETURN_CHECK_CTOR(r2); }
/** * Generates SQL describing a table * * * * @param string $table * @param string $schema * @return string */ PHP_METHOD(Phalcon_Db_Adapter_Mysql, describeTable){ zval *table = NULL, *schema = NULL, *sql = NULL, *describe = NULL; zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; 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", "describetable", 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); RETURN_CHECK_CTOR(describe); }
/** * Check whether internal resource has rows to fetch * * @return boolean */ PHP_METHOD(Phalcon_Model_Resultset, valid){ zval *result = NULL, *row = NULL, *rows = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL; zval *c0 = NULL, *c1 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_type", sizeof("_type")-1, PHALCON_NOISY TSRMLS_CC); if (zend_is_true(t0)) { PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, "_result", sizeof("_result")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(result, t1); if (Z_TYPE_P(result) != IS_BOOL || (Z_TYPE_P(result) == IS_BOOL && Z_BVAL_P(result))) { PHALCON_INIT_VAR(c0); ZVAL_LONG(c0, 1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "setfetchmode", c0, PHALCON_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_METHOD_PARAMS_1(r0, result, "fetcharray", result, PHALCON_NO_CHECK); PHALCON_CPY_WRT(row, r0); if (zend_is_true(row)) { PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, "_model", sizeof("_model")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_STATIC_PARAMS_2(r1, "phalcon_model_base", "dumpresult", t2, row); phalcon_update_property_zval(this_ptr, "_activeRow", strlen("_activeRow"), r1 TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_TRUE; } else { PHALCON_INIT_VAR(c1); ZVAL_LONG(c1, 2); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "setfetchmode", c1, PHALCON_NO_CHECK); } } } else { PHALCON_ALLOC_ZVAL_MM(t3); phalcon_read_property(&t3, this_ptr, "_rows", sizeof("_rows")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(rows, t3); PHALCON_ALLOC_ZVAL_MM(r2); Z_SET_ISREF_P(rows); PHALCON_CALL_FUNC_PARAMS_1(r2, "current", rows, 0x054); Z_UNSET_ISREF_P(rows); PHALCON_CPY_WRT(row, r2); if (zend_is_true(row)) { Z_SET_ISREF_P(rows); PHALCON_CALL_FUNC_PARAMS_1_NORETURN("next", rows, 0x059); Z_UNSET_ISREF_P(rows); phalcon_update_property_zval(this_ptr, "_activeRow", strlen("_activeRow"), row TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_TRUE; } } PHALCON_MM_RESTORE(); RETURN_FALSE; }
/** * Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options * *<code> * echo Phalcon\Tag::select(array( * "robotId", * Robots::find("type = 'mechanical'"), * "using" => array("id", "name") * )); *</code> * * Volt syntax: *<code> * {{ select("robotId", robots, "using": ["id", "name"]) }} *</code> * * @param array $parameters * @param array $data * @return string */ PHP_METHOD(Phalcon_Tag, select){ zval *parameters, *data = NULL, *html; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, ¶meters, &data); if (!data) { PHALCON_INIT_VAR(data); } PHALCON_INIT_VAR(html); PHALCON_CALL_STATIC_PARAMS_2(html, "phalcon\\tag\\select", "selectfield", parameters, data); RETURN_CCTOR(html); }
/** * Appends a LIMIT clause to $sqlQuery argument * * * * @param string $sqlQuery * @param int $number * @return string */ PHP_METHOD(Phalcon_Db_Adapter_Mysql, limit){ zval *sql_query = NULL, *number = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &sql_query, &number) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC_PARAMS_2(r0, "phalcon_db_dialect_mysql", "limit", sql_query, number); RETURN_DZVAL(r0); }
/** * Check whether internal resource has rows to fetch * * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, valid){ zval *type = NULL, *result = NULL, *row = NULL, *model = NULL, *active_row = NULL, *rows = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(type); phalcon_read_property(&type, this_ptr, SL("_type"), PH_NOISY_CC); if (zend_is_true(type)) { PHALCON_INIT_VAR(result); phalcon_read_property(&result, this_ptr, SL("_result"), PH_NOISY_CC); if (Z_TYPE_P(result) != IS_BOOL || (Z_TYPE_P(result) == IS_BOOL && Z_BVAL_P(result))) { PHALCON_INIT_VAR(row); PHALCON_CALL_METHOD_PARAMS_1(row, result, "fetcharray", result, PH_NO_CHECK); if (Z_TYPE_P(row) != IS_BOOL || (Z_TYPE_P(row) == IS_BOOL && Z_BVAL_P(row))) { PHALCON_INIT_VAR(model); phalcon_read_property(&model, this_ptr, SL("_model"), PH_NOISY_CC); PHALCON_INIT_VAR(active_row); PHALCON_CALL_STATIC_PARAMS_2(active_row, "phalcon\\mvc\\model", "dumpresult", model, row); phalcon_update_property_zval(this_ptr, SL("_activeRow"), active_row TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_TRUE; } } } else { PHALCON_INIT_VAR(rows); phalcon_read_property(&rows, this_ptr, SL("_rows"), PH_NOISY_CC); Z_SET_ISREF_P(rows); PHALCON_INIT_VAR(row); PHALCON_CALL_FUNC_PARAMS_1(row, "current", rows); Z_UNSET_ISREF_P(rows); if (zend_is_true(row)) { Z_SET_ISREF_P(rows); PHALCON_CALL_FUNC_PARAMS_1_NORETURN("next", rows); Z_UNSET_ISREF_P(rows); phalcon_update_property_zval(this_ptr, SL("_activeRow"), row TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_TRUE; } } PHALCON_MM_RESTORE(); RETURN_FALSE; }
/** * Drops primary key from a table * * @param string $tableName * @param string $schemaName * @return boolean */ PHP_METHOD(Phalcon_Db_Adapter_Mysql, dropPrimaryKey){ zval *table_name = NULL, *schema_name = NULL, *sql = NULL; zval *r0 = NULL, *r1 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &table_name, &schema_name) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC_PARAMS_2(r0, "phalcon_db_dialect_mysql", "dropprimarykey", table_name, schema_name); PHALCON_CPY_WRT(sql, r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_METHOD_PARAMS_1(r1, this_ptr, "query", sql, PHALCON_NO_CHECK); RETURN_DZVAL(r1); }
/** * Builds a HTML SELECT tag using a Phalcon_Model resultset as options * *<code> * echo Phalcon\Tag::selectStatic(array( * "robotId", * Robots::find("type = 'mechanical'"), * "using" => array("id", "name") * )); *</code> * * @param array $params * @return string */ PHP_METHOD(Phalcon_Tag, select){ zval *parameters, *data = NULL, *html; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", ¶meters, &data) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!data) { PHALCON_INIT_NVAR(data); } PHALCON_INIT_VAR(html); PHALCON_CALL_STATIC_PARAMS_2(html, "phalcon\\tag\\select", "selectfield", parameters, data); RETURN_CCTOR(html); }
/** * Prints the HTML for JS resources * * @param string $collectionName */ PHP_METHOD(Phalcon_Assets_Manager, outputJs){ zval *collection_name = NULL, *collection = NULL, *output; zval *use_implicit_output, *resources, *prefix; zval *resource = NULL, *path = NULL, *local = NULL, *prefixed_path = NULL, *html = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &collection_name) == FAILURE) { RETURN_MM_NULL(); } if (!collection_name) { PHALCON_INIT_VAR(collection_name); } if (PHALCON_IS_EMPTY(collection_name)) { PHALCON_INIT_VAR(collection); PHALCON_CALL_METHOD(collection, this_ptr, "getjs"); } else { PHALCON_INIT_NVAR(collection); PHALCON_CALL_METHOD_PARAMS_1(collection, this_ptr, "get", collection_name); } PHALCON_INIT_VAR(output); PHALCON_OBS_VAR(use_implicit_output); phalcon_read_property_this(&use_implicit_output, this_ptr, SL("_implicitOutput"), PH_NOISY_CC); /** * Get the resources as an array */ PHALCON_INIT_VAR(resources); PHALCON_CALL_METHOD(resources, collection, "getresources"); /** * Get the collection's prefix */ PHALCON_INIT_VAR(prefix); PHALCON_CALL_METHOD(prefix, collection, "getprefix"); if (!phalcon_is_iterable(resources, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_VALUE(resource); PHALCON_INIT_NVAR(path); PHALCON_CALL_METHOD(path, resource, "getpath"); PHALCON_INIT_NVAR(local); PHALCON_CALL_METHOD(local, resource, "getlocal"); if (Z_TYPE_P(prefix) != IS_NULL) { PHALCON_INIT_NVAR(prefixed_path); PHALCON_CONCAT_VV(prefixed_path, prefix, path); } else { PHALCON_CPY_WRT(prefixed_path, path); } /** * Generate the html using Phalcon\Tag */ PHALCON_INIT_NVAR(html); PHALCON_CALL_STATIC_PARAMS_2(html, "phalcon\\tag", "javascriptinclude", prefixed_path, local); if (zend_is_true(use_implicit_output)) { zend_print_zval(html, 0); } else { phalcon_concat_self(&output, html TSRMLS_CC); } zend_hash_move_forward_ex(ah0, &hp0); } RETURN_CCTOR(output); }
/** * 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); }
/** * Generates a SELECT tag * * @param array $parameters * @param array $data */ PHP_METHOD(Phalcon_Tag_Select, selectField){ zval *parameters, *data = NULL, *params = NULL, *eol, *id = NULL, *name, *value = NULL; zval *use_empty = NULL, *empty_value = NULL, *empty_text = NULL, *code; zval *avalue = NULL, *key = NULL, *close_option, *options = NULL, *using; zval *resultset_options, *array_options; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", ¶meters, &data) == FAILURE) { RETURN_MM_NULL(); } if (!data) { PHALCON_INIT_VAR(data); } if (Z_TYPE_P(parameters) != IS_ARRAY) { PHALCON_INIT_VAR(params); array_init_size(params, 2); phalcon_array_append(¶ms, parameters, PH_SEPARATE TSRMLS_CC); phalcon_array_append(¶ms, data, PH_SEPARATE TSRMLS_CC); } else { PHALCON_CPY_WRT(params, parameters); } PHALCON_INIT_VAR(eol); zend_get_constant(SL("PHP_EOL"), eol TSRMLS_CC); if (!phalcon_array_isset_long(params, 0)) { PHALCON_OBS_VAR(id); phalcon_array_fetch_string(&id, params, SL("id"), PH_NOISY_CC); phalcon_array_update_long(¶ms, 0, &id, PH_COPY | PH_SEPARATE TSRMLS_CC); } PHALCON_OBS_NVAR(id); phalcon_array_fetch_long(&id, params, 0, PH_NOISY_CC); if (!phalcon_array_isset_string(params, SS("name"))) { phalcon_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE TSRMLS_CC); } else { PHALCON_OBS_VAR(name); phalcon_array_fetch_string(&name, params, SL("name"), PH_NOISY_CC); if (!zend_is_true(name)) { phalcon_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE TSRMLS_CC); } } if (!phalcon_array_isset_string(params, SS("id"))) { phalcon_array_update_string(¶ms, SL("id"), &id, PH_COPY | PH_SEPARATE TSRMLS_CC); } if (!phalcon_array_isset_string(params, SS("value"))) { PHALCON_INIT_VAR(value); PHALCON_CALL_STATIC_PARAMS_2(value, "phalcon\\tag", "getvalue", id, params); } else { PHALCON_OBS_NVAR(value); phalcon_array_fetch_string(&value, params, SL("value"), PH_NOISY_CC); PHALCON_SEPARATE(params); phalcon_array_unset_string(params, SS("value")); } PHALCON_INIT_VAR(use_empty); ZVAL_BOOL(use_empty, 0); if (phalcon_array_isset_string(params, SS("useEmpty"))) { if (!phalcon_array_isset_string(params, SS("emptyValue"))) { PHALCON_INIT_VAR(empty_value); ZVAL_STRING(empty_value, "", 1); } else { PHALCON_OBS_NVAR(empty_value); phalcon_array_fetch_string(&empty_value, params, SL("emptyValue"), PH_NOISY_CC); PHALCON_SEPARATE(params); phalcon_array_unset_string(params, SS("emptyValue")); } if (!phalcon_array_isset_string(params, SS("emptyText"))) { PHALCON_INIT_VAR(empty_text); ZVAL_STRING(empty_text, "Choose...", 1); } else { PHALCON_OBS_NVAR(empty_text); phalcon_array_fetch_string(&empty_text, params, SL("emptyText"), PH_NOISY_CC); PHALCON_SEPARATE(params); phalcon_array_unset_string(params, SS("emptyText")); } PHALCON_OBS_NVAR(use_empty); phalcon_array_fetch_string(&use_empty, params, SL("useEmpty"), PH_NOISY_CC); PHALCON_SEPARATE(params); phalcon_array_unset_string(params, SS("useEmpty")); } PHALCON_INIT_VAR(code); ZVAL_STRING(code, "<select", 1); if (Z_TYPE_P(params) == IS_ARRAY) { if (!phalcon_is_iterable(params, &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(avalue); if (Z_TYPE_P(key) != IS_LONG) { if (Z_TYPE_P(avalue) != IS_ARRAY) { PHALCON_SCONCAT_SVSVS(code, " ", key, "=\"", avalue, "\""); } } zend_hash_move_forward_ex(ah0, &hp0); } } PHALCON_SCONCAT_SV(code, ">", eol); PHALCON_INIT_VAR(close_option); PHALCON_CONCAT_SV(close_option, "</option>", eol); if (zend_is_true(use_empty)) { /** * Create an empty value */ PHALCON_SCONCAT_SVSVV(code, "\t<option value=\"", empty_value, "\">", empty_text, close_option); PHALCON_SEPARATE(params); phalcon_array_unset_string(params, SS("useEmpty")); } if (phalcon_array_isset_long(params, 1)) { PHALCON_OBS_VAR(options); phalcon_array_fetch_long(&options, params, 1, PH_NOISY_CC); } else { PHALCON_CPY_WRT(options, data); } if (Z_TYPE_P(options) == IS_OBJECT) { /** * The options is a resultset */ if (!phalcon_array_isset_string(params, SS("using"))) { PHALCON_THROW_EXCEPTION_STR(phalcon_tag_exception_ce, "The 'using' parameter is required"); return; } else { PHALCON_OBS_VAR(using); phalcon_array_fetch_string(&using, params, SL("using"), PH_NOISY_CC); if (Z_TYPE_P(using) != IS_ARRAY) { PHALCON_THROW_EXCEPTION_STR(phalcon_tag_exception_ce, "The 'using' parameter should be an Array"); return; } } /** * Create the SELECT's option from a resultset */ PHALCON_INIT_VAR(resultset_options); PHALCON_CALL_SELF_PARAMS_4(resultset_options, this_ptr, "_optionsfromresultset", options, using, value, close_option); phalcon_concat_self(&code, resultset_options TSRMLS_CC); } else { if (Z_TYPE_P(options) == IS_ARRAY) {
/** * Returns a connection builded with the default descriptor parameters * * * * @param boolean $newConnection * @param boolean $renovate * @return Phalcon_Db */ PHP_METHOD(Phalcon_Db_Pool, getConnection){ zval *new_connection = NULL, *renovate = NULL, *database = NULL, *connection = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zz", &new_connection, &renovate) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!new_connection) { PHALCON_INIT_VAR(new_connection); ZVAL_BOOL(new_connection, 0); } if (!renovate) { PHALCON_INIT_VAR(renovate); ZVAL_BOOL(renovate, 0); } PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("Phalcon_Db_Pool"), SL("_defaultDescriptor") TSRMLS_CC); PHALCON_CPY_WRT(database, t0); if (!zend_is_true(database)) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Default database connection parameters was not defined"); return; } eval_int = phalcon_isset_property(database, SL("adapter") TSRMLS_CC); if (!eval_int) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "A valid adapter name is required"); return; } if (zend_is_true(new_connection)) { if (zend_is_true(renovate)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, database, SL("adapter"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_STATIC_PARAMS_2(r0, "phalcon_db", "factory", t1, database); phalcon_update_static_property(SL("Phalcon_Db_Pool"), SL("_connection"), r0 TSRMLS_CC); PHALCON_OBSERVE_VAR(t2); phalcon_read_static_property(&t2, SL("Phalcon_Db_Pool"), SL("_connection") TSRMLS_CC); PHALCON_CPY_WRT(connection, t2); } else { PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_ALLOC_ZVAL_MM(t3); phalcon_read_property(&t3, database, SL("adapter"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_STATIC_PARAMS_2(r1, "phalcon_db", "factory", t3, database); PHALCON_CPY_WRT(connection, r1); } } else { PHALCON_OBSERVE_VAR(t4); phalcon_read_static_property(&t4, SL("Phalcon_Db_Pool"), SL("_connection") TSRMLS_CC); if (!zend_is_true(t4)) { PHALCON_ALLOC_ZVAL_MM(r2); PHALCON_ALLOC_ZVAL_MM(t5); phalcon_read_property(&t5, database, SL("adapter"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_STATIC_PARAMS_2(r2, "phalcon_db", "factory", t5, database); phalcon_update_static_property(SL("Phalcon_Db_Pool"), SL("_connection"), r2 TSRMLS_CC); } PHALCON_OBSERVE_VAR(t6); phalcon_read_static_property(&t6, SL("Phalcon_Db_Pool"), SL("_connection") TSRMLS_CC); PHALCON_CPY_WRT(connection, t6); } RETURN_CHECK_CTOR(connection); }