⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Refining select options for n:n relationship



kde
  • profile picture
  • Member

Posted 16 December 2015 - 19:30 PM

I have 3 tables:
Customers:
customerNumber, contactLastName, contactFirst ….
 
Seats
Seats_ID, Seats_Seaction, Seats_Status ….
 
Customers_seats    to define the relationship
Seats_ID, customerNumber, status, priority
 
 
Here is the function within my .php file
 
public function customers_seats()
{
$crud = new grocery_CRUD();
$crud->set_table('customers');
$where = 'customers_seats.customerNumber != customers.customerNumber';
 
$crud->set_relation_n_n('booked', 'customers_seats', 'seats','customerNumber', 'Seats_ID','Seats_Description', 'priority', $where);
 
$crud->fields('contactLastName', 'contactFirstName','addressLine1','addressLine2', 'phone','city','state', 'postalCode', 'booked');
 
$output = $crud->render();
$this->_display_output($output);
}
 
There are 2 things I am trying to do.
1. Restrict items being displayed for adding the seats to the customer to those not already assigned. I,e 1:n relationship
2. To update the customers_seats.Status when it is assigned to a customer.
Plesae advise how to best implement.
 
 
The above code gives me the following error
Error Number: 1054
Unknown column 'customers_seats.customerNumber' in 'where clause'
SELECT *, Seats_Description as s4320c1c6 FROM `seats` WHERE `customers_seats`.`customerNumber` != `customers`.`customerNumber` ORDER BY `seats`.`Seats_Description`
Filename: C:/WWW/grocerytickets/application/models/Grocery_crud_model.php
Line Number: 373