I'd suggest running query() against the connection object directly. You can either do:
YourModel::connection()->query('CREATE TABLE ...');
or grab this patch from the 1.1 branch http://github.com/kla/php-activerecord/commit/155078f1 which will let you do:
YourModel::query('CREATE TABLE ...');
Thanks this works.
For anyone that happens to trying to use temporary tables the way I ended up doing it was to call
#create instance of the model
$model_object = new [model_name];
#run the temporary table creation query
$model_object->query($query_1, $query_1_data);
#... the connection to the database is still open so the temporary table is waiting to be used
#create the list of objects of the desired model using the temporary table's data
$record_set = $model_object->find_by_sql($query_2, $query_2_data);
(1-2/2)
Subject: Creating Tables Doesn't Work
I don't know if this is just PDO weirdness or an actual bug. Basically if I do any CREATE TABLE statement though find_by_sql it will fail with:
Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error'
Annoyingly it doesn't elaborate on what the general error is and will in fact create the table - just die immediately afterwards.
E.g.
$sql = 'CREATE TABLE temp_table (SELECT * FROM table)';
$model->find_by_sql($sql);
I suspect it may be down to the statement returning TRUE instead of with records but I don't know why it's throwing an exception.
For a bit of background I was using this to build temporary tables but as normal table creations fails in the same way it seemed like a more salient example.
Any pointers would be hugely helpful.
Thanks