I’m getting a really strange error.
I’ve consultants and companies in a database. Companies can be clients or companies that external consultants work for.
so Company has many Consultants.
so Consultant has one Company.
Now, I’m trying to create a Booking class where a Consultant is placed withing a Company for a specific period.
So Booking has one Consultant and one Company
And now Company has many Consultants and many Bookings
And now Consultant has one Company and many Bookings
in my database I have
consultant (id, name, company_id)
company (id, name)
booking(id, datetime_start, datetime_end)
bookings_consultants(id, booking_id, consultant_id)
bookings_companies(id, booking_id, company_id)
If I try
$cu = new Consultant();
$co = new Company();;
// ... build $cu and $co from post data
$b = new Booking();
$b->datetime_start = // datetime post data
$b->datetime_end = // datetime post data
$b->save(array($co, $cu));
I get this warning:
A PHP Error was encountered
Severity: Warning
Message: Illegal offset type in isset or empty
Filename: libraries/datamapper.php
Line Number: 4315
And this Error:
Error Number: 1054
Unknown column 'consultant_id' in 'where clause'
SELECT * FROM (`bookings_companies`) WHERE `booking_id` = 42 AND `consultant_id` = 115
Filename: /var/www/testapp/libraries/datamapper.php
Line Number: 4990
* If I remove the direct link between Consultants and Companies it works but then I don’t know which consultants work for which companies.
* why is it looking for a consultant_id in bookings_companies ? The link between consultants and bookings is in bookings_consultants.