After update from phalcon 2.8 to 3.0.3 and php7.0 i have error InvalidArgumentException: Parameter 'name' must be a string It happend's when try to get belongsTo relation
use Phalcon\Mvc\Model\Resultset\Simple as Resultset;
class Country extends GeonameAbstractModel
{
/**
*
* @var string
*/
protected $iso_alpha2;
/**
*
* @var integer
*/
protected $geonameid;
......
/**
* Initialize method for model.
*/
public function initialize()
{
$this->setSchema("public");
$this->belongsTo('geonameid', 'Geoname', 'geonameid', array('alias' => 'Geoname'));
}
/**
* Virtual method for IDE.
*
* @param mixed $parameters
* @return \Geoname
*/
public function getGeoname($parameters = null)
{
return $this->getRelated('Geoname', $parameters);
}
....
}
class Geoname extends \Phalcon\Mvc\Model
{
public static $lang='en';
/**
*
* @var integer
*/
protected $geonameid;
......
/**
* Initialize method for model.
*/
public function initialize()
{
$this->setSchema("public");
$this->hasMany('geonameid', 'Admin1Codes', 'geonameid', array('alias' => 'Admin1Codes'));
$this->hasMany('geonameid', 'Admin2Codes', 'geonameid', array('alias' => 'Admin2Codes'));
$this->hasMany('geonameid', 'Translate', 'geonameid', array('alias' => 'Translations'));
$this->hasMany('geonameid', 'Continent', 'geonameid', array('alias' => 'ContinentCodes'));
$this->hasMany('geonameid', 'Country', 'geonameid', array('alias' => 'Countryinfo'));
$this->hasMany('geonameid', 'Hierarchy', 'parent_id', array('alias' => 'ParentsHierarchy'));
$this->hasMany('geonameid', 'Hierarchy', 'child_id', array('alias' => 'ChildsHierarchy'));
}
....
}
$country->getGeoname(); //InvalidArgumentException: Parameter 'name' must be a string
All tables exists, this code runs on php 5.6 phalcon 2.8 without problems.