04.05
php
saved
bbun
Note
bbun did not leave a note
bbun did not leave a note
- Using scaffolding.
- When viewing an entry in contacts I get the following error:
- Query: SELECT `Employees`.`id`, `Employees`.`type`, `Employees`.`firmname`, `Employees`.`firstname`, `Employees`.`infix`, `Employees`.`lastname`, `Employees`.`street`, `Employees`.`housenumber`, `Employees`.`zipcode`, `Employees`.`city`, `Employees`.`country`, `Employees`.`phone`, `Employees`.`fax`, `Employees`.`mobile`, `Employees`.`url`, `Employees`.`email`, `Employees`.`created`, `Employees`.`notes` FROM `contacts` AS `Employees` JOIN `employees` ON (`employees`.`employer_id` = 2 AND `employees`.`employee_id` = `Employees`.`id`) WHERE 1 = 1
- Warning: SQL Error: 1066: Not unique table/alias: 'employees' in C:\Program Files\xampp\htdocs\cake\cake\libs\model\datasources\dbo_source.php on line 479
- This only occurs with view/edit actions.
- // MY MODEL
- <?php
- class Contact extends AppModel
- {
- var $name = 'Contact';
- var $displayField = 'firmname';
- 'Employers' =>
- 'joinTable' => 'employees',
- 'foreignKey' => 'employee_id',
- 'associationForeignKey' => 'employer_id'
- ),
- 'Employees' =>
- 'joinTable' => 'employees',
- 'foreignKey' => 'employer_id',
- 'associationForeignKey' => 'employee_id'
- )
- );
- }
- ?>
- // DATABASE
- CREATE TABLE `contacts` (
- `id` int(11) unsigned NOT NULL auto_increment,
- `type` enum('Person','Company') collate utf8_unicode_ci NOT NULL,
- `firmname` tinytext collate utf8_unicode_ci NOT NULL,
- `firstname` tinytext collate utf8_unicode_ci NOT NULL,
- `infix` tinytext collate utf8_unicode_ci NOT NULL,
- `lastname` tinytext collate utf8_unicode_ci NOT NULL,
- `street` tinytext collate utf8_unicode_ci NOT NULL,
- `housenumber` varchar(16) character set latin1 collate latin1_general_ci NOT NULL,
- `zipcode` varchar(16) character set latin1 collate latin1_general_ci NOT NULL,
- `city` tinytext collate utf8_unicode_ci NOT NULL,
- `country` tinytext collate utf8_unicode_ci NOT NULL,
- `phone` tinytext collate utf8_unicode_ci NOT NULL,
- `fax` tinytext collate utf8_unicode_ci NOT NULL,
- `mobile` tinytext collate utf8_unicode_ci NOT NULL,
- `url` tinytext character set latin1 collate latin1_general_ci NOT NULL,
- `email` tinytext character set latin1 collate latin1_general_ci NOT NULL,
- `created` datetime NOT NULL,
- `notes` text collate utf8_unicode_ci,
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=10 ;
- CREATE TABLE `employees` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `employer_id` int(10) unsigned NOT NULL,
- `employee_id` int(10) unsigned NOT NULL,
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
Parsed in 0.122 seconds, using GeSHi 1.0.7.14