You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* What steps will reproduce the problem?
1. generate models
2. get php errors
* What is the expected output? What do you see instead?
No duplicated class properties, getters, setters when dealing with foreign keys
* What version of the product are you using? On what operating system?
v0.6
* Please provide any additional information below.
-- Example: I have two tables
1. users
2. language
The user table has a column "language" that has a foreign key constraint
referencing the column "id" of the "language" table
-- create table statements
CREATE TABLE IF NOT EXISTS `user` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`salutation` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
`firstname` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
`lastname` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
`confirmed` tinyint(1) NOT NULL DEFAULT '0',
`blocked` tinyint(1) NOT NULL DEFAULT '0',
`language` bigint(20) unsigned NOT NULL DEFAULT '1',
`timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`last_login` timestamp NULL DEFAULT NULL,
`last_login_ip` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`password` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'sha256 hash',
PRIMARY KEY (`id`),
KEY `fk_user_language` (`language`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Main
User Table';
CREATE TABLE IF NOT EXISTS `language` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`iso639_1` varchar(2) COLLATE utf8_bin NOT NULL,
`Name` varchar(128) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `iso639-1_UNIQUE` (`iso639_1`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- problematic code snippeds in the generated model class for table "User"
(full class file attached)
[snip]
/**
* Database var type bigint(20) unsigned
*
* @var int
*/
protected $_Language;
/**
* Parent relation fk_user_language
*
* @var Core_Model_Language
*/
protected $_Language;
[snip]
/**
* Sets column language
*
* @param int $data
* @return Core_Model_User
*/
public function setLanguage($data)
{
$this->_Language = $data;
return $this;
}
/**
* Gets column language
*
* @return int
*/
public function getLanguage()
{
return $this->_Language;
}
/**
* Sets parent relation Language
*
* @param Core_Model_Language $data
* @return Core_Model_User
*/
public function setLanguage(Core_Model_Language $data)
{
$this->_Language = $data;
$primary_key = $data->getPrimaryKey();
if (is_array($primary_key)) {
$primary_key = $primary_key['id'];
}
$this->setLanguage($primary_key);
return $this;
}
/**
* Gets parent Language
*
* @param boolean $load Load the object if it is not already
* @return Core_Model_Language
*/
public function getLanguage($load = true)
{
if ($this->_Language === null && $load) {
$this->getMapper()->loadRelated('FkUserLanguage', $this);
}
return $this->_Language;
}
[snip]
Original issue reported on code.google.com by [email protected] on 25 Sep 2011 at 2:31
Original issue reported on code.google.com by
[email protected]
on 25 Sep 2011 at 2:31Attachments:
The text was updated successfully, but these errors were encountered: