Hello everyone,
I need to be able to run queries across several tables. After some research I thought the most comfortable way would be to use temporary tables.
But something goes wrong and I'm starting to think it's a bug, because I found an ugly workaround. Or I'm totally wrong, because I'm a beginner and missing some essential rule.
This controller won't work:
public function my_query()
{
$crud = new grocery_CRUD();
$this->db->query('DROP TABLE IF EXISTS temp');
$this->db->query('CREATE TEMPORARY TABLE temp AS
(SELECT a.foo, b.goo, c.hoo
FROM XYZ a, XYZ b, XYZ c
WHERE a.id = b.a_id
AND b.id = c.b_id)');
$crud->set_table('temp');
$crud->set_primary_key('hoo');
$output = $crud->render();
$this->default_output($output);
}
Fatal error: Uncaught exception 'Exception' with message 'The table name does not exist. Please check you database and try again.'
But it IS working since I created the table "temp" as normal table with just a placeholder column. So: Is this a bug or a feature?
Cheers
P.S.
If someone reads this and has a better idea to query multiple tables, I'm all ears! :)
