config. Plus when debug=0 it do not refresh cache on next request so
"re-run request" helps only with debug > 0.
In Cake 1.2 you can manually clear config tables cache like this:
function createTable($create) {
$this->query($create); // $create if your CREATE TABLE query
$dataSource = ConnectionManager::getDataSource($config); // $config
is your DB config name, like 'default'
if (!$dataSource->error) {
// CREATE TABLE success
$key = ConnectionManager::getSourceName($dataSource).'_'.$dataSource-
>config['database'].'_list';
$key = preg_replace('/[^A-Za-z0-9_\-.+]/', '_', $key);
Cache::delete($key, '_cake_model_'); // clear DB config cache (list
of tables)
$dataSource->sources(true); // reload db config (populate list of
tables from DB)
return true;
}
// CREATE TABLE fail
return false;
}
Will not work in Cake 1.3
On May 1, 12:07 pm, etipaced <kevindecap...@gmail.com> wrote:
> I am creating an "artificial temp table" dynamically during a single
> page request and need to be able to instantiate a model object using
> this table so I can CRUD it. All of this needs to happen during a
> single page call (i.e. no postback or redirects between table creation
> and model instantiation).
>
> I keep getting "database table for model was not found". The bottom
> line is that Cake is not getting refreshed with the newly added table
> so there's no knowledge of it inside the framework. I proved this by
> manually entering the table name in the ClassRegistry::init() call
> (normally the table name is assigned by variable because the table
> name is dynamically generated, etc.), and then re-running the request
> works no problem.
>
> Answering the obvious, I'm only trying to do this because using
> standard MySQL temp tables don't work in Cake as expected. In other
> words, I can't instantiate a model object using the temp table.
>
> Apparently, there must be some routine which "refreshes" or updates
> the available database tables. Any insight on this is appreciated!
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment