I'm trying to execute a bunch of sql from a .sql file from the
console. I was trying to use the query method inside the Model class,
but I keep getting the following error.
Error: Missing database table 'models' for model 'Model'
Below is my code:
<?php
App::import('Core', array('Model'));
class UpgradeShell extends Shell {
var $uses = array();
function main() {
$filename = APP . 'config/sql/upgrade.sql';
if (file_exists($filename)) {
$handle = fopen($filename, "r");
$sql = fread($handle, filesize($filename));
fclose($handle);
echo $sql;
if ($sql) {
//Model::query($sql);
$model = new Model();
//$model->query($sql);
}
}
}
}
?>
When I try Model::query($sql);
I get the following error:
Notice: Undefined property: UpgradeShell::$Model in C:\wamp\www\rx.com
\app\vendors\shells\upgrade.php on line 13
Fatal error: Call to a member function query() on a non-object in C:
\wamp\www\rx.com\app\vendors\shells\upgrade.php on line 13
I don't really need to specify models, I just want to execute the
queries inside the .sql file.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---