Hi
I'm trying to build an installation procedure for my site based on
cakephp; thus I have an updates table where information concerning
version updates are stored. However, I need to bootstrap this procedure
so the first thing the installation script does is to check whether the
database exists and the updates table exists (and is not empty): in such
case it's a brand new installation. So I put some of this logic in the
UpdatesController but I have the problem that the model Update cannot
find the table.
Now, what I did, is to create an InstallsController with $uses=null so
that I can perform these bootstrap checks from there. This should be
fine, shouldn't it?
thanks
Lorenzo
Miles J wrote:
Yes like Nabil said, most models should be related to a table. If you
are trying to figure out if a table exists, then you shouldn't have a
model.
Can you explain your situation a bit more?
On Feb 1, 11:16 am, Nabil Alsharif <[email protected]> wrote:
Controllers expect to have a model which in turn expects to have a table
in the DB by default. If you have a controller that doesn't use a model
set $uses to 'null' or an empty array... if you have a model that
doesn't have a datasource then look at $useTable and $schema variables
inhttp://api.cakephp.org/class/model
On Mon, 2010-02-01 at 19:29 +0100, Lorenzo Bettini wrote:
The problem I have with my solution, but I guess it's the same of the
one of the link, is that if I use it inside a controller, I get an error
before even reaching that code, due to a missing table... is there a way
to avoid this?
Of course I need this check for an installation page, which I'm
developing using a controller...
thanks in advance
Lorenzo
Miles J wrote:
You can try this, then see if your table exists within the array.
http://www.milesj.me/blog/read/75/Retrieving-Tables-Within-Your-Cake-...
On Feb 1, 8:27 am, Lorenzo Bettini <[email protected]> wrote:
Hi
is this a correct way of checking whether a table exists?
function check_table_exists($table) {
$dbo = $this->getDataSource();
$result = $dbo->_execute('DESCRIBE '.$table);
return !empty($result);
}
thanks in advance
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
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 [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