Re: Model constructor not being called

2009-02-16 Thread JoshSchramm

ok update number 2.

I dumped a list of included files and it isnt even including the file
that corresponds to this model (which explains why it cant find a
constructor). Back to digging.

On Feb 16, 9:26 am, JoshSchramm  wrote:
> A bit more background. I had this same issue a couple days ago and the
> only way i was able to solve it was to basically rename the model. At
> that time it was a model i had just created so it was no big deal to
> rename, this time though I'm using this all over the place. Even more
> frustrating this model worked on Friday when i went home and no one
> else was working on it. No database changes... im sure something
> changed somewhere but for the life of me i can't find it (nor can
> SVN)
>
> On Feb 16, 9:19 am, JoshSchramm  wrote:
>
> > Hey guys.
>
> > Ive been fighting with a problem for a couple days now and it popped
> > back up this morning.
>
> > I have a class hotel_group_member that is a model. Some relevant info
>
> > filename: hotel_group_member.php
> > classname: HotelGroupMember
> > table: hotel_group_members
>
> > For some reason it isnt getting initialized. I get this error on my
> > landing page for the controller - Undefined property:
> > HotelGroupMember::$table [CORE/cake/libs/model/model.php, line 639]
>
> > I hunted it down a bit and in class_registry this line gets execute - $
> > {$class} =& new $class($settings);
>
> > but it never calls __construct in model.php like every other model
> > does. It just kinda dies there and skips the constructor.
>
> > I dont have the constructor overridden in my class so it should be
> > passing through to AppModel
>
> > Any thoughts?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Re: Model constructor not being called

2009-02-16 Thread JoshSchramm

A bit more background. I had this same issue a couple days ago and the
only way i was able to solve it was to basically rename the model. At
that time it was a model i had just created so it was no big deal to
rename, this time though I'm using this all over the place. Even more
frustrating this model worked on Friday when i went home and no one
else was working on it. No database changes... im sure something
changed somewhere but for the life of me i can't find it (nor can
SVN)



On Feb 16, 9:19 am, JoshSchramm  wrote:
> Hey guys.
>
> Ive been fighting with a problem for a couple days now and it popped
> back up this morning.
>
> I have a class hotel_group_member that is a model. Some relevant info
>
> filename: hotel_group_member.php
> classname: HotelGroupMember
> table: hotel_group_members
>
> For some reason it isnt getting initialized. I get this error on my
> landing page for the controller - Undefined property:
> HotelGroupMember::$table [CORE/cake/libs/model/model.php, line 639]
>
> I hunted it down a bit and in class_registry this line gets execute - $
> {$class} =& new $class($settings);
>
> but it never calls __construct in model.php like every other model
> does. It just kinda dies there and skips the constructor.
>
> I dont have the constructor overridden in my class so it should be
> passing through to AppModel
>
> Any thoughts?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Re: Credit Card Expiration Date Validation

2009-02-16 Thread JoshSchramm

Oh cool i didnt know i could code a custom method and call it from the
validates array. Thats way better than what I've been doing (override
validates.) Thanks.


On Feb 11, 9:37 am, grigri  wrote:
> Here's an excerpt from a model I had for validating this sort of
> thing:
>
> class Order extends AppModel {
>   var $name = "Order";
>
>         var $validate = array(
>                 // ...
>                 'card_valid_from' => array(
>                         'on' => 'card',
>                         'allowEmpty' => false,
>                         'rule' => array('validateRelativeDate', false),
>                         'message' => 'Time travellers are not allowed to shop 
> here'
>                 ),
>                 'card_valid_to' => array(
>                         'on' => 'card',
>                         'allowEmpty' => false,
>                         'rule' => array('validateRelativeDate', true),
>                         'message' => 'That card has expired'
>                 ),
>                 // ...
>         );
>
>         function deconstruct($field, $data) {
>                 if ($field == 'card_valid_from' || $field == 'card_valid_to') 
> {
>                         $data['day'] = '01';
>                 }
>                 return parent::deconstruct($field, $data);
>         }
>
>         function validateRelativeDate($date, $inFuture) {
>                 $now = date('Y-m') . '-01';
>
>                 $date = reset($date);
>
>                 if ($inFuture) {
>                         return $date >= $now;
>                 }
>                 else {
>                         return $date <= $now;
>                 }
>         }
>
> }
>
> The view form elements look like this (excerpt):
>
> echo $form->inputs(array(
>         'legend' => 'Pay by Credit Card',
>         'card_valid_from' => array('type' => 'date', 'dateFormat' => 'MY'),
>         'card_valid_to' => array('type' => 'date', 'dateFormat' => 'MY')
> ));
>
> hth
> grigri
>
> On Feb 10, 7:38 pm, JoshSchramm  wrote:
>
> > Hey all,
>
> > I cant seem to find anything online to explain this so i'm hoping you
> > all can help a bit.
>
> > I am validating credit card information and right now i'm working on
> > ensuring the user enters an expiration date.
> > For this i have to fields one for month and one for year both using
> > $form->input('type'='date')
>
> > When they post the data looks like
> > [ExpirationMonth] { [month]=>XX }, [ExpirationYear] { [year]=>}
>
> > On the back end I'm trying to validate this and it doesnt want to
> > work. My validate array looks like this.
>
> > 'ExpirationMonth.month'=>array(
> >                         'numeric'=>array(
> >                                 'rule'=>'numeric',
> >                                 'allowEmpty'=>false,
> >                                 'required'=>true,
> >                                 'message'=>'ExpirationMonthInvalid'
> >                         ),
> >                         'between'=>array(
> >                                 'rule'=>array('between', 1, 12),
> >                                 'allowEmpty'=>false,
> >                                 'required'=>true,
> >                                 'message'=>'ExpirationMonthInvalid'
> >                         ),
> >                 ),
> >                 'ExpirationYear.year'=>array(
> >                         'notEmpty'=>array(
> >                                 'rule'=>'notEmpty',
> >                                 'allowEmpty'=>false,
> >                                 'required'=>true,
> >                                 'message'=>'ExpirationYearInvalid'
> >                         ),
> >                         'numeric'=>array(
> >                                 'rule'=>'numeric',
> >                                 'allowEmpty'=>false,
> >                                 'required'=>true,
> >                                 'message'=>'ExpirationYearInvalid'
> >                         )
> >                 )
>
> > no matter what i do i don't get an error message back.
>
> > To clarify a bit more i have a 'empty'=>'Choose Month (or year)' in
> > the drop downs so I'm just trying to make sure the user selected
> > something other than that option.
>
> > Any ideas?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Model constructor not being called

2009-02-16 Thread JoshSchramm

Hey guys.

Ive been fighting with a problem for a couple days now and it popped
back up this morning.

I have a class hotel_group_member that is a model. Some relevant info

filename: hotel_group_member.php
classname: HotelGroupMember
table: hotel_group_members

For some reason it isnt getting initialized. I get this error on my
landing page for the controller - Undefined property:
HotelGroupMember::$table [CORE/cake/libs/model/model.php, line 639]

I hunted it down a bit and in class_registry this line gets execute - $
{$class} =& new $class($settings);

but it never calls __construct in model.php like every other model
does. It just kinda dies there and skips the constructor.

I dont have the constructor overridden in my class so it should be
passing through to AppModel

Any thoughts?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Credit Card Expiration Date Validation

2009-02-10 Thread JoshSchramm

Hey all,

I cant seem to find anything online to explain this so i'm hoping you
all can help a bit.

I am validating credit card information and right now i'm working on
ensuring the user enters an expiration date.
For this i have to fields one for month and one for year both using
$form->input('type'='date')

When they post the data looks like
[ExpirationMonth] { [month]=>XX }, [ExpirationYear] { [year]=>}

On the back end I'm trying to validate this and it doesnt want to
work. My validate array looks like this.

'ExpirationMonth.month'=>array(
'numeric'=>array(
'rule'=>'numeric',
'allowEmpty'=>false,
'required'=>true,
'message'=>'ExpirationMonthInvalid'
),
'between'=>array(
'rule'=>array('between', 1, 12),
'allowEmpty'=>false,
'required'=>true,
'message'=>'ExpirationMonthInvalid'
),
),
'ExpirationYear.year'=>array(
'notEmpty'=>array(
'rule'=>'notEmpty',
'allowEmpty'=>false,
'required'=>true,
'message'=>'ExpirationYearInvalid'
),
'numeric'=>array(
'rule'=>'numeric',
'allowEmpty'=>false,
'required'=>true,
'message'=>'ExpirationYearInvalid'
)
)

no matter what i do i don't get an error message back.

To clarify a bit more i have a 'empty'=>'Choose Month (or year)' in
the drop downs so I'm just trying to make sure the user selected
something other than that option.

Any ideas?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Re: Complex Find with HABTM Relationship

2008-10-12 Thread JoshSchramm

Eek that first line was supposed to read Hey all, I'm sorry IF
something like this already exists but I really had
no clue what to search for.

On Oct 12, 10:26 pm, JoshSchramm <[EMAIL PROTECTED]> wrote:
> Hey all, I'm sorry something like this already exists but I really had
> no clue what to search for.
>
> I'm trying to set up a rather complex find. It works something like
> this.
>
> I have users, those users can have friends (think social networking
> esque). Friends is simply a backrefrence to the users table. I.e. my
> join table Friends_Users contains to fields (user_id, friend_id) both
> of which point to the Users table.
>
> Users can have Tips. Therefore Friends have tips.
>
> Relationally
>
> Users HABTM Friends.
> Users HasMany Tips
> Tips BelongsTo Users
>
> I'm trying to do a find that returns all the tips owned by any friend
> of the passed in user as well as any tips owned by the user itself.
>
> The following SQL query works -
>
> SELECT *
> FROM `tips`
> JOIN users ON users.id = tips.user_id
> JOIN friends_users ON tips.user_id = friends_users.friend_id
> WHERE (friends_users.user_id =2 or tips.user_id=2)
> LIMIT 0 , 30
>
> But i have no idea how to do that in cakephp world. I posted this on
> stackoverflow here 
> -http://stackoverflow.com/questions/196488/complex-find-in-cake-php
> - but havent heard much back yet.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~--~~~~--~~--~--~---



Complex Find with HABTM Relationship

2008-10-12 Thread JoshSchramm

Hey all, I'm sorry something like this already exists but I really had
no clue what to search for.

I'm trying to set up a rather complex find. It works something like
this.

I have users, those users can have friends (think social networking
esque). Friends is simply a backrefrence to the users table. I.e. my
join table Friends_Users contains to fields (user_id, friend_id) both
of which point to the Users table.

Users can have Tips. Therefore Friends have tips.

Relationally

Users HABTM Friends.
Users HasMany Tips
Tips BelongsTo Users

I'm trying to do a find that returns all the tips owned by any friend
of the passed in user as well as any tips owned by the user itself.

The following SQL query works -

SELECT *
FROM `tips`
JOIN users ON users.id = tips.user_id
JOIN friends_users ON tips.user_id = friends_users.friend_id
WHERE (friends_users.user_id =2 or tips.user_id=2)
LIMIT 0 , 30

But i have no idea how to do that in cakephp world. I posted this on
stackoverflow here - 
http://stackoverflow.com/questions/196488/complex-find-in-cake-php
- but havent heard much back yet.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~--~~~~--~~--~--~---