In mysql I created a test schema with 2 tables : Table1 and Test1. Test1 has many Table1
I did use developper tools to generate models with the following command :
./phalcon all-models --relations --fk --namespace=Test\\Model
When I instantiate the Objec Table1
new Rag\Model\Table1();
I got the following error :
The method "addForeignKey" doesn't exist on model "Rag\Model\Table1"
And indeed I didn't found any reference to the addForeignKey Method in the doc. Probably a mistake, or an old feature from the developper tools ?
Here is the generated Model :
<?php
namespace Test\Model;
class Table1 extends \Phalcon\Mvc\Model
{
/**
*
* @var integer
*/
public $idtable1;
/**
*
* @var integer
*/
public $test1_idtable1;
/**
*
* @var string
*/
public $url;
/**
* Initialize method for model.
*/
public function initialize()
{
$this->belongsTo("test1_idtable1", "Test1", "idtable1"); $this->addForeignKey("test1_idtable1", "Test1", "idtable1");
}
public function getSource()
{
return 'table1';
}
}