ok, in 3.0 branch this works for me.
class del1 extends \Phalcon\Mvc\Model
{
public function initialize()
{
$this->setSource("delete_1");
$this->hasOne(
["type", "type_2"],
__NAMESPACE__ . "\del2",
["type", "type_2"],
[
"alias" => "kokoRec"
]
);
}
}
class del2 extends \Phalcon\Mvc\Model
{
public function initialize()
{
$this->setSource("delete_2");
}
}
//DB
CREATE TABLE `delete_1` (
`id` int(11) NOT NULL,
`type` int(11) NOT NULL,
`type_2` int(11) NOT NULL,
`name` varchar(222) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `delete_1` (`id`, `type`, `type_2`, `name`) VALUES
(1, 1, 1, 'text for type 1'),
(2, 1, 1, 'text for type 2');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `delete_1`
--
ALTER TABLE `delete_1`
ADD PRIMARY KEY (`id`);
CREATE TABLE `delete_2` (
`id` int(11) NOT NULL,
`type` int(11) NOT NULL,
`type_2` int(11) NOT NULL,
`koko` varchar(111) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `delete_2` (`id`, `type`, `type_2`, `koko`) VALUES
(1, 1, 1, 'this should be type 1 link'),
(2, 2, 2, 'this should be type 2 link');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `delete_2`
--
ALTER TABLE `delete_2`
ADD PRIMARY KEY (`id`);
//and the dump is :
array (size=4)
'id' => int 1
'type' => int 1
'type_2' => int 1
'koko' => string 'this should be type 1 link' (length=26)