Wrongly-formed find() result in 2.0.3

2011-11-23 Thread bit
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Wrongly-formed find() result in 2.0.3

2011-11-23 Thread bit
Heya,

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


HABTM filtering with a binded hasMany

2007-05-01 Thread bit

I've reviewed the previous thread that covered HABTM filtering and got
it to work:
http://groups.google.com/group/cake-php/browse_thread/thread/f23b1825050ad543/e793267f42fa77fd?#e793267f42fa77fd

But if I understand this correctly, using a binded hasOne association
would make the next find only retrieve one of the associated model.
I've tried it and that is what seems to be happening. The problem is
that I need all of the relevant associated model; not just one. So I
tried replacing the hasOne binding with a hasMany binding. There
shouldn't be any other difference in code, right?

What happens is I suddenly get the following error:
SQL Error in model Job: 1109: Unknown table 'JobsTags' in where clause

I've already declared $useTable in the JobsTags class and as I've
mentioned earlier, it already works with a hasOne association.

Any help? :-)
Thanks!

_bit


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Components not loading

2007-04-05 Thread bit

I've don't remember overriding the __construct method and I just
double-checked to confirm that. :-P

Tried printing out the contents of $this-components and all I got was
Session. Next I tried declaring the components array in AppController
and see if that changes anything. It did. No more errors from PHP but
then I find that the Session component is loaded and then the
components in my declared array gets loaded too - the Session
component is added twice.

And the weirdness doesn't stop there, I suddenly get a missing model
error too, even though I've declared the Uses array to use other
models - I created my own Pages controller - but Cake is now looking
for a Pages model (which doesn't exist).

Is it possible that a missing model DB table is causing this? I don't
have direct access to my server and my server sysad is sick and
missing so I can't check that right now.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Components not loading

2007-04-05 Thread bit

 I wondered about that but forgot to directly ask/clarify. If you put
 code in your app controller that relies on something being present, it
 would be a *very good* idea to put what it relies upon in the same
 place ;).

I won't argue with you on that but I was hoping that I wouldn't have
to load components and helpers in controllers that didn't use 'em.
I've moved all of the Component and Helper declarations into
AppController and everything is now working as it should as far as I
can tell. :-)

Many thanks, AD!


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Components not loading

2007-04-04 Thread bit

I have this really weird bug in which my components aren't loading.
The really weird thing is that when I remove a hasMany relationship in
one of the models, this bug goes away.

In models/ride.php :
var $hasMany = array(
'Registration' = array('className' = 'Registration'),
'Item' = array('className' = 'Item')
);

I really don't know what else I should describe about my code without
having to give the entire code of almost all of my models and
controllers.

I've tried debug($this-components) in beforeFilter() in my
AppController and it's confirmed that only the Session component is
loaded. Curiously, I tried debug($this-helpers) too and found that
only the Html helper is loaded. When I remove the entire
aforementioned hasMany array, the components and the helpers load as
they should.

If it's relevant, all of my controllers either use the above model or
use a model that's associated to it in some way. If you need any more
particular info, just ask.

Any help would be appreciated. Thanks!

_bit


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Components not loading

2007-04-04 Thread bit

That's what I thought. I guess it'd be good to point out then that I'm
getting this error:
Fatal error: Call to a member function on a non-object

The line it refers to is: (in a private function that's called in
beforeFilter() of AppController)
return $this-Acl-check($user, $aco);

Another way I tested the components was by doing
if(!isset($this-Acl)) debug('No ACL!');

And when I tried it, I got that debug message.
Any ideas?

Thanks.


On Apr 4, 5:15 pm, AD7six [EMAIL PROTECTED] wrote:
 On 4 abr, 10:27, bit [EMAIL PROTECTED] wrote:

  I have this really weird bug in which my components aren't loading.
  The really weird thing is that when I remove a hasMany relationship in
  one of the models, this bug goes away.

 If cake is about to present you with a missingX error, components
 aren't loaded.

 hth,

 AD


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---