On Jan 18, 2008 6:39 PM, foxmask <[EMAIL PROTECTED]> wrote:
>
> Good evening,
> I would like to test if my database table exists or not
> If no, i will display a message to suggest to install the software
> If yes, i will "Route::connect()" to the main page of the software.
>
> I digged on the Model::Schema() but i dunno how to use it nor if it's
> the well way to do the trick.
>
Another way to do it is to use $this->Model->loadInfo(). According to the
function description:
"Returns an array of table metadata (column names and types) from the
database."
So perhaps try with:
if( $this->ModelName->loadInfo() ) {
// table exists
} else {
// table doesn't exist
}
Come to think of it, it may return an empty array which could mean the table
exists but has no columns defined, so try it out and see what the function
returns in all 3 cases (table exists and columns defined, table exists and
no columns defined, table doesn't exist).
HTH,
Gonzalo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---