text: 
  #ifdef HAVE_CONFIG_H
  #include "../../../ext_config.h"
  #endif
  
  #include <php.h>
  #include "../../../php_ext.h"
  #include "../../../ext.h"
  
  #include <Zend/zend_operators.h>
  #include <Zend/zend_exceptions.h>
  #include <Zend/zend_interfaces.h>
  
  #include "kernel/main.h"
  #include "kernel/object.h"
  #include "kernel/memory.h"
  #include "kernel/array.h"
  #include "kernel/fcall.h"
  #include "kernel/string.h"
  #include "ext/spl/spl_exceptions.h"
  #include "kernel/exception.h"
  #include "kernel/operators.h"
  #include "kernel/concat.h"
  #include "phalcon/mvc/model/orm.h"
  
  
  /**
   * This file is part of the Phalcon Framework.
   *
   * (c) Phalcon Team <team@phalcon.io>
   *
   * For the full copyright and license information, please view the
   * LICENSE.txt file that was distributed with this source code.
   */
  /**
   * Phalcon\Mvc\Model\Manager
   *
   * This components controls the initialization of models, keeping record of
   * relations between the different models of the application.
   *
   * A ModelsManager is injected to a model via a Dependency Injector/Services
   * Container such as Phalcon\Di.
   *
   * ```php
   * use Phalcon\Di;
   * use Phalcon\Mvc\Model\Manager as ModelsManager;
   *
   * $di = new Di();
   *
   * $di->set(
   *     "modelsManager",
   *     function() {
   *         return new ModelsManager();
   *     }
   * );
   *
   * $robot = new Robots($di);
   * ```
   */
  ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Manager)
  {
  	ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Manager, phalcon, mvc_model_manager, phalcon_mvc_model_manager_method_entry, 0);
  
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("aliases"), ZEND_ACC_PROTECTED);
  	/**
  	 * Models' behaviors
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("behaviors"), ZEND_ACC_PROTECTED);
  	/**
  	 * Belongs to relations
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("belongsTo"), ZEND_ACC_PROTECTED);
  	/**
  	 * All the relationships by model
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("belongsToSingle"), ZEND_ACC_PROTECTED);
  	/**
  	 * @var DiInterface|null
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("container"), ZEND_ACC_PROTECTED);
  	/**
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("customEventsManager"), ZEND_ACC_PROTECTED);
  	/**
  	 * Does the model use dynamic update, instead of updating all rows?
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("dynamicUpdate"), ZEND_ACC_PROTECTED);
  	/**
  	 * @var EventsManagerInterface
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("eventsManager"), ZEND_ACC_PROTECTED);
  	/**
  	 * Has many relations
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasMany"), ZEND_ACC_PROTECTED);
  	/**
  	 * Has many relations by model
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManySingle"), ZEND_ACC_PROTECTED);
  	/**
  	 * Has many-Through relations
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManyToMany"), ZEND_ACC_PROTECTED);
  	/**
  	 * Has many-Through relations by model
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManyToManySingle"), ZEND_ACC_PROTECTED);
  	/**
  	 * Has one relations
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOne"), ZEND_ACC_PROTECTED);
  	/**
  	 * Has one relations by model
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneSingle"), ZEND_ACC_PROTECTED);
  	/**
  	 * Has one through relations
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneThrough"), ZEND_ACC_PROTECTED);
  	/**
  	 * Has one through relations by model
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneThroughSingle"), ZEND_ACC_PROTECTED);
  	/**
  	 * Mark initialized models
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("initialized"), ZEND_ACC_PROTECTED);
  	/**
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("keepSnapshots"), ZEND_ACC_PROTECTED);
  	/**
  	 * Last model initialized
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("lastInitialized"), ZEND_ACC_PROTECTED);
  	/**
  	 * Last query created/executed
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("lastQuery"), ZEND_ACC_PROTECTED);
  	/**
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("modelVisibility"), ZEND_ACC_PROTECTED);
  	/**
  	 * @var string
  	 */
  	zend_declare_property_string(phalcon_mvc_model_manager_ce, SL("prefix"), "", ZEND_ACC_PROTECTED);
  	/**
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("readConnectionServices"), ZEND_ACC_PROTECTED);
  	/**
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("sources"), ZEND_ACC_PROTECTED);
  	/**
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("schemas"), ZEND_ACC_PROTECTED);
  	/**
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("writeConnectionServices"), ZEND_ACC_PROTECTED);
  	/**
  	 * Stores a list of reusable instances
  	 *
  	 * @var array
  	 */
  	zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("reusable"), ZEND_ACC_PROTECTED);
  	phalcon_mvc_model_manager_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Manager;
  
  	zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_mvc_model_managerinterface_ce);
  	zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_di_injectionawareinterface_ce);
  	zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_events_eventsawareinterface_ce);
  	return SUCCESS;
  }
  
  /**
   * Sets the DependencyInjector container
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setDI)
  {
  	zval *container, container_sub;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&container_sub);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	zephir_fetch_params_without_memory_grow(1, 0, &container);
  
  
  	zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container);
  }
  
  /**
   * Returns the DependencyInjector container
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getDI)
  {
  	zval *this_ptr = getThis();
  
  
  
  	RETURN_MEMBER(getThis(), "container");
  }
  
  /**
   * Sets a global events manager
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setEventsManager)
  {
  	zval *eventsManager, eventsManager_sub;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&eventsManager_sub);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	zephir_fetch_params_without_memory_grow(1, 0, &eventsManager);
  
  
  	zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager);
  }
  
  /**
   * Returns the internal event manager
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getEventsManager)
  {
  	zval *this_ptr = getThis();
  
  
  
  	RETURN_MEMBER(getThis(), "eventsManager");
  }
  
  /**
   * Sets a custom events manager for a specific model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setCustomEventsManager)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, *eventsManager, eventsManager_sub, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&eventsManager_sub);
  	ZVAL_UNDEF(&_0);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &eventsManager);
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_get_class(&_0, model, 1);
  	zephir_update_property_array(this_ptr, SL("customEventsManager"), &_0, eventsManager);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Returns a custom events manager related to a model or null if there is no related events manager
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getCustomEventsManager)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, eventsManager, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&eventsManager);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (zephir_array_isset_fetch(&eventsManager, &_0, &_1, 1)) {
  		RETURN_CTOR(&eventsManager);
  	}
  	RETURN_MM_NULL();
  }
  
  /**
   * Initializes a model in the model manager
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, initialize)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *model, model_sub, __$true, className, eventsManager, _0, _1, _2$$5;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_BOOL(&__$true, 1);
  	ZVAL_UNDEF(&className);
  	ZVAL_UNDEF(&eventsManager);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2$$5);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	ZEPHIR_INIT_VAR(&className);
  	zephir_get_class(&className, model, 1);
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset(&_0, &className)) {
  		RETURN_MM_BOOL(0);
  	}
  	zephir_update_property_array(this_ptr, SL("initialized"), &className, &__$true);
  	if ((zephir_method_exists_ex(model, ZEND_STRL("initialize")) == SUCCESS)) {
  		ZEPHIR_CALL_METHOD(NULL, model, "initialize", NULL, 0);
  		zephir_check_call_status();
  	}
  	zephir_update_property_zval(this_ptr, ZEND_STRL("lastInitialized"), model);
  	zephir_read_property(&_1, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_CPY_WRT(&eventsManager, &_1);
  	if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
  		ZEPHIR_INIT_VAR(&_2$$5);
  		ZVAL_STRING(&_2$$5, "modelsManager:afterInitialize");
  		ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_2$$5, this_ptr, model);
  		zephir_check_call_status();
  	}
  	RETURN_MM_BOOL(1);
  }
  
  /**
   * Check whether a model is already initialized
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, isInitialized)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *className_param = NULL, _0, _1;
  	zval className;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&className);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_STR(className)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &className_param);
  	if (UNEXPECTED(Z_TYPE_P(className_param) != IS_STRING && Z_TYPE_P(className_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'className' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(className_param) == IS_STRING)) {
  		zephir_get_strval(&className, className_param);
  	} else {
  		ZEPHIR_INIT_VAR(&className);
  	}
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_fast_strtolower(&_1, &className);
  	RETURN_MM_BOOL(zephir_array_isset(&_0, &_1));
  }
  
  /**
   * Get last initialized model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastInitialized)
  {
  	zval *this_ptr = getThis();
  
  
  
  	RETURN_MEMBER(getThis(), "lastInitialized");
  }
  
  /**
   * Loads a model throwing an exception if it doesn't exist
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, load)
  {
  	zval _2;
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, __$null, model, _3, _0$$3;
  	zval modelName, _1$$3;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&_1$$3);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&model);
  	ZVAL_UNDEF(&_3);
  	ZVAL_UNDEF(&_0$$3);
  	ZVAL_UNDEF(&_2);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_STR(modelName)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &modelName_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  
  
  	if (UNEXPECTED(!(zephir_class_exists(&modelName, 1)))) {
  		ZEPHIR_INIT_VAR(&_0$$3);
  		object_init_ex(&_0$$3, phalcon_mvc_model_exception_ce);
  		ZEPHIR_INIT_VAR(&_1$$3);
  		ZEPHIR_CONCAT_SVS(&_1$$3, "Model '", &modelName, "' could not be loaded");
  		ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 8, &_1$$3);
  		zephir_check_call_status();
  		zephir_throw_exception_debug(&_0$$3, "phalcon/Mvc/Model/Manager.zep", 340);
  		ZEPHIR_MM_RESTORE();
  		return;
  	}
  	ZEPHIR_INIT_VAR(&_2);
  	zephir_create_array(&_2, 3, 0);
  	zephir_array_fast_append(&_2, &__$null);
  	ZEPHIR_OBS_VAR(&_3);
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC);
  	zephir_array_fast_append(&_2, &_3);
  	zephir_array_fast_append(&_2, this_ptr);
  	ZEPHIR_INIT_VAR(&model);
  	ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&model, &modelName, &_2);
  	zephir_check_call_status();
  	RETURN_CCTOR(&model);
  }
  
  /**
   * Sets the prefix for all model sources.
   *
   * ```php
   * use Phalcon\Mvc\Model\Manager;
   *
   * $di->set(
   *     "modelsManager",
   *     function () {
   *         $modelsManager = new Manager();
   *
   *         $modelsManager->setModelPrefix("wp_");
   *
   *         return $modelsManager;
   *     }
   * );
   *
   * $robots = new Robots();
   *
   * echo $robots->getSource(); // wp_robots
   * ```
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelPrefix)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *prefix_param = NULL;
  	zval prefix;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&prefix);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_STR(prefix)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &prefix_param);
  	if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) {
  		zephir_get_strval(&prefix, prefix_param);
  	} else {
  		ZEPHIR_INIT_VAR(&prefix);
  	}
  
  
  	zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Returns the prefix for all model sources.
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelPrefix)
  {
  	zval *this_ptr = getThis();
  
  
  
  	RETURN_MEMBER(getThis(), "prefix");
  }
  
  /**
   * Sets the mapped source for a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSource)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval source;
  	zval *model, model_sub, *source_param = NULL, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&source);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_STR(source)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &source_param);
  	if (UNEXPECTED(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(source_param) == IS_STRING)) {
  		zephir_get_strval(&source, source_param);
  	} else {
  		ZEPHIR_INIT_VAR(&source);
  	}
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_get_class(&_0, model, 1);
  	zephir_update_property_array(this_ptr, SL("sources"), &_0, &source);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Check whether a model property is declared as public.
   *
   * ```php
   * $isPublic = $manager->isVisibleModelProperty(
   *     new Robots(),
   *     "name"
   * );
   * ```
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, isVisibleModelProperty)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval property;
  	zval *model, model_sub, *property_param = NULL, properties, className, _0, _2, _1$$3;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&properties);
  	ZVAL_UNDEF(&className);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_1$$3);
  	ZVAL_UNDEF(&property);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_STR(property)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &property_param);
  	zephir_get_strval(&property, property_param);
  
  
  	ZEPHIR_INIT_VAR(&className);
  	zephir_get_class(&className, model, 0);
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset(&_0, &className))) {
  		ZEPHIR_CALL_FUNCTION(&_1$$3, "get_object_vars", NULL, 438, model);
  		zephir_check_call_status();
  		zephir_update_property_array(this_ptr, SL("modelVisibility"), &className, &_1$$3);
  	}
  	zephir_read_property(&_2, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_OBS_VAR(&properties);
  	zephir_array_fetch(&properties, &_2, &className, PH_NOISY, "phalcon/Mvc/Model/Manager.zep", 421);
  	RETURN_MM_BOOL(zephir_array_key_exists(&properties, &property));
  }
  
  /**
   * Returns the mapped source for a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSource)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *model, model_sub, entityName, _0, _3, _4, _5, _1$$3, _2$$3;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_3);
  	ZVAL_UNDEF(&_4);
  	ZVAL_UNDEF(&_5);
  	ZVAL_UNDEF(&_1$$3);
  	ZVAL_UNDEF(&_2$$3);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_get_class(&entityName, model, 1);
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset(&_0, &entityName))) {
  		ZEPHIR_INIT_VAR(&_1$$3);
  		ZEPHIR_INIT_VAR(&_2$$3);
  		zephir_get_class_ns(&_2$$3, model, 0);
  		zephir_uncamelize(&_1$$3, &_2$$3, NULL  );
  		ZEPHIR_CALL_METHOD(NULL, this_ptr, "setmodelsource", NULL, 0, model, &_1$$3);
  		zephir_check_call_status();
  	}
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY);
  	zephir_read_property(&_4, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY);
  	zephir_array_fetch(&_5, &_4, &entityName, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 444);
  	ZEPHIR_CONCAT_VV(return_value, &_3, &_5);
  	RETURN_MM();
  }
  
  /**
   * Sets the mapped schema for a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSchema)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval schema;
  	zval *model, model_sub, *schema_param = NULL, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&schema);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_STR(schema)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &schema_param);
  	if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) {
  		zephir_get_strval(&schema, schema_param);
  	} else {
  		ZEPHIR_INIT_VAR(&schema);
  	}
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_get_class(&_0, model, 1);
  	zephir_update_property_array(this_ptr, SL("schemas"), &_0, &schema);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Returns the mapped schema for a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSchema)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, schema, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&schema);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("schemas"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (!(zephir_array_isset_fetch(&schema, &_0, &_1, 1))) {
  		RETURN_MM_NULL();
  	}
  	RETURN_CTOR(&schema);
  }
  
  /**
   * Sets both write and read connection service for a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setConnectionService)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval connectionService;
  	zval *model, model_sub, *connectionService_param = NULL;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&connectionService);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_STR(connectionService)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &connectionService_param);
  	if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) {
  		zephir_get_strval(&connectionService, connectionService_param);
  	} else {
  		ZEPHIR_INIT_VAR(&connectionService);
  	}
  
  
  	ZEPHIR_CALL_METHOD(NULL, this_ptr, "setreadconnectionservice", NULL, 0, model, &connectionService);
  	zephir_check_call_status();
  	ZEPHIR_CALL_METHOD(NULL, this_ptr, "setwriteconnectionservice", NULL, 0, model, &connectionService);
  	zephir_check_call_status();
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Sets write connection service for a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setWriteConnectionService)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval connectionService;
  	zval *model, model_sub, *connectionService_param = NULL, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&connectionService);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_STR(connectionService)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &connectionService_param);
  	if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) {
  		zephir_get_strval(&connectionService, connectionService_param);
  	} else {
  		ZEPHIR_INIT_VAR(&connectionService);
  	}
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_get_class(&_0, model, 1);
  	zephir_update_property_array(this_ptr, SL("writeConnectionServices"), &_0, &connectionService);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Sets read connection service for a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setReadConnectionService)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval connectionService;
  	zval *model, model_sub, *connectionService_param = NULL, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&connectionService);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_STR(connectionService)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &connectionService_param);
  	if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) {
  		zephir_get_strval(&connectionService, connectionService_param);
  	} else {
  		ZEPHIR_INIT_VAR(&connectionService);
  	}
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_get_class(&_0, model, 1);
  	zephir_update_property_array(this_ptr, SL("readConnectionServices"), &_0, &connectionService);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Returns the connection to read data related to a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getReadConnection)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *model, model_sub, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, model, &_0);
  	zephir_check_call_status();
  	RETURN_MM();
  }
  
  /**
   * Returns the connection to write data related to a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getWriteConnection)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *model, model_sub, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, model, &_0);
  	zephir_check_call_status();
  	RETURN_MM();
  }
  
  /**
   * Returns the connection to read or write data related to a model depending on the connection services.
   *
   * @return AdapterInterface
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getConnection)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zephir_fcall_cache_entry *_3 = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *model, model_sub, *connectionServices, connectionServices_sub, container, service, connection, _0, _5, _1$$3, _2$$3, _4$$3;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&connectionServices_sub);
  	ZVAL_UNDEF(&container);
  	ZVAL_UNDEF(&service);
  	ZVAL_UNDEF(&connection);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_5);
  	ZVAL_UNDEF(&_1$$3);
  	ZVAL_UNDEF(&_2$$3);
  	ZVAL_UNDEF(&_4$$3);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_ZVAL(connectionServices)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &connectionServices);
  
  
  	ZEPHIR_CALL_METHOD(&service, this_ptr, "getconnectionservice", NULL, 0, model, connectionServices);
  	zephir_check_call_status();
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_CPY_WRT(&container, &_0);
  	if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) {
  		ZEPHIR_INIT_VAR(&_1$$3);
  		object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce);
  		ZEPHIR_INIT_VAR(&_4$$3);
  		ZVAL_STRING(&_4$$3, "the services related to the ORM");
  		ZEPHIR_CALL_CE_STATIC(&_2$$3, phalcon_mvc_model_exception_ce, "containerservicenotfound", &_3, 0, &_4$$3);
  		zephir_check_call_status();
  		ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 8, &_2$$3);
  		zephir_check_call_status();
  		zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Manager.zep", 528);
  		ZEPHIR_MM_RESTORE();
  		return;
  	}
  	ZEPHIR_CALL_METHOD(&_5, &container, "getshared", NULL, 0, &service);
  	zephir_check_call_status();
  	ZEPHIR_CPY_WRT(&connection, &_5);
  	if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) {
  		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid injected connection service", "phalcon/Mvc/Model/Manager.zep", 537);
  		return;
  	}
  	RETURN_CCTOR(&connection);
  }
  
  /**
   * Returns the connection service name used to read data related to a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getReadConnectionService)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *model, model_sub, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnectionservice", NULL, 0, model, &_0);
  	zephir_check_call_status();
  	RETURN_MM();
  }
  
  /**
   * Returns the connection service name used to write data related to a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getWriteConnectionService)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *model, model_sub, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnectionservice", NULL, 0, model, &_0);
  	zephir_check_call_status();
  	RETURN_MM();
  }
  
  /**
   * Returns the connection service name used to read or write data related to
   * a model depending on the connection services
   *
   * @return string
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getConnectionService)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, *connectionServices, connectionServices_sub, connection, _0;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&connectionServices_sub);
  	ZVAL_UNDEF(&connection);
  	ZVAL_UNDEF(&_0);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_ZVAL(connectionServices)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &connectionServices);
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_get_class(&_0, model, 1);
  	if (!(zephir_array_isset_fetch(&connection, connectionServices, &_0, 1))) {
  		RETURN_MM_STRING("db");
  	}
  	RETURN_CTOR(&connection);
  }
  
  /**
   * Receives events generated in the models and dispatches them to an
   * events-manager if available. Notify the behaviors that are listening in
   * the model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, notifyEvent)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *eventName_param = NULL, *model, model_sub, status, behavior, modelsBehaviors, eventsManager, customEventsManager, _0, _1, _4, _6, *_2$$3, _3$$3;
  	zval eventName, _5$$8, _7$$10;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&eventName);
  	ZVAL_UNDEF(&_5$$8);
  	ZVAL_UNDEF(&_7$$10);
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&status);
  	ZVAL_UNDEF(&behavior);
  	ZVAL_UNDEF(&modelsBehaviors);
  	ZVAL_UNDEF(&eventsManager);
  	ZVAL_UNDEF(&customEventsManager);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_4);
  	ZVAL_UNDEF(&_6);
  	ZVAL_UNDEF(&_3$$3);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_STR(eventName)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &eventName_param, &model);
  	if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) {
  		zephir_get_strval(&eventName, eventName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&eventName);
  	}
  
  
  	ZEPHIR_INIT_VAR(&status);
  	ZVAL_NULL(&status);
  	ZEPHIR_OBS_VAR(&modelsBehaviors);
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (zephir_array_isset_fetch(&modelsBehaviors, &_0, &_1, 0)) {
  		zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Model/Manager.zep", 608);
  		if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$3)
  			{
  				ZEPHIR_INIT_NVAR(&behavior);
  				ZVAL_COPY(&behavior, _2$$3);
  				ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model);
  				zephir_check_call_status();
  				if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) {
  					RETURN_MM_BOOL(0);
  				}
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_3$$3, &modelsBehaviors, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_3$$3)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0);
  				zephir_check_call_status();
  					ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model);
  					zephir_check_call_status();
  					if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) {
  						RETURN_MM_BOOL(0);
  					}
  				ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&behavior);
  	}
  	zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_CPY_WRT(&eventsManager, &_4);
  	if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
  		ZEPHIR_INIT_VAR(&_5$$8);
  		ZEPHIR_CONCAT_SV(&_5$$8, "model:", &eventName);
  		ZEPHIR_CALL_METHOD(&status, &eventsManager, "fire", NULL, 0, &_5$$8, model);
  		zephir_check_call_status();
  		if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) {
  			RETURN_CCTOR(&status);
  		}
  	}
  	ZEPHIR_OBS_VAR(&customEventsManager);
  	zephir_read_property(&_4, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_6);
  	zephir_get_class(&_6, model, 1);
  	if (zephir_array_isset_fetch(&customEventsManager, &_4, &_6, 0)) {
  		ZEPHIR_INIT_VAR(&_7$$10);
  		ZEPHIR_CONCAT_SV(&_7$$10, "model:", &eventName);
  		ZEPHIR_CALL_METHOD(&status, &customEventsManager, "fire", NULL, 0, &_7$$10, model);
  		zephir_check_call_status();
  		if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) {
  			RETURN_MM_BOOL(0);
  		}
  	}
  	RETURN_CCTOR(&status);
  }
  
  /**
   * Dispatch an event to the listeners and behaviors
   * This method expects that the endpoint listeners/behaviors returns true
   * meaning that a least one was implemented
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, missingMethod)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval eventName, _5$$8;
  	zval *model, model_sub, *eventName_param = NULL, *data, data_sub, modelsBehaviors, result, eventsManager, behavior, _0, _1, _4, *_2$$3, _3$$3;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&data_sub);
  	ZVAL_UNDEF(&modelsBehaviors);
  	ZVAL_UNDEF(&result);
  	ZVAL_UNDEF(&eventsManager);
  	ZVAL_UNDEF(&behavior);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_4);
  	ZVAL_UNDEF(&_3$$3);
  	ZVAL_UNDEF(&eventName);
  	ZVAL_UNDEF(&_5$$8);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(3, 3)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_STR(eventName)
  		Z_PARAM_ZVAL(data)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 3, 0, &model, &eventName_param, &data);
  	if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) {
  		zephir_get_strval(&eventName, eventName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&eventName);
  	}
  
  
  	ZEPHIR_OBS_VAR(&modelsBehaviors);
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (zephir_array_isset_fetch(&modelsBehaviors, &_0, &_1, 0)) {
  		zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Model/Manager.zep", 666);
  		if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$3)
  			{
  				ZEPHIR_INIT_NVAR(&behavior);
  				ZVAL_COPY(&behavior, _2$$3);
  				ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data);
  				zephir_check_call_status();
  				if (Z_TYPE_P(&result) != IS_NULL) {
  					RETURN_CCTOR(&result);
  				}
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_3$$3, &modelsBehaviors, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_3$$3)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0);
  				zephir_check_call_status();
  					ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data);
  					zephir_check_call_status();
  					if (Z_TYPE_P(&result) != IS_NULL) {
  						RETURN_CCTOR(&result);
  					}
  				ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&behavior);
  	}
  	zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_CPY_WRT(&eventsManager, &_4);
  	if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
  		ZEPHIR_INIT_VAR(&_5$$8);
  		ZEPHIR_CONCAT_SV(&_5$$8, "model:", &eventName);
  		ZEPHIR_RETURN_CALL_METHOD(&eventsManager, "fire", NULL, 0, &_5$$8, model, data);
  		zephir_check_call_status();
  		RETURN_MM();
  	}
  	RETURN_MM_NULL();
  }
  
  /**
   * Binds a behavior to a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, addBehavior)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, *behavior, behavior_sub, entityName, _0, _1$$3;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&behavior_sub);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1$$3);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_OBJECT_OF_CLASS(behavior, phalcon_mvc_model_behaviorinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &behavior);
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_get_class(&entityName, model, 1);
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset(&_0, &entityName))) {
  		ZEPHIR_INIT_VAR(&_1$$3);
  		array_init(&_1$$3);
  		zephir_update_property_array(this_ptr, SL("behaviors"), &entityName, &_1$$3);
  	}
  	zephir_update_property_array_multi(this_ptr, SL("behaviors"), behavior, SL("za"), 2, &entityName);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Sets if a model must keep snapshots
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, keepSnapshots)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_bool keepSnapshots;
  	zval *model, model_sub, *keepSnapshots_param = NULL, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_BOOL(keepSnapshots)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &keepSnapshots_param);
  	keepSnapshots = zephir_get_boolval(keepSnapshots_param);
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_get_class(&_0, model, 1);
  	ZEPHIR_INIT_VAR(&_1);
  	ZVAL_BOOL(&_1, keepSnapshots);
  	zephir_update_property_array(this_ptr, SL("keepSnapshots"), &_0, &_1);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Checks if a model is keeping snapshots for the queried records
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, isKeepingSnapshots)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, isKeeping, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&isKeeping);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (!(zephir_array_isset_fetch(&isKeeping, &_0, &_1, 1))) {
  		RETURN_MM_BOOL(0);
  	}
  	RETURN_CTOR(&isKeeping);
  }
  
  /**
   * Sets if a model must use dynamic update instead of the all-field update
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, useDynamicUpdate)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_bool dynamicUpdate;
  	zval *model, model_sub, *dynamicUpdate_param = NULL, entityName, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_BOOL(dynamicUpdate)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &model, &dynamicUpdate_param);
  	dynamicUpdate = zephir_get_boolval(dynamicUpdate_param);
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_get_class(&entityName, model, 1);
  	ZEPHIR_INIT_VAR(&_0);
  	ZVAL_BOOL(&_0, dynamicUpdate);
  	zephir_update_property_array(this_ptr, SL("dynamicUpdate"), &entityName, &_0);
  	ZEPHIR_INIT_VAR(&_1);
  	ZVAL_BOOL(&_1, dynamicUpdate);
  	zephir_update_property_array(this_ptr, SL("keepSnapshots"), &entityName, &_1);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Checks if a model is using dynamic update instead of all-field update
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, isUsingDynamicUpdate)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, isUsing, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&isUsing);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("dynamicUpdate"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (!(zephir_array_isset_fetch(&isUsing, &_0, &_1, 1))) {
  		RETURN_MM_BOOL(0);
  	}
  	RETURN_CTOR(&isUsing);
  }
  
  /**
   * Setup a 1-1 relation between two models
   *
   * @param array options
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasOne)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval referencedModel, keyRelation;
  	zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options = NULL, options_sub, __$null, entityName, referencedEntity, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2, _3;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&fields_sub);
  	ZVAL_UNDEF(&referencedFields_sub);
  	ZVAL_UNDEF(&options_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&referencedEntity);
  	ZVAL_UNDEF(&relation);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&alias);
  	ZVAL_UNDEF(&lowerAlias);
  	ZVAL_UNDEF(&singleRelations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  	ZVAL_UNDEF(&referencedModel);
  	ZVAL_UNDEF(&keyRelation);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(4, 5)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_ZVAL(fields)
  		Z_PARAM_STR(referencedModel)
  		Z_PARAM_ZVAL(referencedFields)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(options)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options);
  	if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) {
  		zephir_get_strval(&referencedModel, referencedModel_param);
  	} else {
  		ZEPHIR_INIT_VAR(&referencedModel);
  	}
  	if (!options) {
  		options = &options_sub;
  		options = &__$null;
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_get_class(&entityName, model, 1);
  	ZEPHIR_INIT_VAR(&referencedEntity);
  	zephir_fast_strtolower(&referencedEntity, &referencedModel);
  	ZEPHIR_INIT_VAR(&_0);
  	ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity);
  	zephir_get_strval(&keyRelation, &_0);
  	ZEPHIR_OBS_VAR(&relations);
  	zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&relations, &_1, &keyRelation, 0))) {
  		ZEPHIR_INIT_NVAR(&relations);
  		array_init(&relations);
  	}
  	if (Z_TYPE_P(referencedFields) == IS_ARRAY) {
  		if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 779);
  			return;
  		}
  	}
  	ZEPHIR_INIT_VAR(&relation);
  	object_init_ex(&relation, phalcon_mvc_model_relation_ce);
  	ZVAL_LONG(&_2, 1);
  	ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 452, &_2, &referencedModel, fields, referencedFields, options);
  	zephir_check_call_status();
  	ZEPHIR_OBS_VAR(&alias);
  	if (zephir_array_isset_string_fetch(&alias, options, SL("alias"), 0)) {
  		if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 799);
  			return;
  		}
  		ZEPHIR_INIT_VAR(&lowerAlias);
  		zephir_fast_strtolower(&lowerAlias, &alias);
  	} else {
  		ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity);
  	}
  	zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 812);
  	ZEPHIR_INIT_VAR(&_3);
  	ZEPHIR_CONCAT_VSV(&_3, &entityName, "$", &lowerAlias);
  	zephir_update_property_array(this_ptr, SL("aliases"), &_3, &relation);
  	zephir_update_property_array(this_ptr, SL("hasOne"), &keyRelation, &relations);
  	ZEPHIR_OBS_VAR(&singleRelations);
  	zephir_read_property(&_2, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&singleRelations, &_2, &entityName, 0))) {
  		ZEPHIR_INIT_NVAR(&singleRelations);
  		array_init(&singleRelations);
  	}
  	zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 826);
  	zephir_update_property_array(this_ptr, SL("hasOneSingle"), &entityName, &singleRelations);
  	RETURN_CCTOR(&relation);
  }
  
  /**
   * Setups a relation 1-1 between two models using an intermediate model
   *
   * @param    string fields
   * @param    string intermediateFields
   * @param    string intermediateReferencedFields
   * @param    string referencedFields
   * @param   array options
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasOneThrough)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval intermediateModel, referencedModel, keyRelation;
  	zval *model, model_sub, *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options = NULL, options_sub, __$null, entityName, referencedEntity, hasOneThrough, relation, relations, alias, lowerAlias, singleRelations, intermediateEntity, _0, _1, _2;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&fields_sub);
  	ZVAL_UNDEF(&intermediateFields_sub);
  	ZVAL_UNDEF(&intermediateReferencedFields_sub);
  	ZVAL_UNDEF(&referencedFields_sub);
  	ZVAL_UNDEF(&options_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&referencedEntity);
  	ZVAL_UNDEF(&hasOneThrough);
  	ZVAL_UNDEF(&relation);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&alias);
  	ZVAL_UNDEF(&lowerAlias);
  	ZVAL_UNDEF(&singleRelations);
  	ZVAL_UNDEF(&intermediateEntity);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&intermediateModel);
  	ZVAL_UNDEF(&referencedModel);
  	ZVAL_UNDEF(&keyRelation);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(7, 8)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_ZVAL(fields)
  		Z_PARAM_STR(intermediateModel)
  		Z_PARAM_ZVAL(intermediateFields)
  		Z_PARAM_ZVAL(intermediateReferencedFields)
  		Z_PARAM_STR(referencedModel)
  		Z_PARAM_ZVAL(referencedFields)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(options)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 7, 1, &model, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referencedModel_param, &referencedFields, &options);
  	if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) {
  		zephir_get_strval(&intermediateModel, intermediateModel_param);
  	} else {
  		ZEPHIR_INIT_VAR(&intermediateModel);
  	}
  	if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) {
  		zephir_get_strval(&referencedModel, referencedModel_param);
  	} else {
  		ZEPHIR_INIT_VAR(&referencedModel);
  	}
  	if (!options) {
  		options = &options_sub;
  		options = &__$null;
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_get_class(&entityName, model, 1);
  	ZEPHIR_INIT_VAR(&intermediateEntity);
  	zephir_fast_strtolower(&intermediateEntity, &intermediateModel);
  	ZEPHIR_INIT_VAR(&referencedEntity);
  	zephir_fast_strtolower(&referencedEntity, &referencedModel);
  	ZEPHIR_INIT_VAR(&_0);
  	ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity);
  	zephir_get_strval(&keyRelation, &_0);
  	zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_CPY_WRT(&hasOneThrough, &_1);
  	ZEPHIR_OBS_VAR(&relations);
  	if (!(zephir_array_isset_fetch(&relations, &hasOneThrough, &keyRelation, 0))) {
  		ZEPHIR_INIT_NVAR(&relations);
  		array_init(&relations);
  	}
  	if (Z_TYPE_P(intermediateFields) == IS_ARRAY) {
  		if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 871);
  			return;
  		}
  	}
  	if (Z_TYPE_P(intermediateReferencedFields) == IS_ARRAY) {
  		if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 883);
  			return;
  		}
  	}
  	ZEPHIR_INIT_VAR(&relation);
  	object_init_ex(&relation, phalcon_mvc_model_relation_ce);
  	ZVAL_LONG(&_1, 3);
  	ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 452, &_1, &referencedModel, fields, referencedFields, options);
  	zephir_check_call_status();
  	ZEPHIR_CALL_METHOD(NULL, &relation, "setintermediaterelation", NULL, 453, intermediateFields, &intermediateModel, intermediateReferencedFields);
  	zephir_check_call_status();
  	ZEPHIR_OBS_VAR(&alias);
  	if (zephir_array_isset_string_fetch(&alias, options, SL("alias"), 0)) {
  		if (Z_TYPE_P(&alias) != IS_STRING) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 912);
  			return;
  		}
  		ZEPHIR_INIT_VAR(&lowerAlias);
  		zephir_fast_strtolower(&lowerAlias, &alias);
  	} else {
  		ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity);
  	}
  	zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 923);
  	ZEPHIR_INIT_VAR(&_2);
  	ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias);
  	zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation);
  	zephir_update_property_array(this_ptr, SL("hasOneThrough"), &keyRelation, &relations);
  	ZEPHIR_OBS_VAR(&singleRelations);
  	zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) {
  		ZEPHIR_INIT_NVAR(&singleRelations);
  		array_init(&singleRelations);
  	}
  	zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 945);
  	zephir_update_property_array(this_ptr, SL("hasOneThroughSingle"), &entityName, &singleRelations);
  	RETURN_CCTOR(&relation);
  }
  
  /**
   * Setup a relation reverse many to one between two models
   *
   * @param    array options
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, addBelongsTo)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval referencedModel, keyRelation;
  	zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options = NULL, options_sub, __$null, entityName, referencedEntity, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2, _3;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&fields_sub);
  	ZVAL_UNDEF(&referencedFields_sub);
  	ZVAL_UNDEF(&options_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&referencedEntity);
  	ZVAL_UNDEF(&relation);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&alias);
  	ZVAL_UNDEF(&lowerAlias);
  	ZVAL_UNDEF(&singleRelations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  	ZVAL_UNDEF(&referencedModel);
  	ZVAL_UNDEF(&keyRelation);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(4, 5)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_ZVAL(fields)
  		Z_PARAM_STR(referencedModel)
  		Z_PARAM_ZVAL(referencedFields)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(options)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options);
  	if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) {
  		zephir_get_strval(&referencedModel, referencedModel_param);
  	} else {
  		ZEPHIR_INIT_VAR(&referencedModel);
  	}
  	if (!options) {
  		options = &options_sub;
  		options = &__$null;
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_get_class(&entityName, model, 1);
  	ZEPHIR_INIT_VAR(&referencedEntity);
  	zephir_fast_strtolower(&referencedEntity, &referencedModel);
  	ZEPHIR_INIT_VAR(&_0);
  	ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity);
  	zephir_get_strval(&keyRelation, &_0);
  	ZEPHIR_OBS_VAR(&relations);
  	zephir_read_property(&_1, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&relations, &_1, &keyRelation, 0))) {
  		ZEPHIR_INIT_NVAR(&relations);
  		array_init(&relations);
  	}
  	if (Z_TYPE_P(referencedFields) == IS_ARRAY) {
  		if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 983);
  			return;
  		}
  	}
  	ZEPHIR_INIT_VAR(&relation);
  	object_init_ex(&relation, phalcon_mvc_model_relation_ce);
  	ZVAL_LONG(&_2, 0);
  	ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 452, &_2, &referencedModel, fields, referencedFields, options);
  	zephir_check_call_status();
  	ZEPHIR_OBS_VAR(&alias);
  	if (zephir_array_isset_string_fetch(&alias, options, SL("alias"), 0)) {
  		if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 1003);
  			return;
  		}
  		ZEPHIR_INIT_VAR(&lowerAlias);
  		zephir_fast_strtolower(&lowerAlias, &alias);
  	} else {
  		ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity);
  	}
  	zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1016);
  	ZEPHIR_INIT_VAR(&_3);
  	ZEPHIR_CONCAT_VSV(&_3, &entityName, "$", &lowerAlias);
  	zephir_update_property_array(this_ptr, SL("aliases"), &_3, &relation);
  	zephir_update_property_array(this_ptr, SL("belongsTo"), &keyRelation, &relations);
  	ZEPHIR_OBS_VAR(&singleRelations);
  	zephir_read_property(&_2, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&singleRelations, &_2, &entityName, 0))) {
  		ZEPHIR_INIT_NVAR(&singleRelations);
  		array_init(&singleRelations);
  	}
  	zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1030);
  	zephir_update_property_array(this_ptr, SL("belongsToSingle"), &entityName, &singleRelations);
  	RETURN_CCTOR(&relation);
  }
  
  /**
   * Setup a relation 1-n between two models
   *
   * @param    mixed referencedFields
   * @param    array options
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasMany)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval referencedModel, keyRelation;
  	zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options = NULL, options_sub, __$null, entityName, referencedEntity, hasMany, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&fields_sub);
  	ZVAL_UNDEF(&referencedFields_sub);
  	ZVAL_UNDEF(&options_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&referencedEntity);
  	ZVAL_UNDEF(&hasMany);
  	ZVAL_UNDEF(&relation);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&alias);
  	ZVAL_UNDEF(&lowerAlias);
  	ZVAL_UNDEF(&singleRelations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&referencedModel);
  	ZVAL_UNDEF(&keyRelation);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(4, 5)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_ZVAL(fields)
  		Z_PARAM_STR(referencedModel)
  		Z_PARAM_ZVAL(referencedFields)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(options)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options);
  	if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) {
  		zephir_get_strval(&referencedModel, referencedModel_param);
  	} else {
  		ZEPHIR_INIT_VAR(&referencedModel);
  	}
  	if (!options) {
  		options = &options_sub;
  		options = &__$null;
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_get_class(&entityName, model, 1);
  	ZEPHIR_INIT_VAR(&referencedEntity);
  	zephir_fast_strtolower(&referencedEntity, &referencedModel);
  	ZEPHIR_INIT_VAR(&_0);
  	ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity);
  	zephir_get_strval(&keyRelation, &_0);
  	zephir_read_property(&_1, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_CPY_WRT(&hasMany, &_1);
  	ZEPHIR_OBS_VAR(&relations);
  	if (!(zephir_array_isset_fetch(&relations, &hasMany, &keyRelation, 0))) {
  		ZEPHIR_INIT_NVAR(&relations);
  		array_init(&relations);
  	}
  	if (Z_TYPE_P(referencedFields) == IS_ARRAY) {
  		if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 1070);
  			return;
  		}
  	}
  	ZEPHIR_INIT_VAR(&relation);
  	object_init_ex(&relation, phalcon_mvc_model_relation_ce);
  	ZVAL_LONG(&_1, 2);
  	ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 452, &_1, &referencedModel, fields, referencedFields, options);
  	zephir_check_call_status();
  	ZEPHIR_OBS_VAR(&alias);
  	if (zephir_array_isset_string_fetch(&alias, options, SL("alias"), 0)) {
  		if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 1090);
  			return;
  		}
  		ZEPHIR_INIT_VAR(&lowerAlias);
  		zephir_fast_strtolower(&lowerAlias, &alias);
  	} else {
  		ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity);
  	}
  	zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1103);
  	ZEPHIR_INIT_VAR(&_2);
  	ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias);
  	zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation);
  	zephir_update_property_array(this_ptr, SL("hasMany"), &keyRelation, &relations);
  	ZEPHIR_OBS_VAR(&singleRelations);
  	zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) {
  		ZEPHIR_INIT_NVAR(&singleRelations);
  		array_init(&singleRelations);
  	}
  	zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1117);
  	zephir_update_property_array(this_ptr, SL("hasManySingle"), &entityName, &singleRelations);
  	RETURN_CCTOR(&relation);
  }
  
  /**
   * Setups a relation n-m between two models
   *
   * @param    string fields
   * @param    string intermediateFields
   * @param    string intermediateReferencedFields
   * @param    string referencedFields
   * @param   array options
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasManyToMany)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval intermediateModel, referencedModel, keyRelation;
  	zval *model, model_sub, *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options = NULL, options_sub, __$null, entityName, referencedEntity, hasManyToMany, relation, relations, alias, lowerAlias, singleRelations, intermediateEntity, _0, _1, _2;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&fields_sub);
  	ZVAL_UNDEF(&intermediateFields_sub);
  	ZVAL_UNDEF(&intermediateReferencedFields_sub);
  	ZVAL_UNDEF(&referencedFields_sub);
  	ZVAL_UNDEF(&options_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&referencedEntity);
  	ZVAL_UNDEF(&hasManyToMany);
  	ZVAL_UNDEF(&relation);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&alias);
  	ZVAL_UNDEF(&lowerAlias);
  	ZVAL_UNDEF(&singleRelations);
  	ZVAL_UNDEF(&intermediateEntity);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&intermediateModel);
  	ZVAL_UNDEF(&referencedModel);
  	ZVAL_UNDEF(&keyRelation);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(7, 8)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_ZVAL(fields)
  		Z_PARAM_STR(intermediateModel)
  		Z_PARAM_ZVAL(intermediateFields)
  		Z_PARAM_ZVAL(intermediateReferencedFields)
  		Z_PARAM_STR(referencedModel)
  		Z_PARAM_ZVAL(referencedFields)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(options)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 7, 1, &model, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referencedModel_param, &referencedFields, &options);
  	if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) {
  		zephir_get_strval(&intermediateModel, intermediateModel_param);
  	} else {
  		ZEPHIR_INIT_VAR(&intermediateModel);
  	}
  	if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) {
  		zephir_get_strval(&referencedModel, referencedModel_param);
  	} else {
  		ZEPHIR_INIT_VAR(&referencedModel);
  	}
  	if (!options) {
  		options = &options_sub;
  		options = &__$null;
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_get_class(&entityName, model, 1);
  	ZEPHIR_INIT_VAR(&intermediateEntity);
  	zephir_fast_strtolower(&intermediateEntity, &intermediateModel);
  	ZEPHIR_INIT_VAR(&referencedEntity);
  	zephir_fast_strtolower(&referencedEntity, &referencedModel);
  	ZEPHIR_INIT_VAR(&_0);
  	ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity);
  	zephir_get_strval(&keyRelation, &_0);
  	zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_CPY_WRT(&hasManyToMany, &_1);
  	ZEPHIR_OBS_VAR(&relations);
  	if (!(zephir_array_isset_fetch(&relations, &hasManyToMany, &keyRelation, 0))) {
  		ZEPHIR_INIT_NVAR(&relations);
  		array_init(&relations);
  	}
  	if (Z_TYPE_P(intermediateFields) == IS_ARRAY) {
  		if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 1162);
  			return;
  		}
  	}
  	if (Z_TYPE_P(intermediateReferencedFields) == IS_ARRAY) {
  		if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 1174);
  			return;
  		}
  	}
  	ZEPHIR_INIT_VAR(&relation);
  	object_init_ex(&relation, phalcon_mvc_model_relation_ce);
  	ZVAL_LONG(&_1, 4);
  	ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 452, &_1, &referencedModel, fields, referencedFields, options);
  	zephir_check_call_status();
  	ZEPHIR_CALL_METHOD(NULL, &relation, "setintermediaterelation", NULL, 453, intermediateFields, &intermediateModel, intermediateReferencedFields);
  	zephir_check_call_status();
  	ZEPHIR_OBS_VAR(&alias);
  	if (zephir_array_isset_string_fetch(&alias, options, SL("alias"), 0)) {
  		if (Z_TYPE_P(&alias) != IS_STRING) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 1203);
  			return;
  		}
  		ZEPHIR_INIT_VAR(&lowerAlias);
  		zephir_fast_strtolower(&lowerAlias, &alias);
  	} else {
  		ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity);
  	}
  	zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1214);
  	ZEPHIR_INIT_VAR(&_2);
  	ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias);
  	zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation);
  	zephir_update_property_array(this_ptr, SL("hasManyToMany"), &keyRelation, &relations);
  	ZEPHIR_OBS_VAR(&singleRelations);
  	zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) {
  		ZEPHIR_INIT_NVAR(&singleRelations);
  		array_init(&singleRelations);
  	}
  	zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1236);
  	zephir_update_property_array(this_ptr, SL("hasManyToManySingle"), &entityName, &singleRelations);
  	RETURN_CCTOR(&relation);
  }
  
  /**
   * Checks whether a model has a belongsTo relation with another model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, existsBelongsTo)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, *modelRelation_param = NULL, entityName, _0, _1, _2, _3;
  	zval modelName, modelRelation, keyRelation;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&modelRelation);
  	ZVAL_UNDEF(&keyRelation);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(modelRelation)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) {
  		zephir_get_strval(&modelRelation, modelRelation_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelRelation);
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_fast_strtolower(&entityName, &modelName);
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_fast_strtolower(&_0, &modelRelation);
  	ZEPHIR_INIT_VAR(&_1);
  	ZEPHIR_CONCAT_VSV(&_1, &entityName, "$", &_0);
  	zephir_get_strval(&keyRelation, &_1);
  	zephir_read_property(&_2, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset(&_2, &entityName))) {
  		ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, &modelName);
  		zephir_check_call_status();
  	}
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY);
  	RETURN_MM_BOOL(zephir_array_isset(&_3, &keyRelation));
  }
  
  /**
   * Checks whether a model has a hasMany relation with another model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasMany)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, *modelRelation_param = NULL, entityName, _0, _1, _2, _3;
  	zval modelName, modelRelation, keyRelation;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&modelRelation);
  	ZVAL_UNDEF(&keyRelation);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(modelRelation)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) {
  		zephir_get_strval(&modelRelation, modelRelation_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelRelation);
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_fast_strtolower(&entityName, &modelName);
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_fast_strtolower(&_0, &modelRelation);
  	ZEPHIR_INIT_VAR(&_1);
  	ZEPHIR_CONCAT_VSV(&_1, &entityName, "$", &_0);
  	zephir_get_strval(&keyRelation, &_1);
  	zephir_read_property(&_2, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset(&_2, &entityName))) {
  		ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, &modelName);
  		zephir_check_call_status();
  	}
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY);
  	RETURN_MM_BOOL(zephir_array_isset(&_3, &keyRelation));
  }
  
  /**
   * Checks whether a model has a hasOne relation with another model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasOne)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, *modelRelation_param = NULL, entityName, _0, _1, _2, _3;
  	zval modelName, modelRelation, keyRelation;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&modelRelation);
  	ZVAL_UNDEF(&keyRelation);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(modelRelation)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) {
  		zephir_get_strval(&modelRelation, modelRelation_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelRelation);
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_fast_strtolower(&entityName, &modelName);
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_fast_strtolower(&_0, &modelRelation);
  	ZEPHIR_INIT_VAR(&_1);
  	ZEPHIR_CONCAT_VSV(&_1, &entityName, "$", &_0);
  	zephir_get_strval(&keyRelation, &_1);
  	zephir_read_property(&_2, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset(&_2, &entityName))) {
  		ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, &modelName);
  		zephir_check_call_status();
  	}
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY);
  	RETURN_MM_BOOL(zephir_array_isset(&_3, &keyRelation));
  }
  
  /**
   * Checks whether a model has a hasOneThrough relation with another model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasOneThrough)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, *modelRelation_param = NULL, entityName, _0, _1, _2, _3;
  	zval modelName, modelRelation, keyRelation;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&modelRelation);
  	ZVAL_UNDEF(&keyRelation);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(modelRelation)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) {
  		zephir_get_strval(&modelRelation, modelRelation_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelRelation);
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_fast_strtolower(&entityName, &modelName);
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_fast_strtolower(&_0, &modelRelation);
  	ZEPHIR_INIT_VAR(&_1);
  	ZEPHIR_CONCAT_VSV(&_1, &entityName, "$", &_0);
  	zephir_get_strval(&keyRelation, &_1);
  	zephir_read_property(&_2, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset(&_2, &entityName))) {
  		ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, &modelName);
  		zephir_check_call_status();
  	}
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY);
  	RETURN_MM_BOOL(zephir_array_isset(&_3, &keyRelation));
  }
  
  /**
   * Checks whether a model has a hasManyToMany relation with another model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasManyToMany)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, *modelRelation_param = NULL, entityName, _0, _1, _2, _3;
  	zval modelName, modelRelation, keyRelation;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&modelRelation);
  	ZVAL_UNDEF(&keyRelation);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(modelRelation)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) {
  		zephir_get_strval(&modelRelation, modelRelation_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelRelation);
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_fast_strtolower(&entityName, &modelName);
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_fast_strtolower(&_0, &modelRelation);
  	ZEPHIR_INIT_VAR(&_1);
  	ZEPHIR_CONCAT_VSV(&_1, &entityName, "$", &_0);
  	zephir_get_strval(&keyRelation, &_1);
  	zephir_read_property(&_2, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset(&_2, &entityName))) {
  		ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, &modelName);
  		zephir_check_call_status();
  	}
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY);
  	RETURN_MM_BOOL(zephir_array_isset(&_3, &keyRelation));
  }
  
  /**
   * Returns a relation by its alias
   *
   * @param string modelName
   * @param string alias
   *
   * @return RelationInterface|bool
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationByAlias)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *modelName_param = NULL, *alias_param = NULL, relation, _0, _1;
  	zval modelName, alias, _2;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&alias);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&relation);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(alias)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &modelName_param, &alias_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(alias_param) != IS_STRING && Z_TYPE_P(alias_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'alias' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(alias_param) == IS_STRING)) {
  		zephir_get_strval(&alias, alias_param);
  	} else {
  		ZEPHIR_INIT_VAR(&alias);
  	}
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("aliases"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	ZEPHIR_INIT_VAR(&_2);
  	ZEPHIR_CONCAT_VSV(&_2, &modelName, "$", &alias);
  	zephir_fast_strtolower(&_1, &_2);
  	if (!(zephir_array_isset_fetch(&relation, &_0, &_1, 1))) {
  		RETURN_MM_BOOL(0);
  	}
  	RETURN_CTOR(&relation);
  }
  
  /**
   * Merge two arrays of find parameters
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, _mergeFindParameters)
  {
  	zend_bool _6$$6, _9$$11, _16$$17, _17$$17, _22$$26, _23$$26;
  	zend_string *_5$$5, *_15$$16;
  	zend_ulong _4$$5, _14$$16;
  	zval findParams;
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *findParamsOne = NULL, findParamsOne_sub, *findParamsTwo = NULL, findParamsTwo_sub, key, value, _0$$3, _1$$4, *_2$$5, _3$$5, _7$$9, _8$$9, _10$$14, _11$$14, *_12$$16, _13$$16, _18$$20, _19$$20, _20$$24, _21$$24, _24$$29, _25$$29, _26$$33, _27$$33;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&findParamsOne_sub);
  	ZVAL_UNDEF(&findParamsTwo_sub);
  	ZVAL_UNDEF(&key);
  	ZVAL_UNDEF(&value);
  	ZVAL_UNDEF(&_0$$3);
  	ZVAL_UNDEF(&_1$$4);
  	ZVAL_UNDEF(&_3$$5);
  	ZVAL_UNDEF(&_7$$9);
  	ZVAL_UNDEF(&_8$$9);
  	ZVAL_UNDEF(&_10$$14);
  	ZVAL_UNDEF(&_11$$14);
  	ZVAL_UNDEF(&_13$$16);
  	ZVAL_UNDEF(&_18$$20);
  	ZVAL_UNDEF(&_19$$20);
  	ZVAL_UNDEF(&_20$$24);
  	ZVAL_UNDEF(&_21$$24);
  	ZVAL_UNDEF(&_24$$29);
  	ZVAL_UNDEF(&_25$$29);
  	ZVAL_UNDEF(&_26$$33);
  	ZVAL_UNDEF(&_27$$33);
  	ZVAL_UNDEF(&findParams);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_ZVAL(findParamsOne)
  		Z_PARAM_ZVAL(findParamsTwo)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &findParamsOne, &findParamsTwo);
  	ZEPHIR_SEPARATE_PARAM(findParamsOne);
  	ZEPHIR_SEPARATE_PARAM(findParamsTwo);
  
  
  	ZEPHIR_INIT_VAR(&findParams);
  	array_init(&findParams);
  	if (Z_TYPE_P(findParamsOne) == IS_STRING) {
  		ZEPHIR_INIT_VAR(&_0$$3);
  		zephir_create_array(&_0$$3, 1, 0);
  		zephir_array_update_string(&_0$$3, SL("conditions"), findParamsOne, PH_COPY | PH_SEPARATE);
  		ZEPHIR_CPY_WRT(findParamsOne, &_0$$3);
  	}
  	if (Z_TYPE_P(findParamsTwo) == IS_STRING) {
  		ZEPHIR_INIT_VAR(&_1$$4);
  		zephir_create_array(&_1$$4, 1, 0);
  		zephir_array_update_string(&_1$$4, SL("conditions"), findParamsTwo, PH_COPY | PH_SEPARATE);
  		ZEPHIR_CPY_WRT(findParamsTwo, &_1$$4);
  	}
  	if (Z_TYPE_P(findParamsOne) == IS_ARRAY) {
  		zephir_is_iterable(findParamsOne, 0, "phalcon/Mvc/Model/Manager.zep", 1424);
  		if (Z_TYPE_P(findParamsOne) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(findParamsOne), _4$$5, _5$$5, _2$$5)
  			{
  				ZEPHIR_INIT_NVAR(&key);
  				if (_5$$5 != NULL) { 
  					ZVAL_STR_COPY(&key, _5$$5);
  				} else {
  					ZVAL_LONG(&key, _4$$5);
  				}
  				ZEPHIR_INIT_NVAR(&value);
  				ZVAL_COPY(&value, _2$$5);
  				_6$$6 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0);
  				if (!(_6$$6)) {
  					_6$$6 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions");
  				}
  				if (_6$$6) {
  					if (!(zephir_array_isset_long(&findParams, 0))) {
  						zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
  					} else {
  						zephir_array_fetch_long(&_7$$9, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1418);
  						ZEPHIR_INIT_NVAR(&_8$$9);
  						ZEPHIR_CONCAT_SVSVS(&_8$$9, "(", &_7$$9, ") AND (", &value, ")");
  						zephir_array_update_long(&findParams, 0, &_8$$9, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
  					}
  				} else {
  					zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE);
  				}
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, findParamsOne, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_3$$5, findParamsOne, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_3$$5)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&key, findParamsOne, "key", NULL, 0);
  				zephir_check_call_status();
  				ZEPHIR_CALL_METHOD(&value, findParamsOne, "current", NULL, 0);
  				zephir_check_call_status();
  					_9$$11 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0);
  					if (!(_9$$11)) {
  						_9$$11 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions");
  					}
  					if (_9$$11) {
  						if (!(zephir_array_isset_long(&findParams, 0))) {
  							zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
  						} else {
  							zephir_array_fetch_long(&_10$$14, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1418);
  							ZEPHIR_INIT_NVAR(&_11$$14);
  							ZEPHIR_CONCAT_SVSVS(&_11$$14, "(", &_10$$14, ") AND (", &value, ")");
  							zephir_array_update_long(&findParams, 0, &_11$$14, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
  						}
  					} else {
  						zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE);
  					}
  				ZEPHIR_CALL_METHOD(NULL, findParamsOne, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&value);
  		ZEPHIR_INIT_NVAR(&key);
  	}
  	if (Z_TYPE_P(findParamsTwo) == IS_ARRAY) {
  		zephir_is_iterable(findParamsTwo, 0, "phalcon/Mvc/Model/Manager.zep", 1449);
  		if (Z_TYPE_P(findParamsTwo) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(findParamsTwo), _14$$16, _15$$16, _12$$16)
  			{
  				ZEPHIR_INIT_NVAR(&key);
  				if (_15$$16 != NULL) { 
  					ZVAL_STR_COPY(&key, _15$$16);
  				} else {
  					ZVAL_LONG(&key, _14$$16);
  				}
  				ZEPHIR_INIT_NVAR(&value);
  				ZVAL_COPY(&value, _12$$16);
  				_16$$17 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0);
  				if (!(_16$$17)) {
  					_16$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions");
  				}
  				_17$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bind");
  				if (!(_17$$17)) {
  					_17$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bindTypes");
  				}
  				if (_16$$17) {
  					if (!(zephir_array_isset_long(&findParams, 0))) {
  						zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
  					} else {
  						zephir_array_fetch_long(&_18$$20, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1432);
  						ZEPHIR_INIT_NVAR(&_19$$20);
  						ZEPHIR_CONCAT_SVSVS(&_19$$20, "(", &_18$$20, ") AND (", &value, ")");
  						zephir_array_update_long(&findParams, 0, &_19$$20, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
  					}
  				} else if (_17$$17) {
  					if (Z_TYPE_P(&value) == IS_ARRAY) {
  						if (!(zephir_array_isset(&findParams, &key))) {
  							zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE);
  						} else {
  							ZEPHIR_INIT_NVAR(&_20$$24);
  							zephir_array_fetch(&_21$$24, &findParams, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1440);
  							zephir_fast_array_merge(&_20$$24, &_21$$24, &value);
  							zephir_array_update_zval(&findParams, &key, &_20$$24, PH_COPY | PH_SEPARATE);
  						}
  					}
  				} else {
  					zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE);
  				}
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, findParamsTwo, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_13$$16, findParamsTwo, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_13$$16)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&key, findParamsTwo, "key", NULL, 0);
  				zephir_check_call_status();
  				ZEPHIR_CALL_METHOD(&value, findParamsTwo, "current", NULL, 0);
  				zephir_check_call_status();
  					_22$$26 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0);
  					if (!(_22$$26)) {
  						_22$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions");
  					}
  					_23$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bind");
  					if (!(_23$$26)) {
  						_23$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bindTypes");
  					}
  					if (_22$$26) {
  						if (!(zephir_array_isset_long(&findParams, 0))) {
  							zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
  						} else {
  							zephir_array_fetch_long(&_24$$29, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1432);
  							ZEPHIR_INIT_NVAR(&_25$$29);
  							ZEPHIR_CONCAT_SVSVS(&_25$$29, "(", &_24$$29, ") AND (", &value, ")");
  							zephir_array_update_long(&findParams, 0, &_25$$29, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
  						}
  					} else if (_23$$26) {
  						if (Z_TYPE_P(&value) == IS_ARRAY) {
  							if (!(zephir_array_isset(&findParams, &key))) {
  								zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE);
  							} else {
  								ZEPHIR_INIT_NVAR(&_26$$33);
  								zephir_array_fetch(&_27$$33, &findParams, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1440);
  								zephir_fast_array_merge(&_26$$33, &_27$$33, &value);
  								zephir_array_update_zval(&findParams, &key, &_26$$33, PH_COPY | PH_SEPARATE);
  							}
  						}
  					} else {
  						zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE);
  					}
  				ZEPHIR_CALL_METHOD(NULL, findParamsTwo, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&value);
  		ZEPHIR_INIT_NVAR(&key);
  	}
  	RETURN_CTOR(&findParams);
  }
  
  /**
   * Helper method to query records based on a relation definition
   *
   * @return \Phalcon\Mvc\Model\Resultset\Simple|int|false
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationRecords)
  {
  	zend_string *_20$$11;
  	zend_ulong _19$$11;
  	zend_bool reusable = 0, _35$$21;
  	zval placeholders, conditions, joinConditions, _36, _34$$21;
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zephir_fcall_cache_entry *_24 = NULL, *_29 = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval method, retrieveMethod;
  	zval *relation, relation_sub, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, referencedModel, intermediateModel, intermediateFields, fields, builder, extraParameters, refPosition, field, referencedFields, findParams, findArguments, uniqueKey, records, arguments, rows, firstRow, query, _0, _31, _32, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _11$$3, _8$$6, _9$$6, _10$$6, _12$$8, _13$$8, _14$$10, _15$$10, _16$$11, *_17$$11, _18$$11, _21$$12, _22$$12, _23$$12, _25$$12, _26$$13, _27$$13, _28$$13, _30$$13, _33$$16;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&relation_sub);
  	ZVAL_UNDEF(&record_sub);
  	ZVAL_UNDEF(&parameters_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&referencedModel);
  	ZVAL_UNDEF(&intermediateModel);
  	ZVAL_UNDEF(&intermediateFields);
  	ZVAL_UNDEF(&fields);
  	ZVAL_UNDEF(&builder);
  	ZVAL_UNDEF(&extraParameters);
  	ZVAL_UNDEF(&refPosition);
  	ZVAL_UNDEF(&field);
  	ZVAL_UNDEF(&referencedFields);
  	ZVAL_UNDEF(&findParams);
  	ZVAL_UNDEF(&findArguments);
  	ZVAL_UNDEF(&uniqueKey);
  	ZVAL_UNDEF(&records);
  	ZVAL_UNDEF(&arguments);
  	ZVAL_UNDEF(&rows);
  	ZVAL_UNDEF(&firstRow);
  	ZVAL_UNDEF(&query);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_31);
  	ZVAL_UNDEF(&_32);
  	ZVAL_UNDEF(&_1$$3);
  	ZVAL_UNDEF(&_2$$3);
  	ZVAL_UNDEF(&_3$$3);
  	ZVAL_UNDEF(&_4$$3);
  	ZVAL_UNDEF(&_5$$3);
  	ZVAL_UNDEF(&_6$$3);
  	ZVAL_UNDEF(&_7$$3);
  	ZVAL_UNDEF(&_11$$3);
  	ZVAL_UNDEF(&_8$$6);
  	ZVAL_UNDEF(&_9$$6);
  	ZVAL_UNDEF(&_10$$6);
  	ZVAL_UNDEF(&_12$$8);
  	ZVAL_UNDEF(&_13$$8);
  	ZVAL_UNDEF(&_14$$10);
  	ZVAL_UNDEF(&_15$$10);
  	ZVAL_UNDEF(&_16$$11);
  	ZVAL_UNDEF(&_18$$11);
  	ZVAL_UNDEF(&_21$$12);
  	ZVAL_UNDEF(&_22$$12);
  	ZVAL_UNDEF(&_23$$12);
  	ZVAL_UNDEF(&_25$$12);
  	ZVAL_UNDEF(&_26$$13);
  	ZVAL_UNDEF(&_27$$13);
  	ZVAL_UNDEF(&_28$$13);
  	ZVAL_UNDEF(&_30$$13);
  	ZVAL_UNDEF(&_33$$16);
  	ZVAL_UNDEF(&method);
  	ZVAL_UNDEF(&retrieveMethod);
  	ZVAL_UNDEF(&placeholders);
  	ZVAL_UNDEF(&conditions);
  	ZVAL_UNDEF(&joinConditions);
  	ZVAL_UNDEF(&_36);
  	ZVAL_UNDEF(&_34$$21);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 4)
  		Z_PARAM_OBJECT_OF_CLASS(relation, phalcon_mvc_model_relationinterface_ce)
  		Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(parameters)
  		Z_PARAM_STR_OR_NULL(method)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 2, &relation, &record, &parameters, &method_param);
  	if (!parameters) {
  		parameters = &parameters_sub;
  		parameters = &__$null;
  	}
  	if (!method_param) {
  		ZEPHIR_INIT_VAR(&method);
  	} else {
  		zephir_get_strval(&method, method_param);
  	}
  
  
  	ZEPHIR_INIT_VAR(&placeholders);
  	array_init(&placeholders);
  	ZEPHIR_CALL_METHOD(&extraParameters, relation, "getparams", NULL, 0);
  	zephir_check_call_status();
  	ZEPHIR_CALL_METHOD(&referencedModel, relation, "getreferencedmodel", NULL, 0);
  	zephir_check_call_status();
  	ZEPHIR_CALL_METHOD(&_0, relation, "isthrough", NULL, 0);
  	zephir_check_call_status();
  	if (zephir_is_true(&_0)) {
  		ZEPHIR_INIT_VAR(&conditions);
  		array_init(&conditions);
  		ZEPHIR_CALL_METHOD(&intermediateModel, relation, "getintermediatemodel", NULL, 0);
  		zephir_check_call_status();
  		ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatefields", NULL, 0);
  		zephir_check_call_status();
  		ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0);
  		zephir_check_call_status();
  		if (UNEXPECTED(Z_TYPE_P(&fields) == IS_ARRAY)) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Manager.zep", 1501);
  			return;
  		}
  		ZEPHIR_INIT_VAR(&_1$$3);
  		ZEPHIR_CONCAT_SVSVS(&_1$$3, "[", &intermediateModel, "].[", &intermediateFields, "] = :APR0:");
  		zephir_array_append(&conditions, &_1$$3, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1504);
  		ZEPHIR_CALL_METHOD(&_2$$3, record, "readattribute", NULL, 0, &fields);
  		zephir_check_call_status();
  		zephir_array_update_string(&placeholders, SL("APR0"), &_2$$3, PH_COPY | PH_SEPARATE);
  		ZEPHIR_INIT_VAR(&joinConditions);
  		array_init(&joinConditions);
  		ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatereferencedfields", NULL, 0);
  		zephir_check_call_status();
  		if (UNEXPECTED(Z_TYPE_P(&intermediateFields) == IS_ARRAY)) {
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Manager.zep", 1515);
  			return;
  		}
  		ZEPHIR_CALL_METHOD(&_3$$3, relation, "getreferencedfields", NULL, 0);
  		zephir_check_call_status();
  		ZEPHIR_INIT_VAR(&_4$$3);
  		ZEPHIR_CONCAT_SVSVSVSVS(&_4$$3, "[", &intermediateModel, "].[", &intermediateFields, "] = [", &referencedModel, "].[", &_3$$3, "]");
  		zephir_array_append(&joinConditions, &_4$$3, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1518);
  		ZEPHIR_CALL_METHOD(&_5$$3, this_ptr, "_mergefindparameters", NULL, 454, &extraParameters, parameters);
  		zephir_check_call_status();
  		ZEPHIR_CALL_METHOD(&builder, this_ptr, "createbuilder", NULL, 0, &_5$$3);
  		zephir_check_call_status();
  		ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &referencedModel);
  		zephir_check_call_status();
  		ZEPHIR_INIT_VAR(&_6$$3);
  		zephir_fast_join_str(&_6$$3, SL(" AND "), &joinConditions);
  		ZEPHIR_CALL_METHOD(NULL, &builder, "innerjoin", NULL, 0, &intermediateModel, &_6$$3);
  		zephir_check_call_status();
  		ZEPHIR_INIT_VAR(&_7$$3);
  		zephir_fast_join_str(&_7$$3, SL(" AND "), &conditions);
  		ZEPHIR_CALL_METHOD(NULL, &builder, "andwhere", NULL, 0, &_7$$3, &placeholders);
  		zephir_check_call_status();
  		if (ZEPHIR_IS_STRING(&method, "count")) {
  			ZEPHIR_INIT_VAR(&_8$$6);
  			ZVAL_STRING(&_8$$6, "COUNT(*) AS rowcount");
  			ZEPHIR_CALL_METHOD(NULL, &builder, "columns", NULL, 0, &_8$$6);
  			zephir_check_call_status();
  			ZEPHIR_CALL_METHOD(&_9$$6, &builder, "getquery", NULL, 0);
  			zephir_check_call_status();
  			ZEPHIR_CALL_METHOD(&rows, &_9$$6, "execute", NULL, 0);
  			zephir_check_call_status();
  			ZEPHIR_CALL_METHOD(&firstRow, &rows, "getfirst", NULL, 0);
  			zephir_check_call_status();
  			ZEPHIR_INIT_NVAR(&_8$$6);
  			ZVAL_STRING(&_8$$6, "rowcount");
  			ZEPHIR_CALL_METHOD(&_10$$6, &firstRow, "readattribute", NULL, 0, &_8$$6);
  			zephir_check_call_status();
  			RETURN_MM_LONG(zephir_get_intval(&_10$$6));
  		}
  		ZEPHIR_CALL_METHOD(&_11$$3, &builder, "getquery", NULL, 0);
  		zephir_check_call_status();
  		ZEPHIR_CPY_WRT(&query, &_11$$3);
  		ZEPHIR_CALL_METHOD(&_11$$3, relation, "gettype", NULL, 0);
  		zephir_check_call_status();
  		do {
  			if (ZEPHIR_IS_LONG(&_11$$3, 4)) {
  				ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 0);
  				zephir_check_call_status();
  				RETURN_MM();
  			}
  			if (ZEPHIR_IS_LONG(&_11$$3, 3)) {
  				ZVAL_BOOL(&_13$$8, 1);
  				ZEPHIR_CALL_METHOD(&_12$$8, &query, "setuniquerow", NULL, 0, &_13$$8);
  				zephir_check_call_status();
  				ZEPHIR_RETURN_CALL_METHOD(&_12$$8, "execute", NULL, 0);
  				zephir_check_call_status();
  				RETURN_MM();
  			}
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown relation type", "phalcon/Mvc/Model/Manager.zep", 1563);
  			return;
  		} while(0);
  
  	}
  	ZEPHIR_INIT_NVAR(&conditions);
  	array_init(&conditions);
  	ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0);
  	zephir_check_call_status();
  	ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0);
  	zephir_check_call_status();
  	if (Z_TYPE_P(&fields) != IS_ARRAY) {
  		ZEPHIR_INIT_VAR(&_14$$10);
  		ZEPHIR_CONCAT_SVS(&_14$$10, "[", &referencedFields, "] = :APR0:");
  		zephir_array_append(&conditions, &_14$$10, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1580);
  		ZEPHIR_CALL_METHOD(&_15$$10, record, "readattribute", NULL, 0, &fields);
  		zephir_check_call_status();
  		zephir_array_update_string(&placeholders, SL("APR0"), &_15$$10, PH_COPY | PH_SEPARATE);
  	} else {
  		ZEPHIR_CALL_METHOD(&_16$$11, relation, "getfields", NULL, 0);
  		zephir_check_call_status();
  		zephir_is_iterable(&_16$$11, 0, "phalcon/Mvc/Model/Manager.zep", 1587);
  		if (Z_TYPE_P(&_16$$11) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_16$$11), _19$$11, _20$$11, _17$$11)
  			{
  				ZEPHIR_INIT_NVAR(&refPosition);
  				if (_20$$11 != NULL) { 
  					ZVAL_STR_COPY(&refPosition, _20$$11);
  				} else {
  					ZVAL_LONG(&refPosition, _19$$11);
  				}
  				ZEPHIR_INIT_NVAR(&field);
  				ZVAL_COPY(&field, _17$$11);
  				zephir_array_fetch(&_21$$12, &referencedFields, &refPosition, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1584);
  				ZEPHIR_INIT_NVAR(&_22$$12);
  				ZEPHIR_CONCAT_SVSVS(&_22$$12, "[", &_21$$12, "] = :APR", &refPosition, ":");
  				zephir_array_append(&conditions, &_22$$12, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1584);
  				ZEPHIR_CALL_METHOD(&_23$$12, record, "readattribute", &_24, 0, &field);
  				zephir_check_call_status();
  				ZEPHIR_INIT_NVAR(&_25$$12);
  				ZEPHIR_CONCAT_SV(&_25$$12, "APR", &refPosition);
  				zephir_array_update_zval(&placeholders, &_25$$12, &_23$$12, PH_COPY | PH_SEPARATE);
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, &_16$$11, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_18$$11, &_16$$11, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_18$$11)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&refPosition, &_16$$11, "key", NULL, 0);
  				zephir_check_call_status();
  				ZEPHIR_CALL_METHOD(&field, &_16$$11, "current", NULL, 0);
  				zephir_check_call_status();
  					zephir_array_fetch(&_26$$13, &referencedFields, &refPosition, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1584);
  					ZEPHIR_INIT_NVAR(&_27$$13);
  					ZEPHIR_CONCAT_SVSVS(&_27$$13, "[", &_26$$13, "] = :APR", &refPosition, ":");
  					zephir_array_append(&conditions, &_27$$13, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1584);
  					ZEPHIR_CALL_METHOD(&_28$$13, record, "readattribute", &_29, 0, &field);
  					zephir_check_call_status();
  					ZEPHIR_INIT_NVAR(&_30$$13);
  					ZEPHIR_CONCAT_SV(&_30$$13, "APR", &refPosition);
  					zephir_array_update_zval(&placeholders, &_30$$13, &_28$$13, PH_COPY | PH_SEPARATE);
  				ZEPHIR_CALL_METHOD(NULL, &_16$$11, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&field);
  		ZEPHIR_INIT_NVAR(&refPosition);
  	}
  	ZEPHIR_INIT_VAR(&findParams);
  	zephir_create_array(&findParams, 3, 0);
  	ZEPHIR_INIT_VAR(&_31);
  	zephir_fast_join_str(&_31, SL(" AND "), &conditions);
  	zephir_array_fast_append(&findParams, &_31);
  	zephir_array_update_string(&findParams, SL("bind"), &placeholders, PH_COPY | PH_SEPARATE);
  	ZEPHIR_CALL_METHOD(&_32, record, "getdi", NULL, 0);
  	zephir_check_call_status();
  	zephir_array_update_string(&findParams, SL("di"), &_32, PH_COPY | PH_SEPARATE);
  	ZEPHIR_CALL_METHOD(&findArguments, this_ptr, "_mergefindparameters", NULL, 454, &findParams, parameters);
  	zephir_check_call_status();
  	if (Z_TYPE_P(&extraParameters) == IS_ARRAY) {
  		ZEPHIR_CALL_METHOD(&findParams, this_ptr, "_mergefindparameters", NULL, 454, &extraParameters, &findArguments);
  		zephir_check_call_status();
  	} else {
  		ZEPHIR_CPY_WRT(&findParams, &findArguments);
  	}
  	if (ZEPHIR_IS_NULL(&method)) {
  		ZEPHIR_CALL_METHOD(&_33$$16, relation, "gettype", NULL, 0);
  		zephir_check_call_status();
  		do {
  			if (ZEPHIR_IS_LONG(&_33$$16, 0) || ZEPHIR_IS_LONG(&_33$$16, 1)) {
  				ZEPHIR_INIT_VAR(&retrieveMethod);
  				ZVAL_STRING(&retrieveMethod, "findFirst");
  				break;
  			}
  			if (ZEPHIR_IS_LONG(&_33$$16, 2)) {
  				ZEPHIR_INIT_NVAR(&retrieveMethod);
  				ZVAL_STRING(&retrieveMethod, "find");
  				break;
  			}
  			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown relation type", "phalcon/Mvc/Model/Manager.zep", 1625);
  			return;
  		} while(0);
  
  	} else {
  		ZEPHIR_CPY_WRT(&retrieveMethod, &method);
  	}
  	ZEPHIR_CALL_METHOD(&_32, relation, "isreusable", NULL, 0);
  	zephir_check_call_status();
  	reusable = zephir_get_boolval(&_32);
  	if (reusable) {
  		ZEPHIR_INIT_VAR(&_34$$21);
  		zephir_create_array(&_34$$21, 2, 0);
  		zephir_array_fast_append(&_34$$21, &findParams);
  		zephir_array_fast_append(&_34$$21, &retrieveMethod);
  		ZEPHIR_INIT_VAR(&uniqueKey);
  		zephir_unique_key(&uniqueKey, &referencedModel, &_34$$21);
  		ZEPHIR_CALL_METHOD(&records, this_ptr, "getreusablerecords", NULL, 0, &referencedModel, &uniqueKey);
  		zephir_check_call_status();
  		_35$$21 = Z_TYPE_P(&records) == IS_ARRAY;
  		if (!(_35$$21)) {
  			_35$$21 = Z_TYPE_P(&records) == IS_OBJECT;
  		}
  		if (_35$$21) {
  			RETURN_CCTOR(&records);
  		}
  	}
  	ZEPHIR_INIT_VAR(&arguments);
  	zephir_create_array(&arguments, 1, 0);
  	zephir_array_fast_append(&arguments, &findParams);
  	ZEPHIR_INIT_VAR(&_36);
  	zephir_create_array(&_36, 2, 0);
  	ZEPHIR_CALL_METHOD(&_32, this_ptr, "load", NULL, 0, &referencedModel);
  	zephir_check_call_status();
  	zephir_array_fast_append(&_36, &_32);
  	zephir_array_fast_append(&_36, &retrieveMethod);
  	ZEPHIR_INIT_NVAR(&records);
  	ZEPHIR_CALL_USER_FUNC_ARRAY(&records, &_36, &arguments);
  	zephir_check_call_status();
  	if (reusable) {
  		ZEPHIR_CALL_METHOD(NULL, this_ptr, "setreusablerecords", NULL, 0, &referencedModel, &uniqueKey, &records);
  		zephir_check_call_status();
  	}
  	RETURN_CCTOR(&records);
  }
  
  /**
   * Returns a reusable object from the internal list
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getReusableRecords)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *modelName_param = NULL, *key_param = NULL, records, _0;
  	zval modelName, key;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&key);
  	ZVAL_UNDEF(&records);
  	ZVAL_UNDEF(&_0);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(key)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &modelName_param, &key_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) {
  		zephir_get_strval(&key, key_param);
  	} else {
  		ZEPHIR_INIT_VAR(&key);
  	}
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("reusable"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&records, &_0, &key, 1))) {
  		RETURN_MM_NULL();
  	}
  	RETURN_CTOR(&records);
  }
  
  /**
   * Stores a reusable record in the internal list
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, setReusableRecords)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *modelName_param = NULL, *key_param = NULL, *records, records_sub;
  	zval modelName, key;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&key);
  	ZVAL_UNDEF(&records_sub);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(3, 3)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(key)
  		Z_PARAM_ZVAL(records)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 3, 0, &modelName_param, &key_param, &records);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) {
  		zephir_get_strval(&key, key_param);
  	} else {
  		ZEPHIR_INIT_VAR(&key);
  	}
  
  
  	zephir_update_property_array(this_ptr, SL("reusable"), &key, records);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Clears the internal reusable list
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, clearReusableObjects)
  {
  	zval _0;
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&_0);
  
  
  	ZEPHIR_MM_GROW();
  
  	ZEPHIR_INIT_VAR(&_0);
  	array_init(&_0);
  	zephir_update_property_zval(this_ptr, ZEND_STRL("reusable"), &_0);
  	ZEPHIR_MM_RESTORE();
  }
  
  /**
   * Gets belongsTo related records from a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsToRecords)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4;
  	zval modelName, modelRelation, method, keyRelation;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&modelRelation);
  	ZVAL_UNDEF(&method);
  	ZVAL_UNDEF(&keyRelation);
  	ZVAL_UNDEF(&record_sub);
  	ZVAL_UNDEF(&parameters_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  	ZVAL_UNDEF(&_4);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(3, 5)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(modelRelation)
  		Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(parameters)
  		Z_PARAM_STR_OR_NULL(method)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, &parameters, &method_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) {
  		zephir_get_strval(&modelRelation, modelRelation_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelRelation);
  	}
  	if (!parameters) {
  		parameters = &parameters_sub;
  		parameters = &__$null;
  	}
  	if (!method_param) {
  		ZEPHIR_INIT_VAR(&method);
  	} else {
  		zephir_get_strval(&method, method_param);
  	}
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_fast_strtolower(&_0, &modelName);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_fast_strtolower(&_1, &modelRelation);
  	ZEPHIR_INIT_VAR(&_2);
  	ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1);
  	zephir_get_strval(&keyRelation, &_2);
  	ZEPHIR_OBS_VAR(&relations);
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) {
  		RETURN_MM_BOOL(0);
  	}
  	zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1722);
  	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method);
  	zephir_check_call_status();
  	RETURN_MM();
  }
  
  /**
   * Gets hasMany related records from a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyRecords)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4;
  	zval modelName, modelRelation, method, keyRelation;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&modelRelation);
  	ZVAL_UNDEF(&method);
  	ZVAL_UNDEF(&keyRelation);
  	ZVAL_UNDEF(&record_sub);
  	ZVAL_UNDEF(&parameters_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  	ZVAL_UNDEF(&_4);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(3, 5)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(modelRelation)
  		Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(parameters)
  		Z_PARAM_STR_OR_NULL(method)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, &parameters, &method_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) {
  		zephir_get_strval(&modelRelation, modelRelation_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelRelation);
  	}
  	if (!parameters) {
  		parameters = &parameters_sub;
  		parameters = &__$null;
  	}
  	if (!method_param) {
  		ZEPHIR_INIT_VAR(&method);
  	} else {
  		zephir_get_strval(&method, method_param);
  	}
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_fast_strtolower(&_0, &modelName);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_fast_strtolower(&_1, &modelRelation);
  	ZEPHIR_INIT_VAR(&_2);
  	ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1);
  	zephir_get_strval(&keyRelation, &_2);
  	ZEPHIR_OBS_VAR(&relations);
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) {
  		RETURN_MM_BOOL(0);
  	}
  	zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1752);
  	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method);
  	zephir_check_call_status();
  	RETURN_MM();
  }
  
  /**
   * Gets belongsTo related records from a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneRecords)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4;
  	zval modelName, modelRelation, method, keyRelation;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&modelRelation);
  	ZVAL_UNDEF(&method);
  	ZVAL_UNDEF(&keyRelation);
  	ZVAL_UNDEF(&record_sub);
  	ZVAL_UNDEF(&parameters_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  	ZVAL_UNDEF(&_4);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(3, 5)
  		Z_PARAM_STR(modelName)
  		Z_PARAM_STR(modelRelation)
  		Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(parameters)
  		Z_PARAM_STR_OR_NULL(method)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, &parameters, &method_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  	if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) {
  		zephir_get_strval(&modelRelation, modelRelation_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelRelation);
  	}
  	if (!parameters) {
  		parameters = &parameters_sub;
  		parameters = &__$null;
  	}
  	if (!method_param) {
  		ZEPHIR_INIT_VAR(&method);
  	} else {
  		zephir_get_strval(&method, method_param);
  	}
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_fast_strtolower(&_0, &modelName);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_fast_strtolower(&_1, &modelRelation);
  	ZEPHIR_INIT_VAR(&_2);
  	ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1);
  	zephir_get_strval(&keyRelation, &_2);
  	ZEPHIR_OBS_VAR(&relations);
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY);
  	if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) {
  		RETURN_MM_BOOL(0);
  	}
  	zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1782);
  	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method);
  	zephir_check_call_status();
  	RETURN_MM();
  }
  
  /**
   * Gets all the belongsTo relations defined in a model
   *
   *```php
   * $relations = $modelsManager->getBelongsTo(
   *     new Robots()
   * );
   *```
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsTo)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, relations, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) {
  		array_init(return_value);
  		RETURN_MM();
  	}
  	RETURN_CTOR(&relations);
  }
  
  /**
   * Gets hasMany relations defined on a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasMany)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, relations, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) {
  		array_init(return_value);
  		RETURN_MM();
  	}
  	RETURN_CTOR(&relations);
  }
  
  /**
   * Gets hasOne relations defined on a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOne)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, relations, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) {
  		array_init(return_value);
  		RETURN_MM();
  	}
  	RETURN_CTOR(&relations);
  }
  
  /**
   * Gets hasOneThrough relations defined on a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneThrough)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, relations, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) {
  		array_init(return_value);
  		RETURN_MM();
  	}
  	RETURN_CTOR(&relations);
  }
  
  /**
   * Gets hasManyToMany relations defined on a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyToMany)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *model, model_sub, relations, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_get_class(&_1, model, 1);
  	if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) {
  		array_init(return_value);
  		RETURN_MM();
  	}
  	RETURN_CTOR(&relations);
  }
  
  /**
   * Gets hasOne relations defined on a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneAndHasMany)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *model, model_sub, _0, _1;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&model_sub);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &model);
  
  
  	ZEPHIR_CALL_METHOD(&_0, this_ptr, "gethasone", NULL, 0, model);
  	zephir_check_call_status();
  	ZEPHIR_CALL_METHOD(&_1, this_ptr, "gethasmany", NULL, 0, model);
  	zephir_check_call_status();
  	zephir_fast_array_merge(return_value, &_0, &_1);
  	RETURN_MM();
  }
  
  /**
   * Query all the relationships defined on a model
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelations)
  {
  	zval allRelations;
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *modelName_param = NULL, entityName, relations, relation, _0, _3, _6, _9, _12, *_1$$3, _2$$3, *_4$$6, _5$$6, *_7$$9, _8$$9, *_10$$12, _11$$12, *_13$$15, _14$$15;
  	zval modelName;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&modelName);
  	ZVAL_UNDEF(&entityName);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&relation);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_3);
  	ZVAL_UNDEF(&_6);
  	ZVAL_UNDEF(&_9);
  	ZVAL_UNDEF(&_12);
  	ZVAL_UNDEF(&_2$$3);
  	ZVAL_UNDEF(&_5$$6);
  	ZVAL_UNDEF(&_8$$9);
  	ZVAL_UNDEF(&_11$$12);
  	ZVAL_UNDEF(&_14$$15);
  	ZVAL_UNDEF(&allRelations);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_STR(modelName)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &modelName_param);
  	if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) {
  		zephir_get_strval(&modelName, modelName_param);
  	} else {
  		ZEPHIR_INIT_VAR(&modelName);
  	}
  
  
  	ZEPHIR_INIT_VAR(&entityName);
  	zephir_fast_strtolower(&entityName, &modelName);
  	ZEPHIR_INIT_VAR(&allRelations);
  	array_init(&allRelations);
  	ZEPHIR_OBS_VAR(&relations);
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_0, &entityName, 0)) {
  		zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1894);
  		if (Z_TYPE_P(&relations) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _1$$3)
  			{
  				ZEPHIR_INIT_NVAR(&relation);
  				ZVAL_COPY(&relation, _1$$3);
  				zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1892);
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_2$$3, &relations, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_2$$3)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0);
  				zephir_check_call_status();
  					zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1892);
  				ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&relation);
  	}
  	ZEPHIR_OBS_NVAR(&relations);
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_3, &entityName, 0)) {
  		zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1903);
  		if (Z_TYPE_P(&relations) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _4$$6)
  			{
  				ZEPHIR_INIT_NVAR(&relation);
  				ZVAL_COPY(&relation, _4$$6);
  				zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1901);
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_5$$6, &relations, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_5$$6)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0);
  				zephir_check_call_status();
  					zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1901);
  				ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&relation);
  	}
  	ZEPHIR_OBS_NVAR(&relations);
  	zephir_read_property(&_6, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_6, &entityName, 0)) {
  		zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1912);
  		if (Z_TYPE_P(&relations) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _7$$9)
  			{
  				ZEPHIR_INIT_NVAR(&relation);
  				ZVAL_COPY(&relation, _7$$9);
  				zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1910);
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_8$$9, &relations, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_8$$9)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0);
  				zephir_check_call_status();
  					zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1910);
  				ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&relation);
  	}
  	ZEPHIR_OBS_NVAR(&relations);
  	zephir_read_property(&_9, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_9, &entityName, 0)) {
  		zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1921);
  		if (Z_TYPE_P(&relations) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _10$$12)
  			{
  				ZEPHIR_INIT_NVAR(&relation);
  				ZVAL_COPY(&relation, _10$$12);
  				zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1919);
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_11$$12, &relations, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_11$$12)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0);
  				zephir_check_call_status();
  					zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1919);
  				ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&relation);
  	}
  	ZEPHIR_OBS_NVAR(&relations);
  	zephir_read_property(&_12, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_12, &entityName, 0)) {
  		zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1930);
  		if (Z_TYPE_P(&relations) == IS_ARRAY) {
  			ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _13$$15)
  			{
  				ZEPHIR_INIT_NVAR(&relation);
  				ZVAL_COPY(&relation, _13$$15);
  				zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1928);
  			} ZEND_HASH_FOREACH_END();
  		} else {
  			ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0);
  			zephir_check_call_status();
  			while (1) {
  				ZEPHIR_CALL_METHOD(&_14$$15, &relations, "valid", NULL, 0);
  				zephir_check_call_status();
  				if (!zend_is_true(&_14$$15)) {
  					break;
  				}
  				ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0);
  				zephir_check_call_status();
  					zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1928);
  				ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0);
  				zephir_check_call_status();
  			}
  		}
  		ZEPHIR_INIT_NVAR(&relation);
  	}
  	RETURN_CTOR(&allRelations);
  }
  
  /**
   * Query the first relationship defined between two models
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationsBetween)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zval *first_param = NULL, *second_param = NULL, relations, _0, _1, _2, _3, _4, _5, _6, _7;
  	zval first, second, keyRelation;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&first);
  	ZVAL_UNDEF(&second);
  	ZVAL_UNDEF(&keyRelation);
  	ZVAL_UNDEF(&relations);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_1);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_3);
  	ZVAL_UNDEF(&_4);
  	ZVAL_UNDEF(&_5);
  	ZVAL_UNDEF(&_6);
  	ZVAL_UNDEF(&_7);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(2, 2)
  		Z_PARAM_STR(first)
  		Z_PARAM_STR(second)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 2, 0, &first_param, &second_param);
  	if (UNEXPECTED(Z_TYPE_P(first_param) != IS_STRING && Z_TYPE_P(first_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'first' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(first_param) == IS_STRING)) {
  		zephir_get_strval(&first, first_param);
  	} else {
  		ZEPHIR_INIT_VAR(&first);
  	}
  	if (UNEXPECTED(Z_TYPE_P(second_param) != IS_STRING && Z_TYPE_P(second_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'second' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(second_param) == IS_STRING)) {
  		zephir_get_strval(&second, second_param);
  	} else {
  		ZEPHIR_INIT_VAR(&second);
  	}
  
  
  	ZEPHIR_INIT_VAR(&_0);
  	zephir_fast_strtolower(&_0, &first);
  	ZEPHIR_INIT_VAR(&_1);
  	zephir_fast_strtolower(&_1, &second);
  	ZEPHIR_INIT_VAR(&_2);
  	ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1);
  	zephir_get_strval(&keyRelation, &_2);
  	ZEPHIR_OBS_VAR(&relations);
  	zephir_read_property(&_3, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0)) {
  		RETURN_CCTOR(&relations);
  	}
  	ZEPHIR_OBS_NVAR(&relations);
  	zephir_read_property(&_4, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_4, &keyRelation, 0)) {
  		RETURN_CCTOR(&relations);
  	}
  	ZEPHIR_OBS_NVAR(&relations);
  	zephir_read_property(&_5, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_5, &keyRelation, 0)) {
  		RETURN_CCTOR(&relations);
  	}
  	ZEPHIR_OBS_NVAR(&relations);
  	zephir_read_property(&_6, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_6, &keyRelation, 0)) {
  		RETURN_CCTOR(&relations);
  	}
  	ZEPHIR_OBS_NVAR(&relations);
  	zephir_read_property(&_7, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY);
  	if (zephir_array_isset_fetch(&relations, &_7, &keyRelation, 0)) {
  		RETURN_CCTOR(&relations);
  	}
  	RETURN_MM_BOOL(0);
  }
  
  /**
   * Creates a Phalcon\Mvc\Model\Query without execute it
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, createQuery)
  {
  	zval _6;
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zephir_fcall_cache_entry *_3 = NULL;
  	zval *phql_param = NULL, container, query, _0, _5, _7, _1$$3, _2$$3, _4$$3;
  	zval phql;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&phql);
  	ZVAL_UNDEF(&container);
  	ZVAL_UNDEF(&query);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_5);
  	ZVAL_UNDEF(&_7);
  	ZVAL_UNDEF(&_1$$3);
  	ZVAL_UNDEF(&_2$$3);
  	ZVAL_UNDEF(&_4$$3);
  	ZVAL_UNDEF(&_6);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 1)
  		Z_PARAM_STR(phql)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 0, &phql_param);
  	if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) {
  		zephir_get_strval(&phql, phql_param);
  	} else {
  		ZEPHIR_INIT_VAR(&phql);
  	}
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_CPY_WRT(&container, &_0);
  	if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) {
  		ZEPHIR_INIT_VAR(&_1$$3);
  		object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce);
  		ZEPHIR_INIT_VAR(&_4$$3);
  		ZVAL_STRING(&_4$$3, "the services related to the ORM");
  		ZEPHIR_CALL_CE_STATIC(&_2$$3, phalcon_mvc_model_exception_ce, "containerservicenotfound", &_3, 0, &_4$$3);
  		zephir_check_call_status();
  		ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 8, &_2$$3);
  		zephir_check_call_status();
  		zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Manager.zep", 1997);
  		ZEPHIR_MM_RESTORE();
  		return;
  	}
  	ZEPHIR_INIT_VAR(&_6);
  	zephir_create_array(&_6, 2, 0);
  	zephir_array_fast_append(&_6, &phql);
  	zephir_array_fast_append(&_6, &container);
  	ZEPHIR_INIT_VAR(&_7);
  	ZVAL_STRING(&_7, "Phalcon\\Mvc\\Model\\Query");
  	ZEPHIR_CALL_METHOD(&_5, &container, "get", NULL, 0, &_7, &_6);
  	zephir_check_call_status();
  	ZEPHIR_CPY_WRT(&query, &_5);
  	zephir_update_property_zval(this_ptr, ZEND_STRL("lastQuery"), &query);
  	RETURN_CCTOR(&query);
  }
  
  /**
   * Creates a Phalcon\Mvc\Model\Query and execute it
   *
   * ```php
   * $model = new Robots();
   * $manager = $model->getModelsManager();
   *
   * // \Phalcon\Mvc\Model\Resultset\Simple
   * $manager->executeQuery('SELECT * FROM Robots');
   *
   * // \Phalcon\Mvc\Model\Resultset\Complex
   * $manager->executeQuery('SELECT COUNT(type) FROM Robots GROUP BY type');
   *
   * // \Phalcon\Mvc\Model\Query\StatusInterface
   * $manager->executeQuery('INSERT INTO Robots (id) VALUES (1)');
   *
   * // \Phalcon\Mvc\Model\Query\StatusInterface
   * $manager->executeQuery('UPDATE Robots SET id = 0 WHERE id = :id:', ['id' => 1]);
   *
   * // \Phalcon\Mvc\Model\Query\StatusInterface
   * $manager->executeQuery('DELETE FROM Robots WHERE id = :id:', ['id' => 1]);
   * ```
   *
   * @param array|null $placeholders
   * @param array|null $types
   * @return ResultsetInterface|StatusInterface
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, executeQuery)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zval *phql_param = NULL, *placeholders = NULL, placeholders_sub, *types = NULL, types_sub, __$null, query;
  	zval phql;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&phql);
  	ZVAL_UNDEF(&placeholders_sub);
  	ZVAL_UNDEF(&types_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&query);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(1, 3)
  		Z_PARAM_STR(phql)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(placeholders)
  		Z_PARAM_ZVAL(types)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 1, 2, &phql_param, &placeholders, &types);
  	if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) {
  		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string"));
  		RETURN_MM_NULL();
  	}
  	if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) {
  		zephir_get_strval(&phql, phql_param);
  	} else {
  		ZEPHIR_INIT_VAR(&phql);
  	}
  	if (!placeholders) {
  		placeholders = &placeholders_sub;
  		placeholders = &__$null;
  	}
  	if (!types) {
  		types = &types_sub;
  		types = &__$null;
  	}
  
  
  	ZEPHIR_CALL_METHOD(&query, this_ptr, "createquery", NULL, 0, &phql);
  	zephir_check_call_status();
  	if (Z_TYPE_P(placeholders) == IS_ARRAY) {
  		ZEPHIR_CALL_METHOD(NULL, &query, "setbindparams", NULL, 0, placeholders);
  		zephir_check_call_status();
  	}
  	if (Z_TYPE_P(types) == IS_ARRAY) {
  		ZEPHIR_CALL_METHOD(NULL, &query, "setbindtypes", NULL, 0, types);
  		zephir_check_call_status();
  	}
  	ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 0);
  	zephir_check_call_status();
  	RETURN_MM();
  }
  
  /**
   * Creates a Phalcon\Mvc\Model\Query\Builder
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, createBuilder)
  {
  	zval _6;
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zephir_fcall_cache_entry *_3 = NULL;
  	zval *params = NULL, params_sub, __$null, container, _0, _5, _7, _1$$3, _2$$3, _4$$3;
  	zval *this_ptr = getThis();
  
  	ZVAL_UNDEF(&params_sub);
  	ZVAL_NULL(&__$null);
  	ZVAL_UNDEF(&container);
  	ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_5);
  	ZVAL_UNDEF(&_7);
  	ZVAL_UNDEF(&_1$$3);
  	ZVAL_UNDEF(&_2$$3);
  	ZVAL_UNDEF(&_4$$3);
  	ZVAL_UNDEF(&_6);
  #if PHP_VERSION_ID >= 80000
  	bool is_null_true = 1;
  	ZEND_PARSE_PARAMETERS_START(0, 1)
  		Z_PARAM_OPTIONAL
  		Z_PARAM_ZVAL(params)
  	ZEND_PARSE_PARAMETERS_END();
  #endif
  
  
  	ZEPHIR_MM_GROW();
  	zephir_fetch_params(1, 0, 1, &params);
  	if (!params) {
  		params = &params_sub;
  		params = &__$null;
  	}
  
  
  	zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY);
  	ZEPHIR_CPY_WRT(&container, &_0);
  	if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) {
  		ZEPHIR_INIT_VAR(&_1$$3);
  		object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce);
  		ZEPHIR_INIT_VAR(&_4$$3);
  		ZVAL_STRING(&_4$$3, "the services related to the ORM");
  		ZEPHIR_CALL_CE_STATIC(&_2$$3, phalcon_mvc_model_exception_ce, "containerservicenotfound", &_3, 0, &_4$$3);
  		zephir_check_call_status();
  		ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 8, &_2$$3);
  		zephir_check_call_status();
  		zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Manager.zep", 2074);
  		ZEPHIR_MM_RESTORE();
  		return;
  	}
  	ZEPHIR_INIT_VAR(&_6);
  	zephir_create_array(&_6, 2, 0);
  	zephir_array_fast_append(&_6, params);
  	zephir_array_fast_append(&_6, &container);
  	ZEPHIR_INIT_VAR(&_7);
  	ZVAL_STRING(&_7, "Phalcon\\Mvc\\Model\\Query\\Builder");
  	ZEPHIR_CALL_METHOD(&_5, &container, "get", NULL, 0, &_7, &_6);
  	zephir_check_call_status();
  	RETURN_CCTOR(&_5);
  }
  
  /**
   * Returns the last query created or executed in the models manager
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastQuery)
  {
  	zval *this_ptr = getThis();
  
  
  
  	RETURN_MEMBER(getThis(), "lastQuery");
  }
  
  /**
   * Destroys the current PHQL cache
   */
  PHP_METHOD(Phalcon_Mvc_Model_Manager, __destruct)
  {
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  	zend_long ZEPHIR_LAST_CALL_STATUS;
  	zephir_fcall_cache_entry *_0 = NULL;
  	zval *this_ptr = getThis();
  
  
  
  	ZEPHIR_MM_GROW();
  
  	phalcon_orm_destroy_cache();
  	ZEPHIR_CALL_CE_STATIC(NULL, phalcon_mvc_model_query_ce, "clean", &_0, 0);
  	zephir_check_call_status();
  	ZEPHIR_MM_RESTORE();
  }
  
  zend_object *zephir_init_properties_Phalcon_Mvc_Model_Manager(zend_class_entry *class_type)
  {
  		zval _0, _2, _4, _6, _8, _10, _12, _14, _16, _18, _20, _22, _24, _26, _28, _30, _32, _34, _36, _38, _40, _42, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10, _17$$11, _19$$12, _21$$13, _23$$14, _25$$15, _27$$16, _29$$17, _31$$18, _33$$19, _35$$20, _37$$21, _39$$22, _41$$23, _43$$24;
  	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
  		ZVAL_UNDEF(&_0);
  	ZVAL_UNDEF(&_2);
  	ZVAL_UNDEF(&_4);
  	ZVAL_UNDEF(&_6);
  	ZVAL_UNDEF(&_8);
  	ZVAL_UNDEF(&_10);
  	ZVAL_UNDEF(&_12);
  	ZVAL_UNDEF(&_14);
  	ZVAL_UNDEF(&_16);
  	ZVAL_UNDEF(&_18);
  	ZVAL_UNDEF(&_20);
  	ZVAL_UNDEF(&_22);
  	ZVAL_UNDEF(&_24);
  	ZVAL_UNDEF(&_26);
  	ZVAL_UNDEF(&_28);
  	ZVAL_UNDEF(&_30);
  	ZVAL_UNDEF(&_32);
  	ZVAL_UNDEF(&_34);
  	ZVAL_UNDEF(&_36);
  	ZVAL_UNDEF(&_38);
  	ZVAL_UNDEF(&_40);
  	ZVAL_UNDEF(&_42);
  	ZVAL_UNDEF(&_1$$3);
  	ZVAL_UNDEF(&_3$$4);
  	ZVAL_UNDEF(&_5$$5);
  	ZVAL_UNDEF(&_7$$6);
  	ZVAL_UNDEF(&_9$$7);
  	ZVAL_UNDEF(&_11$$8);
  	ZVAL_UNDEF(&_13$$9);
  	ZVAL_UNDEF(&_15$$10);
  	ZVAL_UNDEF(&_17$$11);
  	ZVAL_UNDEF(&_19$$12);
  	ZVAL_UNDEF(&_21$$13);
  	ZVAL_UNDEF(&_23$$14);
  	ZVAL_UNDEF(&_25$$15);
  	ZVAL_UNDEF(&_27$$16);
  	ZVAL_UNDEF(&_29$$17);
  	ZVAL_UNDEF(&_31$$18);
  	ZVAL_UNDEF(&_33$$19);
  	ZVAL_UNDEF(&_35$$20);
  	ZVAL_UNDEF(&_37$$21);
  	ZVAL_UNDEF(&_39$$22);
  	ZVAL_UNDEF(&_41$$23);
  	ZVAL_UNDEF(&_43$$24);
  	
  
  		ZEPHIR_MM_GROW();
  	
  	{
  		zval local_this_ptr, *this_ptr = &local_this_ptr;
  		ZEPHIR_CREATE_OBJECT(this_ptr, class_type);
  		zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("reusable"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_0) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_1$$3);
  			array_init(&_1$$3);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("reusable"), &_1$$3);
  		}
  		zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_2) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_3$$4);
  			array_init(&_3$$4);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("writeConnectionServices"), &_3$$4);
  		}
  		zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("schemas"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_4) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_5$$5);
  			array_init(&_5$$5);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("schemas"), &_5$$5);
  		}
  		zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_6) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_7$$6);
  			array_init(&_7$$6);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sources"), &_7$$6);
  		}
  		zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_8) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_9$$7);
  			array_init(&_9$$7);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("readConnectionServices"), &_9$$7);
  		}
  		zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_10) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_11$$8);
  			array_init(&_11$$8);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modelVisibility"), &_11$$8);
  		}
  		zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_12) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_13$$9);
  			array_init(&_13$$9);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keepSnapshots"), &_13$$9);
  		}
  		zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_14) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_15$$10);
  			array_init(&_15$$10);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("initialized"), &_15$$10);
  		}
  		zephir_read_property_ex(&_16, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_16) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_17$$11);
  			array_init(&_17$$11);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneThroughSingle"), &_17$$11);
  		}
  		zephir_read_property_ex(&_18, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_18) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_19$$12);
  			array_init(&_19$$12);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneThrough"), &_19$$12);
  		}
  		zephir_read_property_ex(&_20, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_20) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_21$$13);
  			array_init(&_21$$13);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneSingle"), &_21$$13);
  		}
  		zephir_read_property_ex(&_22, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_22) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_23$$14);
  			array_init(&_23$$14);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOne"), &_23$$14);
  		}
  		zephir_read_property_ex(&_24, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_24) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_25$$15);
  			array_init(&_25$$15);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManyToManySingle"), &_25$$15);
  		}
  		zephir_read_property_ex(&_26, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_26) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_27$$16);
  			array_init(&_27$$16);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManyToMany"), &_27$$16);
  		}
  		zephir_read_property_ex(&_28, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_28) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_29$$17);
  			array_init(&_29$$17);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManySingle"), &_29$$17);
  		}
  		zephir_read_property_ex(&_30, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_30) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_31$$18);
  			array_init(&_31$$18);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasMany"), &_31$$18);
  		}
  		zephir_read_property_ex(&_32, this_ptr, ZEND_STRL("dynamicUpdate"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_32) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_33$$19);
  			array_init(&_33$$19);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("dynamicUpdate"), &_33$$19);
  		}
  		zephir_read_property_ex(&_34, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_34) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_35$$20);
  			array_init(&_35$$20);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("customEventsManager"), &_35$$20);
  		}
  		zephir_read_property_ex(&_36, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_36) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_37$$21);
  			array_init(&_37$$21);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("belongsToSingle"), &_37$$21);
  		}
  		zephir_read_property_ex(&_38, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_38) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_39$$22);
  			array_init(&_39$$22);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("belongsTo"), &_39$$22);
  		}
  		zephir_read_property_ex(&_40, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_40) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_41$$23);
  			array_init(&_41$$23);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("behaviors"), &_41$$23);
  		}
  		zephir_read_property_ex(&_42, this_ptr, ZEND_STRL("aliases"), PH_NOISY_CC | PH_READONLY);
  		if (Z_TYPE_P(&_42) == IS_NULL) {
  			ZEPHIR_INIT_VAR(&_43$$24);
  			array_init(&_43$$24);
  			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("aliases"), &_43$$24);
  		}
  		ZEPHIR_MM_RESTORE();
  		return Z_OBJ_P(this_ptr);
  	}
  }
  
  