Hi Johnny,
I’m trying to use the set_model function. I am very new to GroceryCrud. Is there any examples how to use this?
I have 3 tables.
Demographics
demo_id (prim)
name
location_id
Location
location_id (prim)
location_name
Visits
visits_id
demo_id
location_id
I want the visits table to show. The person that made the visit. The Location name which the person is from. I needed the Demographics field: Location to be filtered by the where clause. This ultimately made me think of using the set_model.
$crud->where cannot be done cause it only goes by the primary table which is the VISITS table in this case.
so something like
SELECT * FROM visits
INNER JOIN demographics ON visits.demo_id = demographics.demo_id WHERE demographics.location_id=$location
http://www.grocerycrud.com/crud/function_name/set_model—isn’t very helpful.
Is that function get_relation_n_n_unselected_array automatically called?
Do I have to use set_table in my controller? If I don’t use it, I get an error.
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
SHOW COLUMNS FROM
Filename: C:\xampp\htdocs\ci3\system\database\DB_driver.php
Line Number: 330
Thanks~