/** * 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); }
/** * Lists table indexes * * @param string $table * @param string $schema * @return Phalcon\Db\Index[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, describeIndexes){ zval *table = NULL, *schema = NULL, *dialect = NULL, *sql = NULL, *describe = NULL, *indexes = NULL; zval *index = NULL, *key_name = NULL, *column_name = NULL, *index_objects = NULL; zval *index_columns = NULL, *name = NULL; zval *t0 = NULL; zval *a0 = 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_ALLOC_ZVAL_MM(schema); ZVAL_NULL(schema); } PHALCON_INIT_VAR(dialect); phalcon_read_property(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); PHALCON_INIT_VAR(sql); PHALCON_CALL_METHOD_PARAMS_2(sql, dialect, "describeindexes", table, schema, PH_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_get_class_constant(t0, phalcon_db_ce, SL("FETCH_ASSOC") TSRMLS_CC); PHALCON_INIT_VAR(describe); PHALCON_CALL_METHOD_PARAMS_2(describe, this_ptr, "fetchall", sql, t0, PH_NO_CHECK); PHALCON_INIT_VAR(indexes); array_init(indexes); if (!phalcon_valid_foreach(describe TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(describe); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_ecef_1: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_ecef_1; } PHALCON_INIT_VAR(index); ZVAL_ZVAL(index, *hd, 1, 0); PHALCON_INIT_VAR(key_name); phalcon_array_fetch_string(&key_name, index, SL("key_name"), PH_NOISY_CC); eval_int = phalcon_array_isset(indexes, key_name); if (!eval_int) { PHALCON_INIT_VAR(a0); array_init(a0); phalcon_array_update_zval(&indexes, key_name, &a0, PH_COPY | PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_VAR(column_name); phalcon_array_fetch_string(&column_name, index, SL("column_name"), PH_NOISY_CC); phalcon_array_update_multi_append_2(&indexes, key_name, column_name, 0 TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_ecef_1; fee_ecef_1: PHALCON_INIT_VAR(index_objects); array_init(index_objects); if (!phalcon_valid_foreach(indexes TSRMLS_CC)) { return; } ah1 = Z_ARRVAL_P(indexes); zend_hash_internal_pointer_reset_ex(ah1, &hp1); fes_ecef_2: if(zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS){ goto fee_ecef_2; } 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(index); object_init_ex(index, phalcon_db_index_ce); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(index, "__construct", name, index_columns, PH_CHECK); phalcon_array_update_zval(&index_objects, name, &index, PH_COPY | PH_SEPARATE TSRMLS_CC); zend_hash_move_forward_ex(ah1, &hp1); goto fes_ecef_2; fee_ecef_2: RETURN_CTOR(index_objects); }