Here are my tables:
DROP TABLE IF EXISTS `countries`;
CREATE TABLE `countries` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(255) collate utf8_bin NOT NULL,
`iso2` varchar(2) collate utf8_bin NOT NULL,
`iso3` varchar(3) collate utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `members`;
CREATE TABLE `members` (
`id` int(11) unsigned NOT NULL auto_increment,
`first_name` varchar(50) collate utf8_bin NOT NULL,
`last_name` varchar(50) collate utf8_bin NOT NULL,
`username` varchar(32) collate utf8_bin NOT NULL,
`password` varchar(32) collate utf8_bin NOT NULL,
`collector_type` enum('BY_TYPE','BY_YEAR') collate utf8_bin NOT NULL,
`country_id` int(10) unsigned NOT NULL,
`state` varchar(100) collate utf8_bin NOT NULL,
`city` varchar(100) collate utf8_bin NOT NULL,
`zip` int(10) unsigned NOT NULL,
`address` varchar(255) collate utf8_bin NOT NULL,
`phone` varchar(50) collate utf8_bin NOT NULL,
`cell_phone` varchar(50) collate utf8_bin NOT NULL,
`email` varchar(255) collate utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Here are my models:
<?php
class Member extends AppModel
{
var $name = 'Member';
/*
var $hasOne = array('Country' =>
array('className' => 'Country',
'conditions' => '',
'order' => '',
'dependent' => false,
'foreignKey' => 'country_id'
)
);
*/
var $validate = array(
'username' => '/[a-z0-9\_\-\.]{6,}$/i',
'password' => VALID_NOT_EMPTY,
'first_name' => VALID_NOT_EMPTY,
'last_name' => VALID_NOT_EMPTY
);
}
?>
<?php
class Country extends AppModel
{
var $name = 'Country';
}
?>
And controller:
<?php
class MembersController extends AppController
{
var $uses = array('Member', 'Country');
function index()
{
$members = $this->Member->findAll();
print_r($members);
}
}
Problem is when I uncomment $hasOne line in Member model
print_r($members); returns nothing.... when is commented out everything
is fine... ofcourse, expect the fact that relationship is not defined??
Can anubody check this and tell me what I'm doing wrong??
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---