Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

[HELP] Relation

Hi, Sorry for my English.

There are tables :

catalog_parametrs_names(id, name) | catalog_parametrs_values(id, value) | catalog_parametrs_names_values(id, id_name, id_value) | catalog_parametrs_products(id, id_prod, id_parametrs, id_categories)

Connection between catalogparametrsnames => catalogparametrsvalues => catalogparametrsnamesvalues working, but how to make the connection between the catalogparametrsnamesvalues and catalogparametrsproducts and how to access it.

Please help.

namespace Ashanty\Models;

class CatalogParametersValues extends \Phalcon\Mvc\Model
{
    public $id;
    public $value;

    public function initialize()
    {
        $this->hasManyToMany(
                'id',
                __NAMESPACE__ .'\CatalogParametersNamesValues',
                'id_value',
                'id_name',
                __NAMESPACE__ .'\CatalogParametersNames',
                'id',
                array('alias' => 'value')
            );
    }
}
namespace Ashanty\Models;

class CatalogParametersNames extends \Phalcon\Mvc\Model
{
    public $id;
    public $name;

    public function initialize()
    {
        $this->hasManyToMany(
                'id',
                __NAMESPACE__ .'\CatalogParametersNamesValues',
                'id_name',
                'id_value',
                __NAMESPACE__ .'\CatalogParametersValues',
                'id',
                array('alias' => 'name')
            );
    }
}
namespace Ashanty\Models;

class CatalogParametersNamesValues extends \Phalcon\Mvc\Model
{
    public $id;
    public $id_name;
    public $id_value;

    public function initialize()
    {
        $this->hasManyToMany(
            'id',
            __NAMESPACE__ .'\CatalogParametersProducts',
            'id_parameters',
            'id',
            __NAMESPACE__ .'\CatalogParametersNamesValues',
           'id',
            array('alias' => 'values')
        );
        $this->belongsTo('id_name', __NAMESPACE__.'\CatalogParametersNames', 'id', array('alias' => 'name'));
        $this->belongsTo('id_value', __NAMESPACE__.'\CatalogParametersValues', 'id', array('alias' => 'value'));
    }

}
namespace Ashanty\Models;

class CatalogParametersProducts extends \Phalcon\Mvc\Model
{
    public $id;
    public $id_prod;
    public $id_parameters;
    public $id_categories;

    public function initialize()
    {
        $this->belongsTo('id_prod', __NAMESPACE__ . '\CatalogProducts', 'id', array('alias' => 'products'));
        $this->belongsTo('id_parametrs', __NAMESPACE__ . '\CatalogParametersNamesValues', 'id', array('alias' => 'parameters'));
        $this->belongsTo('id_categories', __NAMESPACE__ . '\CatalogCategories', 'id', array('alias' => 'categories'));
    }
}


202
Accepted
answer
edited Aug '16

I do it yourself . #Closed