*sigh* - Looked at web site and that is NOT the problem, but this is
not over, it seems.  I ran into it again on some unit tests, and when
using the bake script, I still getting errors on certain tables.  Here
is some output:

Welcome to CakePHP v1.2.1.8004 Console
---------------------------------------------------------------
App : app
Path: /usr/local/apache2/vhosts/dev-obfuscated.com/app
---------------------------------------------------------------
---------------------------------------------------------------
Bake All
---------------------------------------------------------------
Possible Models based on your current database:
1. ArchiveReason
...
15. Vehicle
Enter a number from the list above, type in the name of another model,
or 'q' to exit
[q] > 15
string(7) "Vehicle"
PHP Notice:  Use of undefined constant ‘Vehicle’ - assumed '‘Vehicle’'
in /usr/local/apache2/vhosts/dev-middletennesseeautomall.com/cake/
console/libs/bake.php on line 141

Notice: Use of undefined constant ‘Vehicle’ - assumed '‘Vehicle’' in /
usr/local/apache2/vhosts/dev-middletennesseeautomall.com/cake/console/
libs/bake.php on line 141
Error: Missing database table '‘vehicle’s' for model '‘Vehicle’'
<------- SEE THE TABLE AND MODEL NAME?

The string(7) output is from a var_dump() I inserted to see what might
be going on.  The instrumented code from cake/console/libs/bake.php is
here:

line 137: $modelExists = false;
line 138: $model = $this->_modelName($name);
line 139: if (App::import('Model', $model)) {
line 140:     var_dump($model);
line 141:     $object = new $model();
line 142:     $modelExists = true;
line 143: } else {
line 144:     App::import('Model');
line 145:     $object = new Model(array('name' => $name, 'ds' =>
$ds));
line 146: }

In the PHP Notice, where are the glyphs (smart quotes or whatever they
are) surrounding the model and table name coming from? var_dump() sees
a 7-character string Vehicle.  This error is happening only when
baking on *some* of my tables, not all of them, which led me to think
it had something to do with the table names in MySQL.  I've checked my
ddl script, to make sure they're all being created the same way:

The quotes here are backticks, which should be fine for quoting table
and column names in MySQL.

DROP TABLE IF EXISTS `vehicles`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `vehicles` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `created` datetime default NULL,
  `modified` datetime default NULL,
...
  `description` text,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM CHARSET=utf8;
SET character_set_client = @saved_cs_client;

On some tables, the PHP Notice comes from cake/libs/class_registry.php
(again, I've instrumented a bit to see what is going on). The Notice
is generated from line 139 below:

line 128: if ($model =& $_this->__duplicate($alias, $class)) {
line 129:     $_this->map($alias, $class);
line 130:     return $model;
line 131: }
line 132: echo '$settings variable: ' . (isset($settings) ? print_r
($settings, true) : 'is not set.') . "\n";
line 133: echo __LINE__ . ": Class '${class}' does " . (class_exists
($class) ? '' : 'not ') ."exist.\n";
line 134: echo "Type is '${type}' and class path is ${pluginPath}$
{class}\n";
line 135: if (class_exists($class) || App::import($type, $pluginPath .
$class)) {
libe 136:     echo __LINE__ . ": Class '${class}' does " .
(class_exists($class) ? '' : 'not ') ."exist.\n";
line 137:     var_dump($settings) . "\n";
line 138:     echo 'Class name is ' . (0 === strcmp('Vehicle',
$settings['class']) ? 'Vehicle' : ' not Vehicle') . "\n";
line 139:     ${$class} =& new $class($settings);
line 140:      } elseif ($type === 'Model') {
                   if ($plugin && class_exists($plugin . 'AppModel'))
{
                       $appModel = $plugin . 'AppModel';
                   } else {
                       $appModel = 'AppModel';
                   }
                   $settings['name'] = $class;
                   ${$class} =& new $appModel($settings);
               }

Here is the corresponding output:
Enter a number from the list above, type in the name of another model,
or 'q' to exit
[q] > 2
string(15) "ArchivedVehicle"
$settings variable: Array
(
    [class] => Vehicle
    [alias] => Vehicle
)

133: Class 'Vehicle' does not exist.
Type is 'Model' and class path is Vehicle
136: Class 'Vehicle' does exist.
array(2) {
  ["class"]=>
  string(7) "Vehicle"
  ["alias"]=>
  string(7) "Vehicle"
}
Class name is Vehicle
PHP Notice:  Use of undefined constant ‘Vehicle’ - assumed '‘Vehicle’'
in /usr/local/apache2/vhosts/dev-middletennesseeautomall.com/cake/libs/
class_registry.php on line 139

Notice: Use of undefined constant ‘Vehicle’ - assumed '‘Vehicle’' in /
usr/local/apache2/vhosts/dev-middletennesseeautomall.com/cake/libs/
class_registry.php on line 139
Error: Missing database table '‘vehicle’s' for model 'Vehicle'

Again, the glyphs.  strcmp() in line 138 is binary-safe; I used it to
compare my model name (Vehicle) with the contents of $settings
['class'] .  I see the client character set saves and restores in the
ddl script (which came from mysql_dump), and will look into that, but
I don't see yet what is problematic about certain Model/table names
and not others.

Another pair of fresh eyes anyone?

Thank you!
Clark


On Jan 18, 7:23 pm, clarkphp <[email protected]> wrote:
> Felix mentioned something about fixing this - I'll check to see if it
> has been updated. If not, it'll be my first contribution to the
> manual.
>
> On Jan 18, 6:25 am, AD7six <[email protected]> wrote:
>
> > On Jan 16, 9:49 pm, clarkphp <[email protected]> wrote:
>
> > > Figured it out, with the help of a sharper pair of eyes than mine. It
> > > turns out that the original code did in fact come from a web page -
> > > the CakePHP manual (I copied, pasted, and edited the table name and
> > > other code). When I pasted into my text editor, I didn't notice that
> > > the quote marks were not the regular single quotes. All is good now.
>
> > Please submit an edit correcting the quote marks on the manual.
>
> > Thanks,
>
> > AD
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to