04.05 php saved
bbun
Tags add more
1.1.14.4757  
Note
bbun did not leave a note
  1. Using scaffolding.
  2. When viewing an entry in contacts I get the following error:
  3.  
  4. 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
  5. 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
  6.  
  7.  
  8. This only occurs with view/edit actions.
  9.  
  10.  
  11. // MY MODEL
  12.  
  13. <?php
  14.  
  15.     class Contact extends AppModel
  16.     {
  17.         var $name = 'Contact';
  18.         var $displayField = 'firmname';
  19.        
  20.         var $hasMany = array('Project');
  21.        
  22.         var $hasAndBelongsToMany = array(
  23.  
  24.                                         'Employers' =>
  25.                                         array('className'    => 'Contact',
  26.                                             'joinTable'      => 'employees',
  27.                                             'foreignKey'     => 'employee_id',
  28.                                             'associationForeignKey' => 'employer_id'
  29.                                                 ),
  30.                                                
  31.                                         'Employees' =>
  32.                                         array('className'    => 'Contact',
  33.                                             'joinTable'      => 'employees',
  34.                                             'foreignKey'     => 'employer_id',
  35.                                             'associationForeignKey' => 'employee_id'
  36.                                                 )
  37.                                                
  38.                                         );
  39.        
  40.     }
  41. ?>
  42.  
  43.  
  44.  
  45.  
  46.  
  47. // DATABASE
  48.  
  49.  
  50. CREATE TABLE `contacts` (
  51.   `id` int(11) unsigned NOT NULL auto_increment,
  52.   `type` enum('Person','Company') collate utf8_unicode_ci NOT NULL,
  53.   `firmname` tinytext collate utf8_unicode_ci NOT NULL,
  54.   `firstname` tinytext collate utf8_unicode_ci NOT NULL,
  55.   `infix` tinytext collate utf8_unicode_ci NOT NULL,
  56.   `lastname` tinytext collate utf8_unicode_ci NOT NULL,
  57.   `street` tinytext collate utf8_unicode_ci NOT NULL,
  58.   `housenumber` varchar(16) character set latin1 collate latin1_general_ci NOT NULL,
  59.   `zipcode` varchar(16) character set latin1 collate latin1_general_ci NOT NULL,
  60.   `city` tinytext collate utf8_unicode_ci NOT NULL,
  61.   `country` tinytext collate utf8_unicode_ci NOT NULL,
  62.   `phone` tinytext collate utf8_unicode_ci NOT NULL,
  63.   `fax` tinytext collate utf8_unicode_ci NOT NULL,
  64.   `mobile` tinytext collate utf8_unicode_ci NOT NULL,
  65.   `url` tinytext character set latin1 collate latin1_general_ci NOT NULL,
  66.   `email` tinytext character set latin1 collate latin1_general_ci NOT NULL,
  67.   `created` datetime NOT NULL,
  68.   `notes` text collate utf8_unicode_ci,
  69.   PRIMARY KEY  (`id`)
  70. ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=10 ;
  71.  
  72.  
  73. CREATE TABLE `employees` (
  74.   `id` int(10) unsigned NOT NULL auto_increment,
  75.   `employer_id` int(10) unsigned NOT NULL,
  76.   `employee_id` int(10) unsigned NOT NULL,
  77.   PRIMARY KEY  (`id`)
  78. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
  79.  
  80.  
  81.  
  82.  
Parsed in 0.122 seconds, using GeSHi 1.0.7.14

Modify this Paste