/** * Executes a find using the parameters built with the criteria */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, execute) { zend_class_entry *_1; zval *model = NULL, *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&model, this_ptr, "getmodelname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(model) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Model name must be string", "phalcon/mvc/model/criteria.zep", 771); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "getparams", NULL, 0); zephir_check_call_status(); _1 = zephir_fetch_class(model TSRMLS_CC); ZEPHIR_RETURN_CALL_CE_STATIC(_1, "find", NULL, 0, _0); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(Phalcon_Validation_Validator_Uniqueness, isUniqueness) { zval *_32$$16 = NULL, *_44$$20 = NULL, *_58$$25 = NULL; zend_bool _11$$7, _18$$12; zend_class_entry *_78; HashTable *_2, *_8, *_24$$13, *_29$$15, *_41$$19, *_50$$22, *_55$$24, *_68$$27; HashPosition _1, _7, _23$$13, _28$$15, _40$$19, _49$$22, _54$$24, _67$$27; zephir_fcall_cache_entry *_5 = NULL, *_12 = NULL, *_14 = NULL; int ZEPHIR_LAST_CALL_STATUS, index = 0; zval *validation, *field = NULL, *value = NULL, *values = NULL, *convert = NULL, *record = NULL, *attribute = NULL, *except = NULL, *params = NULL, *metaData = NULL, *primaryField = NULL, *className = NULL, *singleField = NULL, *fieldExcept = NULL, *singleExcept = NULL, *notInValues = NULL, *exceptConditions = NULL, *_0 = NULL, **_3, **_9, *_63 = NULL, *_76, *_77 = NULL, *_4$$4 = NULL, *_6$$5 = NULL, *_10$$7 = NULL, *_13$$7 = NULL, _15$$10 = zval_used_for_init, *_16$$10 = NULL, *_17$$11 = NULL, *_19$$12, _20$$12, _21$$12, *_22$$12 = NULL, **_25$$13, *_26$$14 = NULL, *_27$$14 = NULL, **_30$$15, *_33$$15 = NULL, *_34$$15 = NULL, _31$$16 = zval_used_for_init, _35$$17 = zval_used_for_init, *_36$$17 = NULL, *_37$$18 = NULL, *_38$$18, *_39$$18, **_42$$19, *_45$$19, *_46$$19, _43$$20 = zval_used_for_init, _47$$21, *_48$$21, **_51$$22, *_52$$23 = NULL, *_53$$23 = NULL, **_56$$24, *_59$$24 = NULL, *_60$$24 = NULL, _57$$25 = zval_used_for_init, _61$$26 = zval_used_for_init, *_62$$26 = NULL, *_64$$27 = NULL, *_65$$27, *_66$$27 = NULL, **_69$$27, *_70$$28 = NULL, _71$$28 = zval_used_for_init, *_72$$28 = NULL, *_73$$28 = NULL, *_74$$29, *_75$$29; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field); ZEPHIR_SEPARATE_PARAM(field); ZEPHIR_INIT_VAR(exceptConditions); array_init(exceptConditions); index = 0; ZEPHIR_INIT_VAR(params); zephir_create_array(params, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_array_update_string(¶ms, SL("conditions"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_0); array_init(_0); zephir_array_update_string(¶ms, SL("bind"), &_0, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(field) != IS_ARRAY) { ZEPHIR_CPY_WRT(singleField, field); ZEPHIR_INIT_NVAR(field); array_init(field); zephir_array_append(&field, singleField, PH_SEPARATE, "phalcon/validation/validator/uniqueness.zep", 156); } ZEPHIR_INIT_VAR(values); array_init(values); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "convert", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&convert, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); zephir_is_iterable(field, &_2, &_1, 0, 0, "phalcon/validation/validator/uniqueness.zep", 166); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(singleField, _3); ZEPHIR_CALL_METHOD(&_4$$4, validation, "getvalue", &_5, 0, singleField); zephir_check_call_status(); zephir_array_update_zval(&values, singleField, &_4$$4, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(convert) != IS_NULL) { ZEPHIR_CALL_ZVAL_FUNCTION(&_6$$5, convert, NULL, 0, values); zephir_check_call_status(); ZEPHIR_CPY_WRT(values, _6$$5); if (!(Z_TYPE_P(values) == IS_ARRAY)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Value conversion must return an array", "phalcon/validation/validator/uniqueness.zep", 170); return; } } zephir_is_iterable(field, &_8, &_7, 0, 0, "phalcon/validation/validator/uniqueness.zep", 200); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HVALUE(singleField, _9); ZEPHIR_INIT_NVAR(fieldExcept); ZVAL_NULL(fieldExcept); ZEPHIR_INIT_NVAR(notInValues); array_init(notInValues); ZEPHIR_INIT_NVAR(_10$$7); ZVAL_STRING(_10$$7, "model", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&record, this_ptr, "getoption", NULL, 0, _10$$7); zephir_check_temp_parameter(_10$$7); zephir_check_call_status(); ZEPHIR_OBS_NVAR(value); zephir_array_fetch(&value, values, singleField, PH_NOISY, "phalcon/validation/validator/uniqueness.zep", 178 TSRMLS_CC); _11$$7 = ZEPHIR_IS_EMPTY(record); if (!(_11$$7)) { _11$$7 = Z_TYPE_P(record) != IS_OBJECT; } if (_11$$7) { ZEPHIR_CALL_METHOD(&record, validation, "getentity", &_12, 0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(record)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Model of record must be set to property \"model\"", "phalcon/validation/validator/uniqueness.zep", 184); return; } } ZEPHIR_INIT_NVAR(_10$$7); ZVAL_STRING(_10$$7, "attribute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_13$$7, this_ptr, "getoption", NULL, 0, _10$$7, singleField); zephir_check_temp_parameter(_10$$7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_14, 0, record, _13$$7); zephir_check_call_status(); if (Z_TYPE_P(value) != IS_NULL) { ZEPHIR_SINIT_NVAR(_15$$10); ZVAL_LONG(&_15$$10, index); ZEPHIR_INIT_LNVAR(_16$$10); ZEPHIR_CONCAT_VSV(_16$$10, attribute, " = ?", &_15$$10); zephir_array_update_multi(¶ms, &_16$$10 TSRMLS_CC, SL("sa"), 3, SL("conditions")); zephir_array_update_multi(¶ms, &value TSRMLS_CC, SL("sa"), 3, SL("bind")); index++; } else { ZEPHIR_INIT_LNVAR(_17$$11); ZEPHIR_CONCAT_VS(_17$$11, attribute, " IS NULL"); zephir_array_update_multi(¶ms, &_17$$11 TSRMLS_CC, SL("sa"), 3, SL("conditions")); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "except", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&except, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(except)) { _18$$12 = Z_TYPE_P(except) == IS_ARRAY; if (_18$$12) { ZEPHIR_INIT_VAR(_19$$12); zephir_array_keys(_19$$12, except TSRMLS_CC); ZEPHIR_SINIT_VAR(_20$$12); ZVAL_LONG(&_20$$12, 0); ZEPHIR_SINIT_VAR(_21$$12); ZVAL_LONG(&_21$$12, (zephir_fast_count_int(except TSRMLS_CC) - 1)); ZEPHIR_CALL_FUNCTION(&_22$$12, "range", NULL, 446, &_20$$12, &_21$$12); zephir_check_call_status(); _18$$12 = !ZEPHIR_IS_IDENTICAL(_19$$12, _22$$12); } if (_18$$12) { zephir_is_iterable(except, &_24$$13, &_23$$13, 0, 0, "phalcon/validation/validator/uniqueness.zep", 219); for ( ; zephir_hash_get_current_data_ex(_24$$13, (void**) &_25$$13, &_23$$13) == SUCCESS ; zephir_hash_move_forward_ex(_24$$13, &_23$$13) ) { ZEPHIR_GET_HMKEY(singleField, _24$$13, _23$$13); ZEPHIR_GET_HVALUE(fieldExcept, _25$$13); ZEPHIR_INIT_NVAR(_27$$14); ZVAL_STRING(_27$$14, "attribute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_26$$14, this_ptr, "getoption", NULL, 0, _27$$14, singleField); zephir_check_temp_parameter(_27$$14); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_14, 0, record, _26$$14); zephir_check_call_status(); if (Z_TYPE_P(fieldExcept) == IS_ARRAY) { zephir_is_iterable(fieldExcept, &_29$$15, &_28$$15, 0, 0, "phalcon/validation/validator/uniqueness.zep", 212); for ( ; zephir_hash_get_current_data_ex(_29$$15, (void**) &_30$$15, &_28$$15) == SUCCESS ; zephir_hash_move_forward_ex(_29$$15, &_28$$15) ) { ZEPHIR_GET_HVALUE(singleExcept, _30$$15); ZEPHIR_SINIT_NVAR(_31$$16); ZVAL_LONG(&_31$$16, index); ZEPHIR_INIT_LNVAR(_32$$16); ZEPHIR_CONCAT_SV(_32$$16, "?", &_31$$16); zephir_array_append(¬InValues, _32$$16, PH_SEPARATE, "phalcon/validation/validator/uniqueness.zep", 208); zephir_array_update_multi(¶ms, &singleExcept TSRMLS_CC, SL("sa"), 3, SL("bind")); index++; } ZEPHIR_INIT_NVAR(_33$$15); zephir_fast_join_str(_33$$15, SL(","), notInValues TSRMLS_CC); ZEPHIR_INIT_LNVAR(_34$$15); ZEPHIR_CONCAT_VSVS(_34$$15, attribute, " NOT IN (", _33$$15, ")"); zephir_array_append(&exceptConditions, _34$$15, PH_SEPARATE, "phalcon/validation/validator/uniqueness.zep", 212); } else { ZEPHIR_SINIT_NVAR(_35$$17); ZVAL_LONG(&_35$$17, index); ZEPHIR_INIT_LNVAR(_36$$17); ZEPHIR_CONCAT_VSV(_36$$17, attribute, " <> ?", &_35$$17); zephir_array_append(&exceptConditions, _36$$17, PH_SEPARATE, "phalcon/validation/validator/uniqueness.zep", 214); zephir_array_update_multi(¶ms, &fieldExcept TSRMLS_CC, SL("sa"), 3, SL("bind")); index++; } } } else if (zephir_fast_count_int(field TSRMLS_CC) == 1) { zephir_array_fetch_long(&_38$$18, field, 0, PH_NOISY | PH_READONLY, "phalcon/validation/validator/uniqueness.zep", 220 TSRMLS_CC); ZEPHIR_INIT_VAR(_39$$18); ZVAL_STRING(_39$$18, "attribute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_37$$18, this_ptr, "getoption", NULL, 0, _39$$18, _38$$18); zephir_check_temp_parameter(_39$$18); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_14, 0, record, _37$$18); zephir_check_call_status(); if (Z_TYPE_P(except) == IS_ARRAY) { zephir_is_iterable(except, &_41$$19, &_40$$19, 0, 0, "phalcon/validation/validator/uniqueness.zep", 227); for ( ; zephir_hash_get_current_data_ex(_41$$19, (void**) &_42$$19, &_40$$19) == SUCCESS ; zephir_hash_move_forward_ex(_41$$19, &_40$$19) ) { ZEPHIR_GET_HVALUE(singleExcept, _42$$19); ZEPHIR_SINIT_NVAR(_43$$20); ZVAL_LONG(&_43$$20, index); ZEPHIR_INIT_LNVAR(_44$$20); ZEPHIR_CONCAT_SV(_44$$20, "?", &_43$$20); zephir_array_append(¬InValues, _44$$20, PH_SEPARATE, "phalcon/validation/validator/uniqueness.zep", 223); zephir_array_update_multi(¶ms, &singleExcept TSRMLS_CC, SL("sa"), 3, SL("bind")); index++; } ZEPHIR_INIT_VAR(_45$$19); zephir_fast_join_str(_45$$19, SL(","), notInValues TSRMLS_CC); ZEPHIR_INIT_VAR(_46$$19); ZEPHIR_CONCAT_VSVS(_46$$19, attribute, " NOT IN (", _45$$19, ")"); zephir_array_append(&exceptConditions, _46$$19, PH_SEPARATE, "phalcon/validation/validator/uniqueness.zep", 227); } else { ZEPHIR_SINIT_VAR(_47$$21); ZVAL_LONG(&_47$$21, index); ZEPHIR_INIT_VAR(_48$$21); ZEPHIR_CONCAT_VSV(_48$$21, attribute, " <> ?", &_47$$21); zephir_array_update_multi(¶ms, &_48$$21 TSRMLS_CC, SL("sa"), 3, SL("conditions")); zephir_array_update_multi(¶ms, &except TSRMLS_CC, SL("sa"), 3, SL("bind")); index++; } } else if (zephir_fast_count_int(field TSRMLS_CC) > 1) { zephir_is_iterable(field, &_50$$22, &_49$$22, 0, 0, "phalcon/validation/validator/uniqueness.zep", 249); for ( ; zephir_hash_get_current_data_ex(_50$$22, (void**) &_51$$22, &_49$$22) == SUCCESS ; zephir_hash_move_forward_ex(_50$$22, &_49$$22) ) { ZEPHIR_GET_HVALUE(singleField, _51$$22); ZEPHIR_INIT_NVAR(_53$$23); ZVAL_STRING(_53$$23, "attribute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_52$$23, this_ptr, "getoption", NULL, 0, _53$$23, singleField); zephir_check_temp_parameter(_53$$23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_14, 0, record, _52$$23); zephir_check_call_status(); if (Z_TYPE_P(except) == IS_ARRAY) { zephir_is_iterable(except, &_55$$24, &_54$$24, 0, 0, "phalcon/validation/validator/uniqueness.zep", 242); for ( ; zephir_hash_get_current_data_ex(_55$$24, (void**) &_56$$24, &_54$$24) == SUCCESS ; zephir_hash_move_forward_ex(_55$$24, &_54$$24) ) { ZEPHIR_GET_HVALUE(singleExcept, _56$$24); ZEPHIR_SINIT_NVAR(_57$$25); ZVAL_LONG(&_57$$25, index); ZEPHIR_INIT_LNVAR(_58$$25); ZEPHIR_CONCAT_SV(_58$$25, "?", &_57$$25); zephir_array_append(¬InValues, _58$$25, PH_SEPARATE, "phalcon/validation/validator/uniqueness.zep", 238); zephir_array_update_multi(¶ms, &singleExcept TSRMLS_CC, SL("sa"), 3, SL("bind")); index++; } ZEPHIR_INIT_NVAR(_59$$24); zephir_fast_join_str(_59$$24, SL(","), notInValues TSRMLS_CC); ZEPHIR_INIT_LNVAR(_60$$24); ZEPHIR_CONCAT_VSVS(_60$$24, attribute, " NOT IN (", _59$$24, ")"); zephir_array_append(&exceptConditions, _60$$24, PH_SEPARATE, "phalcon/validation/validator/uniqueness.zep", 242); } else { ZEPHIR_SINIT_NVAR(_61$$26); ZVAL_LONG(&_61$$26, index); ZEPHIR_INIT_LNVAR(_62$$26); ZEPHIR_CONCAT_VSV(_62$$26, attribute, " <> ?", &_61$$26); zephir_array_update_multi(¶ms, &_62$$26 TSRMLS_CC, SL("sa"), 3, SL("conditions")); zephir_array_update_multi(¶ms, &except TSRMLS_CC, SL("sa"), 3, SL("bind")); index++; } } } } ZEPHIR_CALL_METHOD(&_63, record, "getdirtystate", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_63, 0)) { ZEPHIR_CALL_METHOD(&_64$$27, record, "getdi", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_65$$27); ZVAL_STRING(_65$$27, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&metaData, _64$$27, "getshared", NULL, 0, _65$$27); zephir_check_temp_parameter(_65$$27); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_66$$27, metaData, "getprimarykeyattributes", NULL, 0, record); zephir_check_call_status(); zephir_is_iterable(_66$$27, &_68$$27, &_67$$27, 0, 0, "phalcon/validation/validator/uniqueness.zep", 263); for ( ; zephir_hash_get_current_data_ex(_68$$27, (void**) &_69$$27, &_67$$27) == SUCCESS ; zephir_hash_move_forward_ex(_68$$27, &_67$$27) ) { ZEPHIR_GET_HVALUE(primaryField, _69$$27); ZEPHIR_CALL_METHOD(&_70$$28, this_ptr, "getcolumnnamereal", &_14, 0, record, primaryField); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_71$$28); ZVAL_LONG(&_71$$28, index); ZEPHIR_INIT_LNVAR(_72$$28); ZEPHIR_CONCAT_VSV(_72$$28, _70$$28, " <> ?", &_71$$28); zephir_array_update_multi(¶ms, &_72$$28 TSRMLS_CC, SL("sa"), 3, SL("conditions")); ZEPHIR_CALL_METHOD(&_73$$28, record, "readattribute", NULL, 0, primaryField); zephir_check_call_status(); zephir_array_update_multi(¶ms, &_73$$28 TSRMLS_CC, SL("sa"), 3, SL("bind")); index++; } } ZEPHIR_INIT_VAR(className); zephir_get_class(className, record, 0 TSRMLS_CC); if (!(ZEPHIR_IS_EMPTY(exceptConditions))) { ZEPHIR_INIT_VAR(_74$$29); zephir_fast_join_str(_74$$29, SL(" OR "), exceptConditions TSRMLS_CC); ZEPHIR_INIT_VAR(_75$$29); ZEPHIR_CONCAT_SVS(_75$$29, "(", _74$$29, ")"); zephir_array_update_multi(¶ms, &_75$$29 TSRMLS_CC, SL("sa"), 3, SL("conditions")); } ZEPHIR_INIT_NVAR(_0); zephir_array_fetch_string(&_76, params, SL("conditions"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/uniqueness.zep", 269 TSRMLS_CC); zephir_fast_join_str(_0, SL(" AND "), _76 TSRMLS_CC); zephir_array_update_string(¶ms, SL("conditions"), &_0, PH_COPY | PH_SEPARATE); _78 = zephir_fetch_class(className TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&_77, _78, "count", NULL, 0, params); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_LONG(_77, 0)); }
/** * Executes the validator */ PHP_METHOD(Phalcon_Mvc_Model_Validator_Uniqueness, validate) { HashTable *_2$$5, *_22$$16; HashPosition _1$$5, _21$$16; zend_class_entry *_33; zephir_fcall_cache_entry *_6 = NULL, *_12 = NULL, *_31 = NULL; int ZEPHIR_LAST_CALL_STATUS, number = 0; zval *record, *field = NULL, *dependencyInjector = NULL, *metaData = NULL, *message = NULL, *bindTypes = NULL, *bindDataTypes = NULL, *columnMap = NULL, *conditions = NULL, *bindParams = NULL, *composeField = NULL, *columnField = NULL, *bindType = NULL, *primaryField = NULL, *attributeField = NULL, *params = NULL, *className = NULL, *replacePairs = NULL, *_0 = NULL, *_19 = NULL, *_32 = NULL, **_3$$5, *_4$$8 = NULL, *_5$$8 = NULL, *_7$$10 = NULL, *_8$$10 = NULL, _9$$6 = zval_used_for_init, *_10$$6 = NULL, *_11$$6 = NULL, *_13$$13, *_14$$13, *_15$$15, *_16$$15, *_17$$11, *_18$$11 = NULL, *_20$$16 = NULL, **_23$$16, *_24$$20 = NULL, *_25$$20 = NULL, *_26$$22 = NULL, *_27$$22 = NULL, _28$$19 = zval_used_for_init, *_29$$19 = NULL, *_30$$19 = NULL, *_34$$24 = NULL, *_36$$24 = NULL, *_35$$25; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_CALL_METHOD(&dependencyInjector, record, "getdi", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&metaData, dependencyInjector, "getshared", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(bindTypes); array_init(bindTypes); ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, record); zephir_check_call_status(); if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getreversecolumnmap", NULL, 0, record); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } ZEPHIR_INIT_VAR(conditions); array_init(conditions); ZEPHIR_INIT_VAR(bindParams); array_init(bindParams); number = 0; ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) == IS_ARRAY) { zephir_is_iterable(field, &_2$$5, &_1$$5, 0, 0, "phalcon/mvc/model/validator/uniqueness.zep", 127); for ( ; zephir_hash_get_current_data_ex(_2$$5, (void**) &_3$$5, &_1$$5) == SUCCESS ; zephir_hash_move_forward_ex(_2$$5, &_1$$5) ) { ZEPHIR_GET_HVALUE(composeField, _3$$5); if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(columnField); if (!(zephir_array_isset_fetch(&columnField, columnMap, composeField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_4$$8); object_init_ex(_4$$8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_5$$8); ZEPHIR_CONCAT_SVS(_5$$8, "Column '", composeField, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _4$$8, "__construct", &_6, 9, _5$$8); zephir_check_call_status(); zephir_throw_exception_debug(_4$$8, "phalcon/mvc/model/validator/uniqueness.zep", 104 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(columnField, composeField); } ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, columnField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_7$$10); object_init_ex(_7$$10, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_8$$10); ZEPHIR_CONCAT_SVS(_8$$10, "Column '", columnField, "' isn't part of the table columns"); ZEPHIR_CALL_METHOD(NULL, _7$$10, "__construct", &_6, 9, _8$$10); zephir_check_call_status(); zephir_throw_exception_debug(_7$$10, "phalcon/mvc/model/validator/uniqueness.zep", 114 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_SINIT_NVAR(_9$$6); ZVAL_LONG(&_9$$6, number); ZEPHIR_INIT_LNVAR(_10$$6); ZEPHIR_CONCAT_SVSV(_10$$6, "[", composeField, "] = ?", &_9$$6); zephir_array_append(&conditions, _10$$6, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 120); ZEPHIR_CALL_METHOD(&_11$$6, record, "readattribute", &_12, 0, composeField); zephir_check_call_status(); zephir_array_append(&bindParams, _11$$6, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 121); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 122); number++; } } else { if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(columnField); if (!(zephir_array_isset_fetch(&columnField, columnMap, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_13$$13); object_init_ex(_13$$13, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_14$$13); ZEPHIR_CONCAT_SVS(_14$$13, "Column '", field, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _13$$13, "__construct", &_6, 9, _14$$13); zephir_check_call_status(); zephir_throw_exception_debug(_13$$13, "phalcon/mvc/model/validator/uniqueness.zep", 134 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(columnField, field); } ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, columnField, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_15$$15); object_init_ex(_15$$15, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_16$$15); ZEPHIR_CONCAT_SVS(_16$$15, "Column '", columnField, "' isn't part of the table columns"); ZEPHIR_CALL_METHOD(NULL, _15$$15, "__construct", &_6, 9, _16$$15); zephir_check_call_status(); zephir_throw_exception_debug(_15$$15, "phalcon/mvc/model/validator/uniqueness.zep", 144 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(_17$$11); ZEPHIR_CONCAT_SVS(_17$$11, "[", field, "] = ?0"); zephir_array_append(&conditions, _17$$11, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 150); ZEPHIR_CALL_METHOD(&_18$$11, record, "readattribute", NULL, 0, field); zephir_check_call_status(); zephir_array_append(&bindParams, _18$$11, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 151); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 152); number++; } ZEPHIR_CALL_METHOD(&_19, record, "getoperationmade", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_19, 2)) { if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, record); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } ZEPHIR_CALL_METHOD(&_20$$16, metaData, "getprimarykeyattributes", NULL, 0, record); zephir_check_call_status(); zephir_is_iterable(_20$$16, &_22$$16, &_21$$16, 0, 0, "phalcon/mvc/model/validator/uniqueness.zep", 197); for ( ; zephir_hash_get_current_data_ex(_22$$16, (void**) &_23$$16, &_21$$16) == SUCCESS ; zephir_hash_move_forward_ex(_22$$16, &_21$$16) ) { ZEPHIR_GET_HVALUE(primaryField, _23$$16); ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, primaryField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_24$$20); object_init_ex(_24$$20, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_25$$20); ZEPHIR_CONCAT_SVS(_25$$20, "Column '", primaryField, "' isn't part of the table columns"); ZEPHIR_CALL_METHOD(NULL, _24$$20, "__construct", &_6, 9, _25$$20); zephir_check_call_status(); zephir_throw_exception_debug(_24$$20, "phalcon/mvc/model/validator/uniqueness.zep", 174 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, primaryField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_26$$22); object_init_ex(_26$$22, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_27$$22); ZEPHIR_CONCAT_SVS(_27$$22, "Column '", primaryField, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _26$$22, "__construct", &_6, 9, _27$$22); zephir_check_call_status(); zephir_throw_exception_debug(_26$$22, "phalcon/mvc/model/validator/uniqueness.zep", 182 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, primaryField); } ZEPHIR_SINIT_NVAR(_28$$19); ZVAL_LONG(&_28$$19, number); ZEPHIR_INIT_LNVAR(_29$$19); ZEPHIR_CONCAT_SVSV(_29$$19, "[", attributeField, "] <> ?", &_28$$19); zephir_array_append(&conditions, _29$$19, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 191); ZEPHIR_CALL_METHOD(&_30$$19, record, "readattribute", &_31, 0, primaryField); zephir_check_call_status(); zephir_array_append(&bindParams, _30$$19, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 192); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 193); number++; } } ZEPHIR_INIT_VAR(params); array_init(params); zephir_array_update_string(¶ms, SL("di"), &dependencyInjector, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_0); zephir_fast_join_str(_0, SL(" AND "), conditions TSRMLS_CC); zephir_array_update_string(¶ms, SL("conditions"), &_0, PH_COPY | PH_SEPARATE); zephir_array_update_string(¶ms, SL("bind"), &bindParams, PH_COPY | PH_SEPARATE); zephir_array_update_string(¶ms, SL("bindTypes"), &bindTypes, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(className); zephir_get_class(className, record, 0 TSRMLS_CC); _33 = zephir_fetch_class(className TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&_32, _33, "count", NULL, 0, params); zephir_check_call_status(); if (!ZEPHIR_IS_LONG(_32, 0)) { ZEPHIR_INIT_VAR(_34$$24); ZVAL_STRING(_34$$24, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _34$$24); zephir_check_temp_parameter(_34$$24); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); if (Z_TYPE_P(field) == IS_ARRAY) { zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_35$$25); zephir_fast_join_str(_35$$25, SL(", "), field TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":fields"), &_35$$25, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of fields: :fields are already present in another record", 1); } } else { zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &field, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field: ':field' is already present in another record", 1); } } ZEPHIR_CALL_FUNCTION(&_36$$24, "strtr", NULL, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_34$$24); ZVAL_STRING(_34$$24, "Unique", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _36$$24, field, _34$$24); zephir_check_temp_parameter(_34$$24); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Get modified params for handler using reflection */ PHP_METHOD(Phalcon_Mvc_Model_Binder, getParamsFromReflection) { zend_class_entry *_8$$10, *_9$$14, *_13$$16, *_14$$18; HashTable *_2; HashPosition _1; zephir_fcall_cache_entry *_7 = NULL, *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *cacheKey = NULL; zval *params = NULL; zval *handler, *params_param = NULL, *cacheKey_param = NULL, *methodName, *methodParams = NULL, *reflection = NULL, *paramKey = NULL, *methodParam = NULL, *paramsCache = NULL, *className = NULL, *realClasses = NULL, *boundModel = NULL, *cache = NULL, *handlerClass = NULL, *reflectionClass = NULL, *paramsKeys = NULL, *paramValue = NULL, *_0, **_3, *_4$$7, _5$$5 = zval_used_for_init, *_6$$5 = NULL, *_10$$15 = NULL, *_11$$15 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &handler, ¶ms_param, &cacheKey_param, &methodName); zephir_get_arrval(params, params_param); zephir_get_strval(cacheKey, cacheKey_param); ZEPHIR_INIT_VAR(realClasses); ZVAL_NULL(realClasses); ZEPHIR_INIT_VAR(paramsCache); array_init(paramsCache); ZEPHIR_INIT_VAR(reflection); if (Z_TYPE_P(methodName) != IS_NULL) { object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionmethod") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 324, handler, methodName); zephir_check_call_status(); } else { object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionfunction") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 82, handler); zephir_check_call_status(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC); ZEPHIR_CPY_WRT(cache, _0); ZEPHIR_CALL_METHOD(&methodParams, reflection, "getparameters", NULL, 83); zephir_check_call_status(); ZEPHIR_INIT_VAR(paramsKeys); zephir_array_keys(paramsKeys, params TSRMLS_CC); zephir_is_iterable(methodParams, &_2, &_1, 0, 0, "phalcon/mvc/model/binder.zep", 197); for ( ; zend_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zend_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(paramKey, _2, _1); ZEPHIR_GET_HVALUE(methodParam, _3); ZEPHIR_CALL_METHOD(&reflectionClass, methodParam, "getclass", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(reflectionClass))) { continue; } ZEPHIR_CALL_METHOD(&className, reflectionClass, "getname", NULL, 0); zephir_check_call_status(); if (!(zephir_array_isset(params, paramKey))) { zephir_array_fetch(&_4$$7, paramsKeys, paramKey, PH_NOISY | PH_READONLY, "phalcon/mvc/model/binder.zep", 157 TSRMLS_CC); ZEPHIR_CPY_WRT(paramKey, _4$$7); } ZEPHIR_INIT_NVAR(boundModel); ZVAL_NULL(boundModel); ZEPHIR_OBS_NVAR(paramValue); zephir_array_fetch(¶mValue, params, paramKey, PH_NOISY, "phalcon/mvc/model/binder.zep", 160 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_5$$5); ZVAL_STRING(&_5$$5, "Phalcon\\Mvc\\Model", 0); ZEPHIR_CALL_FUNCTION(&_6$$5, "is_subclass_of", &_7, 325, className, &_5$$5); zephir_check_call_status(); if (ZEPHIR_IS_STRING(className, "Phalcon\\Mvc\\Model")) { if (Z_TYPE_P(realClasses) == IS_NULL) { if (zephir_instance_of_ev(handler, phalcon_mvc_controller_bindmodelinterface_ce TSRMLS_CC)) { ZEPHIR_INIT_NVAR(handlerClass); zephir_get_class(handlerClass, handler, 0 TSRMLS_CC); _8$$10 = zephir_fetch_class(handlerClass TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&realClasses, _8$$10, "getmodelname", NULL, 0); zephir_check_call_status(); } else if (zephir_instance_of_ev(handler, phalcon_mvc_model_binder_bindableinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&realClasses, handler, "getmodelname", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Handler must implement Phalcon\\Mvc\\Model\\Binder\\BindableInterface in order to use Phalcon\\Mvc\\Model as parameter", "phalcon/mvc/model/binder.zep", 170); return; } } if (Z_TYPE_P(realClasses) == IS_ARRAY) { ZEPHIR_OBS_NVAR(className); if (zephir_array_isset_fetch(&className, realClasses, paramKey, 0 TSRMLS_CC)) { _9$$14 = zephir_fetch_class(className TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&boundModel, _9$$14, "findfirst", NULL, 0, paramValue); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_10$$15); object_init_ex(_10$$15, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_11$$15); ZEPHIR_CONCAT_SVS(_11$$15, "You should provide model class name for ", paramKey, " parameter"); ZEPHIR_CALL_METHOD(NULL, _10$$15, "__construct", &_12, 9, _11$$15); zephir_check_call_status(); zephir_throw_exception_debug(_10$$15, "phalcon/mvc/model/binder.zep", 177 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else if (Z_TYPE_P(realClasses) == IS_STRING) { _13$$16 = zephir_fetch_class(realClasses TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&boundModel, _13$$16, "findfirst", NULL, 0, paramValue); zephir_check_call_status(); ZEPHIR_CPY_WRT(className, realClasses); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "getModelName should return array or string", "phalcon/mvc/model/binder.zep", 183); return; } } else if (zephir_is_true(_6$$5)) { _14$$18 = zephir_fetch_class(className TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&boundModel, _14$$18, "findfirst", NULL, 0, paramValue); zephir_check_call_status(); } if (Z_TYPE_P(boundModel) != IS_NULL) { zephir_update_property_array(this_ptr, SL("originalValues"), paramKey, paramValue TSRMLS_CC); zephir_array_update_zval(¶ms, paramKey, &boundModel, PH_COPY | PH_SEPARATE); zephir_update_property_array(this_ptr, SL("boundModels"), paramKey, boundModel TSRMLS_CC); zephir_array_update_zval(¶msCache, paramKey, &className, PH_COPY | PH_SEPARATE); } } if (Z_TYPE_P(cache) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, cache, "save", NULL, 0, cacheKey, paramsCache); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("internalCache"), cacheKey, paramsCache TSRMLS_CC); RETURN_CTOR(params); }
/** * Bind models into params in proper handler */ PHP_METHOD(Phalcon_Mvc_Model_Binder, bindToHandler) { zend_class_entry *_6$$5; HashTable *_4$$4; HashPosition _3$$4; zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zval *cacheKey = NULL; zval *params = NULL; zval *handler, *params_param = NULL, *cacheKey_param = NULL, *methodName = NULL, *paramKey = NULL, *className = NULL, *boundModel = NULL, *paramsCache = NULL, *paramValue = NULL, *_0, *_2$$3, **_5$$4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &handler, ¶ms_param, &cacheKey_param, &methodName); zephir_get_arrval(params, params_param); zephir_get_strval(cacheKey, cacheKey_param); if (!methodName) { methodName = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("originalValues"), _0 TSRMLS_CC); _1 = zephir_instance_of_ev(handler, zend_ce_closure TSRMLS_CC); if (!(_1)) { _1 = Z_TYPE_P(methodName) != IS_NULL; } if (_1) { ZEPHIR_INIT_VAR(_2$$3); array_init(_2$$3); zephir_update_property_this(this_ptr, SL("boundModels"), _2$$3 TSRMLS_CC); ZEPHIR_CALL_METHOD(¶msCache, this_ptr, "getparamsfromcache", NULL, 0, cacheKey); zephir_check_call_status(); if (Z_TYPE_P(paramsCache) == IS_ARRAY) { zephir_is_iterable(paramsCache, &_4$$4, &_3$$4, 0, 0, "phalcon/mvc/model/binder.zep", 102); for ( ; zend_hash_get_current_data_ex(_4$$4, (void**) &_5$$4, &_3$$4) == SUCCESS ; zend_hash_move_forward_ex(_4$$4, &_3$$4) ) { ZEPHIR_GET_HMKEY(paramKey, _4$$4, _3$$4); ZEPHIR_GET_HVALUE(className, _5$$4); ZEPHIR_OBS_NVAR(paramValue); zephir_array_fetch(¶mValue, params, paramKey, PH_NOISY, "phalcon/mvc/model/binder.zep", 95 TSRMLS_CC); _6$$5 = zephir_fetch_class(className TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&boundModel, _6$$5, "findfirst", NULL, 0, paramValue); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("originalValues"), paramKey, paramValue TSRMLS_CC); zephir_array_update_zval(¶ms, paramKey, &boundModel, PH_COPY | PH_SEPARATE); zephir_update_property_array(this_ptr, SL("boundModels"), paramKey, boundModel TSRMLS_CC); } RETURN_CTOR(params); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparamsfromreflection", NULL, 0, handler, params, cacheKey, methodName); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "You must specify methodName for handler or pass Closure as handler", "phalcon/mvc/model/binder.zep", 107); return; }
/** * Returns current row in the resultset */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, current) { zephir_fcall_cache_entry *_13 = NULL, *_15 = NULL; zend_class_entry *_12; HashTable *_3, *_6; HashPosition _2, _5; int dirtyState, ZEPHIR_LAST_CALL_STATUS; zval *row, *hydrateMode, *eager, *alias = NULL, *activeRow = NULL, *type = NULL, *column = NULL, *columnValue = NULL, *value = NULL, *attribute = NULL, *source = NULL, *attributes = NULL, *columnMap = NULL, *rowModel = NULL, *keepSnapshots = NULL, *sqlAlias = NULL, *modelName = NULL, *_0, *_1, **_4, **_7, *_8 = NULL, *_9 = NULL, *_10, *_11 = NULL, *_14, _16 = zval_used_for_init, _17 = zval_used_for_init; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(activeRow); zephir_read_property_this(&activeRow, this_ptr, SL("_activeRow"), PH_NOISY_CC); if (Z_TYPE_P(activeRow) != IS_NULL) { RETURN_CCTOR(activeRow); } ZEPHIR_OBS_VAR(row); zephir_read_property_this(&row, this_ptr, SL("_row"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_disableHydration"), PH_NOISY_CC); if (zephir_is_true(_0)) { zephir_update_property_this(this_ptr, SL("_activeRow"), row TSRMLS_CC); RETURN_CCTOR(row); } if (Z_TYPE_P(row) != IS_ARRAY) { if (0) { zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(hydrateMode); zephir_read_property_this(&hydrateMode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC); do { if (ZEPHIR_IS_LONG(hydrateMode, 0)) { ZEPHIR_INIT_NVAR(activeRow); object_init_ex(activeRow, phalcon_mvc_model_row_ce); if (zephir_has_constructor(activeRow TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, activeRow, "__construct", NULL, 0); zephir_check_call_status(); } break; } if (ZEPHIR_IS_LONG(hydrateMode, 1)) { ZEPHIR_INIT_NVAR(activeRow); array_init(activeRow); break; } ZEPHIR_INIT_NVAR(activeRow); object_init(activeRow); break; } while(0); dirtyState = 0; _1 = zephir_fetch_nproperty_this(this_ptr, SL("_columnTypes"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 0, "phalcon/mvc/model/resultset/complex.zep", 246); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(alias, _3, _2); ZEPHIR_GET_HVALUE(column, _4); if (Z_TYPE_P(column) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Column type is corrupt", "phalcon/mvc/model/resultset/complex.zep", 133); return; } ZEPHIR_OBS_NVAR(type); zephir_array_fetch_string(&type, column, SL("type"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 136 TSRMLS_CC); if (ZEPHIR_IS_STRING(type, "object")) { ZEPHIR_OBS_NVAR(source); zephir_array_fetch_string(&source, column, SL("column"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 142 TSRMLS_CC); ZEPHIR_OBS_NVAR(attributes); zephir_array_fetch_string(&attributes, column, SL("attributes"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 143 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnMap); zephir_array_fetch_string(&columnMap, column, SL("columnMap"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 144 TSRMLS_CC); ZEPHIR_INIT_NVAR(rowModel); array_init(rowModel); zephir_is_iterable(attributes, &_6, &_5, 0, 0, "phalcon/mvc/model/resultset/complex.zep", 162); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(attribute, _7); ZEPHIR_OBS_NVAR(columnValue); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSV(_8, "_", source, "_", attribute); zephir_array_fetch(&columnValue, row, _8, PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 155 TSRMLS_CC); zephir_array_update_zval(&rowModel, attribute, &columnValue, PH_COPY | PH_SEPARATE); } do { if (ZEPHIR_IS_LONG(hydrateMode, 0)) { ZEPHIR_OBS_NVAR(keepSnapshots); if (!(zephir_array_isset_string_fetch(&keepSnapshots, column, SS("keepSnapshots"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(keepSnapshots); ZVAL_BOOL(keepSnapshots, 0); } if (ZEPHIR_GLOBAL(orm).late_state_binding) { ZEPHIR_OBS_NVAR(_9); zephir_array_fetch_string(&_9, column, SL("instance"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 173 TSRMLS_CC); if (zephir_instance_of_ev(_9, phalcon_mvc_model_ce TSRMLS_CC)) { zephir_array_fetch_string(&_10, column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 174 TSRMLS_CC); ZEPHIR_INIT_NVAR(modelName); zephir_get_class(modelName, _10, 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(modelName); ZVAL_STRING(modelName, "Phalcon\\Mvc\\Model", 1); } zephir_array_fetch_string(&_10, column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 180 TSRMLS_CC); ZEPHIR_INIT_NVAR(_11); ZVAL_LONG(_11, dirtyState); _12 = zephir_fetch_class(modelName TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&value, _12, "cloneresultmap", NULL, 0, _10, rowModel, columnMap, _11, keepSnapshots); zephir_check_call_status(); } else { zephir_array_fetch_string(&_14, column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 188 TSRMLS_CC); ZEPHIR_INIT_NVAR(_11); ZVAL_LONG(_11, dirtyState); ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmap", &_13, 0, _14, rowModel, columnMap, _11, keepSnapshots); zephir_check_call_status(); } break; } ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_15, 0, rowModel, columnMap, hydrateMode); zephir_check_call_status(); break; } while(0); ZEPHIR_OBS_NVAR(attribute); zephir_array_fetch_string(&attribute, column, SL("balias"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 202 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(sqlAlias); if (zephir_array_isset_string_fetch(&sqlAlias, column, SS("sqlAlias"), 0 TSRMLS_CC)) { ZEPHIR_OBS_NVAR(value); zephir_array_fetch(&value, row, sqlAlias, PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 210 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(value); zephir_array_isset_fetch(&value, row, alias, 0 TSRMLS_CC); } if (zephir_array_isset_string(column, SS("balias"))) { ZEPHIR_CPY_WRT(attribute, alias); } else { ZEPHIR_SINIT_NVAR(_16); ZVAL_STRING(&_16, "_", 0); ZEPHIR_SINIT_NVAR(_17); ZVAL_STRING(&_17, "", 0); ZEPHIR_INIT_NVAR(attribute); zephir_fast_str_replace(&attribute, &_16, &_17, alias TSRMLS_CC); } } if (!(zephir_array_isset_string_fetch(&eager, column, SS("eager"), 1 TSRMLS_CC))) { do { if (ZEPHIR_IS_LONG(hydrateMode, 1)) { zephir_array_update_zval(&activeRow, attribute, &value, PH_COPY | PH_SEPARATE); break; } zephir_update_property_zval_zval(activeRow, attribute, value TSRMLS_CC); break; } while(0); } } zephir_update_property_this(this_ptr, SL("_activeRow"), activeRow TSRMLS_CC); RETURN_CCTOR(activeRow); }
/** * Returns current row in the resultset */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, current) { zend_class_entry *_5$$6; zval *row = NULL, *hydrateMode = NULL, *columnMap = NULL, *activeRow = NULL, *modelName = NULL, *_0$$6, *_2$$6, *_3$$6, *_4$$6, *_1$$7, *_7$$9, *_8$$9, *_9$$9; zephir_fcall_cache_entry *_6 = NULL, *_10 = NULL; int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(activeRow); zephir_read_property_this(&activeRow, this_ptr, SL("_activeRow"), PH_NOISY_CC); if (Z_TYPE_P(activeRow) != IS_NULL) { RETURN_CCTOR(activeRow); } ZEPHIR_OBS_VAR(row); zephir_read_property_this(&row, this_ptr, SL("_row"), PH_NOISY_CC); if (Z_TYPE_P(row) != IS_ARRAY) { if (0) { zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(hydrateMode); zephir_read_property_this(&hydrateMode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC); ZEPHIR_OBS_VAR(columnMap); zephir_read_property_this(&columnMap, this_ptr, SL("_columnMap"), PH_NOISY_CC); do { if (ZEPHIR_IS_LONG(hydrateMode, 0)) { if (ZEPHIR_GLOBAL(orm).late_state_binding) { ZEPHIR_OBS_VAR(_0$$6); zephir_read_property_this(&_0$$6, this_ptr, SL("_model"), PH_NOISY_CC); if (zephir_instance_of_ev(_0$$6, phalcon_mvc_model_ce TSRMLS_CC)) { _1$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); ZEPHIR_INIT_VAR(modelName); zephir_get_class(modelName, _1$$7, 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(modelName); ZVAL_STRING(modelName, "Phalcon\\Mvc\\Model", 1); } _2$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); _3$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_4$$6); ZVAL_LONG(_4$$6, 0); _5$$6 = zephir_fetch_class(modelName TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&activeRow, _5$$6, "cloneresultmap", NULL, 0, _2$$6, row, columnMap, _4$$6, _3$$6); zephir_check_call_status(); } else { _7$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); _8$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_9$$9); ZVAL_LONG(_9$$9, 0); ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmap", &_6, 369, _7$$9, row, columnMap, _9$$9, _8$$9); zephir_check_call_status(); } break; } ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_10, 370, row, columnMap, hydrateMode); zephir_check_call_status(); break; } while(0); zephir_update_property_this(this_ptr, SL("_activeRow"), activeRow TSRMLS_CC); RETURN_CCTOR(activeRow); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Uniqueness, validate) { zend_class_entry *_4, *_5; zval *_1 = NULL, *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *attribute = NULL, *value = NULL, *model = NULL, *except = NULL, *number = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_2 = NULL, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "model", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&model, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "attribute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "except", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&except, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(model)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Model must be set", "phalcon/validation/validator/uniqueness.zep", 65); return; } if (ZEPHIR_IS_EMPTY(attribute)) { ZEPHIR_CPY_WRT(attribute, field); } if (zephir_is_true(except)) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VSVS(_2, attribute, " = :value: AND ", attribute, " != :except:"); zephir_array_fast_append(_1, _2); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 2, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL("value"), &value, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_3, SL("except"), &except, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL("bind"), &_3, PH_COPY | PH_SEPARATE); _4 = zephir_fetch_class(model TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&number, _4, "count", NULL, 0, _1); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VS(_2, attribute, " = :value:"); zephir_array_fast_append(_1, _2); ZEPHIR_INIT_NVAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL("value"), &value, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL("bind"), &_3, PH_COPY | PH_SEPARATE); _5 = zephir_fetch_class(model TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&number, _5, "count", NULL, 0, _1); zephir_check_call_status(); } if (zephir_is_true(number)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Uniqueness", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "Uniqueness", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 436, _6, field, _7); zephir_check_temp_parameter(_7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Returns current row in the resultset */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, current) { zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_4; zval *row, *hydrateMode, *columnMap, *activeRow = NULL, *modelName = NULL, *_0, *_1, *_2, *_3 = NULL, *_6; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(activeRow); zephir_read_property_this(&activeRow, this_ptr, SL("_activeRow"), PH_NOISY_CC); if (Z_TYPE_P(activeRow) != IS_NULL) { RETURN_CCTOR(activeRow); } ZEPHIR_OBS_VAR(row); zephir_read_property_this(&row, this_ptr, SL("_row"), PH_NOISY_CC); if (Z_TYPE_P(row) != IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_activeRow"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(hydrateMode); zephir_read_property_this(&hydrateMode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC); ZEPHIR_OBS_VAR(columnMap); zephir_read_property_this(&columnMap, this_ptr, SL("_columnMap"), PH_NOISY_CC); do { if (ZEPHIR_IS_LONG(hydrateMode, 0)) { if (ZEPHIR_GLOBAL(orm).late_state_binding) { ZEPHIR_INIT_VAR(modelName); ZVAL_STRING(modelName, "Phalcon\\Mvc\\Model", 1); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_model"), PH_NOISY_CC); if (zephir_instance_of_ev(_0, phalcon_mvc_model_ce TSRMLS_CC)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(modelName); zephir_get_class(modelName, _1, 0 TSRMLS_CC); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 0); _4 = zephir_fetch_class(modelName TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&activeRow, _4, "cloneresultmap", NULL, 0, _1, row, columnMap, _3, _2); zephir_check_call_status(); } else { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmap", &_5, 345, _2, row, columnMap, _3, _6); zephir_check_call_status(); } break; } ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_7, 346, row, columnMap, hydrateMode); zephir_check_call_status(); break; } while(0); zephir_update_property_this(this_ptr, SL("_activeRow"), activeRow TSRMLS_CC); RETURN_CCTOR(activeRow); }