This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

alias problems

By: a guest on Jul 23rd, 2013  |  syntax: PHP  |  size: 0.92 KB  |  views: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. MembersModel:
  2.         public $hasAndBelongsToMany = array(
  3.                 'Event' => array(
  4.                         'className' => 'Event',
  5.                         'unique' => 'keepExisting',
  6.                         'conditions' => array('Event.course_id'=>null),
  7.                 )
  8.         );
  9.  
  10. Produces error:
  11.  
  12. Database Error
  13. Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Event.course_id' in 'where clause'
  14.  
  15. SQL Query: SELECT `EventsMember`.`event_id`
  16. FROM `eventsa7_esa`.`events_members` AS `EventsMember`
  17. WHERE `EventsMember`.`member_id` = 12 AND `Event`.`course_id` IS NULL
  18.  
  19.  
  20.  
  21. I think it should produce this SQL instead (notice additional 3rd line):
  22. SELECT `EventsMember`.`event_id`
  23. FROM `eventsa7_esa`.`events_members` AS `EventsMember`,
  24. `eventsa7_esa`.`events` AS `Event`
  25. WHERE `EventsMember`.`member_id` = 12
  26. AND `Event`.`course_id` IS NULL
  27.  
  28. The code works in SQLite when the MembersModel says:
  29. 'conditions' => array('course_id'=>null),
  30. But does not work in MySQL.
clone this paste RAW Paste Data