Hi group.

New to cake, but I like the concept,  installed, and tried bake.php on
a table in a database, it kept giving me very strange results.

Finally I just went with it to see if I could get things working.

after some other configuration issues, I pointed at my 'questions'
table page. http://myserver/questions/

I received a whole slew of errors, like 'undefined index 'Type'... in
cake/libs/model/dbo/dbo_mysql.php
also an error for 'Null', 'Default',  (each multiple times) and one
time for 'Key'. for each column in the table.

So being a decent debuger, I printed out the data in the database.

mysql> describe questions;
+---------+---------+------+-----+---------+----------------+
| Field   | Type    | Null | Key | Default | Extra          |
+---------+---------+------+-----+---------+----------------+
| id      | int(11) | NO   | PRI | NULL    | auto_increment |
| desc_id | int(11) | NO   | MUL | 0       |                |
+---------+---------+------+-----+---------+----------------+

database: mysql 5.0.22

so as I said, I'm used to debuging, I printed out what the cake file
was seeing:

 describe `questions`

 Array
(
    [0] => Array
        (
            [COLUMN_NAME] => Array
                (
                    [Field] => id
                )

            [COLUMN_TYPE] => Array
                (
                    [Type] => int(11)
                )

            [IS_NULLABLE] => Array
                (
                    [Null] => NO
                )

            [COLUMN_KEY] => Array
                (
                    [Key] => PRI
                )

            [COLUMN_DEFAULT] => Array
                (
                    [Default] =>
                )

            [EXTRA] => Array
                (
                    [Extra] => auto_increment
                )

        )

    [1] => Array
        (
            [COLUMN_NAME] => Array
                (
                    [Field] => desc_id
                )

            [COLUMN_TYPE] => Array
                (
                    [Type] => int(11)
                )

            [IS_NULLABLE] => Array
                (
                    [Null] => NO
                )

            [COLUMN_KEY] => Array
                (
                    [Key] => MUL
                )

            [COLUMN_DEFAULT] => Array
                (
                    [Default] => 0
                )

            [EXTRA] => Array
                (
                    [Extra] =>
                )

        )

)

Wanting to see something real come out, I added the following lines to
dbo_mysql.php file:

in 'foreach ($cols as $column)'

in 'if (isset($column[0]))'

added lines:
    180                           /*
    181                           ** jefkin: fixing describe reading
for MySql 5.0.22
    182                           */
    183                           if ((isset($column['COLUMN_NAME']))
&& (isset($column['COLUMN_TYPE'])) &&
    184                               (isset($column['IS_NULLABLE']))
&&     (isset($column['COLUMN_KEY']))  &&
    185                               (isset($column['EXTRA'])))
    186                           {
    187                             $column[0]['Extra']   =
$column['EXTRA']['Extra'];
    188                             $column[0]['Key']     =
$column['COLUMN_KEY']['Key'];
    189                             $column[0]['Type']    =
$column['COLUMN_TYPE']['Type'];
    190                             $column[0]['Null']      =
$column['IS_NULLABLE']['Null'];
    191                             $column[0]['Default'] =
$column['COLUMN_DEFAULT']['Default'];
    192                           }

note my lines might be off from yours as I still had some debuging
stuff in the file.  But this patch seems to fix
the page lookups, but seems to be missing the name when I run bake.php
again.

So... there you have it, now I've contributed to cake...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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