嗨,我从来没有遇到过这类问题。当我做错时请澄清我。我试图生成 2 个有关系的模型,但它没有出现在模型中。这是Db结构。
CREATE TABLE IF NOT EXISTS `property` (
`property_id` int(11) NOT NULL AUTO_INCREMENT,
`ListPrice` int(11) NOT NULL,
`ListingURL` text NOT NULL,
`ProviderName` varchar(255) NOT NULL,
`ProviderURL` text NOT NULL,
`modificationTimestamp` text NOT NULL,
PRIMARY KEY (`property_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `location` (
`loc_id` int(11) NOT NULL AUTO_INCREMENT,
`property_id` int(11) NOT NULL,
`latitude` varchar(255) NOT NULL DEFAULT '0.0000',
`longitude` varchar(255) NOT NULL DEFAULT '0.0000',
PRIMARY KEY (`loc_id`),
KEY `property_id` (`property_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
--
-- Constraints for table `location`
--
ALTER TABLE `location`
ADD CONSTRAINT `location_ibfk_1` FOREIGN KEY (`property_id`)
REFERENCES `property` (`property_id`) ON DELETE CASCADE ON UPDATE CASCADE;
在模型中没有关系:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}