After a lot of digging into the core, I found that Cake now uses
PDOStatement->getColumnMeta - http://php.net/manual/en/pdostatement.getcolumnmeta.php
- to determine what tables each column in query results belong to.
Because I had installed PDO MySQL through PECL (which has been
deprecated) instead of using the built-in PDO of the newer PHP's,
getColumnMeta() wasn't getting the table names. CakePHP fortunately
catches this gracefully but it results in what I got - one big array
of fields from all of the associated Models.
Just reconfigured my PHP with --with-pdo-mysql and it now works as it
should.
Hope this helps someone at some point.
Regards,
Bit Santos
On Nov 23, 6:10 pm, bit <bit.san...@gmail.com> wrote:
> Hi guys,
>
> Today I made my first attempt at using 2.x but I've gotten thoroughly
> stuck at what seems to be a bug.
>
> - I have three models: Ticket, Project, User. Ticket belongsTo Project
> and User with no declared parameters.
> - In the Tickets controller, I'm just doing a $this->Ticket->find('all').
>
> - There is currently only one record in the tickets table.
>
> This is what I get from the find():
>
> Array
> (
> [0] => Array
> (
> [id] => 1
> [creator_id] => 1
> [project_id] => 1
> [title] => Fix HTML
> [description] => The HTML is broken.
> [status] => for_moderation
> [priority] => 4
> [impact] => 0
> [resolution] =>
> [affected_files] =>
> [branch_revision] =>
> [created] => 2011-11-23 16:33:17
> [modified] => 2011-11-23 16:33:17
> [name] => Bit Santos
> [active] => 1
> [group_id] => 1
> [soft_limit] => 1
> [limit_active] => 20
> [limit_releasing] => 0
> [email] => f...@example.com
> )
> )
>
> So first of all, you'll see that the resulting fields aren't grouped
> by model - name and email actually belong to User; active, group_id,
> soft_limit, limit_active, limit_releasing belong to Project.
>
> What's going on? All I've done so far is to create the controllers and
> models via console, add index() actions, and create almost-blank view
> templates. I've tried going through what I think are the relevant core
> classes - Model, DboSource - but none of it is looking familiar to me.
>
> Any help would be appreciated.
>
> Thanks!
>
> Regards,
> Bit Santos
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
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
No comments:
Post a Comment