Hello,
At the moment i'm using three models, two of them have the same
database and the other one uses a different one.
the center model name is coursedate, a coursedate is linked to a course
(this works) but it's also linked to a user(teacher) but this doesn't
work(from another DB).
here are the model klasses;
<?php
class TblCourseDate extends AppModel {

  var $primaryKey = 'cda_id';
  var $name = 'TblCourseDate';
  var $hasOne = array(
        'TblCourse' => array(
            'className'   => 'TblCourse',
            'foreignKey'  => false,
            'conditions'  => 'TblCourse.crs_id =
TblCourseDate.cda_crs_id'),
        'TblUser' => array(
            'className'   => 'TblUser',
            'foreignKey'  => false,
            'conditions'  => 'TblUser.usr_id =
TblCourseDate.cda_usr_id')
    );
}
?>

<?php
class TblCourse extends AppModel {
  var $primaryKey = 'crs_id';
  var $name = 'TblCourse';
  var $hasOne = array(
        'TblGroup' => array(
            'className'   => 'TblGroup',
            'foreignKey'  => false,
            'conditions'  => 'TblCourse.crs_grp_id = TblGroup.grp_id')
    );
?>

<?php
class TblUser extends AppModel {
  var $useDbConfig = 'tmp';
  var $useTable = 'tbl_users';
        var $name = 'TblUser';
  var $primaryKey = 'usr_id';
?>

controller class
<?php
uses('L10n');
class TblCourseDatesController extends AppController {

        var $name = 'TblCourseDates';

        function index() {
                $this->set('TblCourseDates', $this->TblCourseDate->find('all'));
    $this->set('pagetitle', 'Datums');
        }
?>

it generates these queries but the last one doesn't work/is wrong
        SELECT TblCourseDate.cda_id, TblCourseDate.cda_date,
TblCourseDate.cda_max_students, TblCourseDate.cda_crs_id,
TblCourseDate.cda_usr_id, TblCourseDate.cda_ext_docent,
TblCourse.crs_id, TblCourse.crs_name, TblCourse.crs_desc,
TblCourse.crs_type, TblCourse.crs_grp_id FROM tbl_course_dates
TblCourseDate LEFT JOIN tbl_courses TblCourse ON (TblCourse.crs_id =
TblCourseDate.cda_crs_id) WHERE TblCourseDate.cda_id = 9
(works)

SELECT TblUser.usr_full_name, TblUser.usr_first_name,
TblUser.usr_user_yn, TblUser.usr_active_start, TblUser.usr_last_name,
TblUser.usr_email, TblUser.usr_active_end, TblUser.usr_id,
TblUser.usr_login FROM tbl_users TblUser WHERE TblUser.usr_id =
TblCourseDate.cda_usr_id
(fails)

anyone knows what i'm doing wrong?
thanks in advance



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to