unsubscribe

2010-10-19 Thread d...@freakclimbing.com


Inviato da HTC

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Dates before 1600-01-01 are not recognized by models' date fields?

2010-10-19 Thread Joshua Muheim
Wow... It seems I'm always asking for things I suppose have an easy
answer (but I'm too dumb to find them myself), and then it comes out
that nobody else really knows it as well... ;-)

Thanks for you explanations, cricket! I'm not using any dates in the
past at all in my application, but I stumbled over this oddity when
doing some unit boundary tests with past dates which failed even
though they were valid dates (e.g. -11-11).

On Wed, Oct 20, 2010 at 12:56 AM, cricket  wrote:
> On Tue, Oct 19, 2010 at 6:02 AM, psybear83  wrote:
>> Hi everybody
>>
>> Is there a reason why CakePHP doesn't recognize dates before
>> 1600-01-01? I get a validation error when submitting a date before
>> that (e.g. 1599-31-12 or 1300-11-05).
>
> Use the source, Luke.
> http://api.cakephp.org/view_source/validation/#line-389
>
> --snip--
> $regex['ymd'] =
> '%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.|\\x20)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.|\\x20)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]$%';
> --snip--
>
> Note the "1[6-9]|[2-9]". I believe that's saying, "(1 AND 6-9) OR (1
> AND 2-9), which wouldn't be desirable. Although, if it's supposed to
> be, "1 AND (6-9 OR 2-9) it still doesn't make much sense.
>
> Or maybe it's the "16|[2468][048]|[3579][26])00" part. I'm going
> cross-eyed looking at this.
>
> I figured the trouble would be due to something like this. For routes,
> one can use the built-in $Year, which is a regexp defined as
> "[12][0-9]{3}". So, nothing before year 1000, in that case. I think it
> should be "[12]?[0-9]{3}". But, then that would limit you only to
> dates after 100AD, of course.
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: A little help with auth. :)

2010-10-19 Thread Miles J
Just check $this->params['action'] and do different logic based on
specific actions.

On Oct 19, 7:12 pm, xtraorange  wrote:
> Is there any way to do that at the action level, rather than the
> controller level?  Different actions may have different userlevel
> requirements.
>
> On Oct 19, 7:18 pm, jsalonen  wrote:
>
> > The easiest way to do it is probably simpler than you think: set the
> > $authorize variable of AuthComponent to "controller", and add
> > isAuthorized method to your controllers, kind of like:
>
> > function beforeFilter() {
> >     $this->Auth->authorize = 'controller';
>
> > }
>
> > function isAuthorized() {
> >     // get access level from user's profile
> >     $accessLevel = $this->Auth->user('access_level');
> >     // find the required access level for $this->action
> >    $requiredLevel = xxx($this->action);
> >    return $accessLevel >= $requiredLevel;
>
> > }
>
> > You could implement "xxx" with an array of numbers or what ever you
> > like...
>
> > By the way you could use ACL for the same effect: ACOs don't have to
> > be "actions." They can just as well be user roles, and then you use
> > ACL to check if a given user has access to the required role. More
> > flexible but probably not worth the effort for the simpler cases.
>
> > On Oct 20, 1:48 am, xtraorange  wrote:
>
> > > Howdy all,
>
> > > ACL seems to just be too complicated for what I'm doing, particularly
> > > with all the actions I have... the table is hard to keep organized,
> > > and it's way too hard to edit permissions.  So I'm looking for
> > > something else.
>
> > > The site I'm building has need for multiple user levels, but the user
> > > would only need to belong to one of these levels (for example, user,
> > > moderator, admin, site master).
>
> > > Here's what I'm thinking:
> > > An auth function I can put at the top of an action that I can either
> > > pass a number to, or an array of numbers to, as a minimum "level" for
> > > the user to access that action (or in the case of an array, each level
> > > defined as true/false).  Each user would then simply have a number in
> > > their user data that would indicate their level.
>
> > > Questions:
> > > 1.  Is there anything wrong with this (other than the fact that it
> > > goes against the grain of typical ACL)?
> > > 2.  What would be the easiest way to implement this?  Extend the auth
> > > class with a custom class and add my functions, or a new class, or
> > > just a function?
> > > 3.  Any other suggestions that would handle what I'm looking for that
> > > I'm not considering?
>
> > > Thank you!
> > > xtraorange

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: A little help with auth. :)

2010-10-19 Thread xtraorange
Is there any way to do that at the action level, rather than the
controller level?  Different actions may have different userlevel
requirements.

On Oct 19, 7:18 pm, jsalonen  wrote:
> The easiest way to do it is probably simpler than you think: set the
> $authorize variable of AuthComponent to "controller", and add
> isAuthorized method to your controllers, kind of like:
>
> function beforeFilter() {
>     $this->Auth->authorize = 'controller';
>
> }
>
> function isAuthorized() {
>     // get access level from user's profile
>     $accessLevel = $this->Auth->user('access_level');
>     // find the required access level for $this->action
>    $requiredLevel = xxx($this->action);
>    return $accessLevel >= $requiredLevel;
>
> }
>
> You could implement "xxx" with an array of numbers or what ever you
> like...
>
> By the way you could use ACL for the same effect: ACOs don't have to
> be "actions." They can just as well be user roles, and then you use
> ACL to check if a given user has access to the required role. More
> flexible but probably not worth the effort for the simpler cases.
>
> On Oct 20, 1:48 am, xtraorange  wrote:
>
>
>
>
>
>
>
> > Howdy all,
>
> > ACL seems to just be too complicated for what I'm doing, particularly
> > with all the actions I have... the table is hard to keep organized,
> > and it's way too hard to edit permissions.  So I'm looking for
> > something else.
>
> > The site I'm building has need for multiple user levels, but the user
> > would only need to belong to one of these levels (for example, user,
> > moderator, admin, site master).
>
> > Here's what I'm thinking:
> > An auth function I can put at the top of an action that I can either
> > pass a number to, or an array of numbers to, as a minimum "level" for
> > the user to access that action (or in the case of an array, each level
> > defined as true/false).  Each user would then simply have a number in
> > their user data that would indicate their level.
>
> > Questions:
> > 1.  Is there anything wrong with this (other than the fact that it
> > goes against the grain of typical ACL)?
> > 2.  What would be the easiest way to implement this?  Extend the auth
> > class with a custom class and add my functions, or a new class, or
> > just a function?
> > 3.  Any other suggestions that would handle what I'm looking for that
> > I'm not considering?
>
> > Thank you!
> > xtraorange

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: A little help with auth. :)

2010-10-19 Thread jsalonen
The easiest way to do it is probably simpler than you think: set the
$authorize variable of AuthComponent to "controller", and add
isAuthorized method to your controllers, kind of like:

function beforeFilter() {
$this->Auth->authorize = 'controller';
}

function isAuthorized() {
// get access level from user's profile
$accessLevel = $this->Auth->user('access_level');
// find the required access level for $this->action
   $requiredLevel = xxx($this->action);
   return $accessLevel >= $requiredLevel;
}

You could implement "xxx" with an array of numbers or what ever you
like...

By the way you could use ACL for the same effect: ACOs don't have to
be "actions." They can just as well be user roles, and then you use
ACL to check if a given user has access to the required role. More
flexible but probably not worth the effort for the simpler cases.

On Oct 20, 1:48 am, xtraorange  wrote:
> Howdy all,
>
> ACL seems to just be too complicated for what I'm doing, particularly
> with all the actions I have... the table is hard to keep organized,
> and it's way too hard to edit permissions.  So I'm looking for
> something else.
>
> The site I'm building has need for multiple user levels, but the user
> would only need to belong to one of these levels (for example, user,
> moderator, admin, site master).
>
> Here's what I'm thinking:
> An auth function I can put at the top of an action that I can either
> pass a number to, or an array of numbers to, as a minimum "level" for
> the user to access that action (or in the case of an array, each level
> defined as true/false).  Each user would then simply have a number in
> their user data that would indicate their level.
>
> Questions:
> 1.  Is there anything wrong with this (other than the fact that it
> goes against the grain of typical ACL)?
> 2.  What would be the easiest way to implement this?  Extend the auth
> class with a custom class and add my functions, or a new class, or
> just a function?
> 3.  Any other suggestions that would handle what I'm looking for that
> I'm not considering?
>
> Thank you!
> xtraorange

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Enter directly into the web application via SMS

2010-10-19 Thread jsalonen
Sessions make sense only when the user has to visit more than one
pages, so you must mean something else.

Do you mean to ask how to identify users based on the links they are
sent? One way to do it is to generate a random number or string--let's
call it an "access code"--and store the code in the application and
send a link with the code to the users. When the users enter the
application you use the access code to identify them.

On Oct 19, 12:55 pm, "marco.rizze...@gmail.com"
 wrote:
> Hi
> I have a particular question.
> I have a web mobile application.
> This application has his authentication part (with Auth component).
> Now one features of the web application is that the user in certainly
> situation receives a sms with a link.
> If he clicks on link I must open a session that allows only to view
> the page and then the session must expiry.
> Have someone some suggestion to do this?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


A little help with auth. :)

2010-10-19 Thread xtraorange
Howdy all,

ACL seems to just be too complicated for what I'm doing, particularly
with all the actions I have... the table is hard to keep organized,
and it's way too hard to edit permissions.  So I'm looking for
something else.

The site I'm building has need for multiple user levels, but the user
would only need to belong to one of these levels (for example, user,
moderator, admin, site master).

Here's what I'm thinking:
An auth function I can put at the top of an action that I can either
pass a number to, or an array of numbers to, as a minimum "level" for
the user to access that action (or in the case of an array, each level
defined as true/false).  Each user would then simply have a number in
their user data that would indicate their level.

Questions:
1.  Is there anything wrong with this (other than the fact that it
goes against the grain of typical ACL)?
2.  What would be the easiest way to implement this?  Extend the auth
class with a custom class and add my functions, or a new class, or
just a function?
3.  Any other suggestions that would handle what I'm looking for that
I'm not considering?

Thank you!
xtraorange

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread cricket
On Tue, Oct 19, 2010 at 7:03 PM, cricket  wrote:
> On Tue, Oct 19, 2010 at 5:53 AM, psybear83  wrote:
>> Hi everybody
>>
>> Sorry for this newbish question, but I don't seem to find much about
>> this (although I should, I guess).
>>
>> $m = $this->Model->find(1);
>
> Since when does find() work like that? What version are you using?
>
>> echo $m->data['Model']['something];
>
> How are you getting an object returned from find()? Did I miss something?
>

Whoops! Please disregard. I didn't understand that you were
*suggesting* it be done this way.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread cricket
On Tue, Oct 19, 2010 at 8:30 AM, Joshua Muheim  wrote:
>
> Then I saw that every related model has its own key there, so it makes
> a bit sense. But why is the key in the array the model's name?
> Wouldn't it be better to have the name of the association in there?

What if you have several other models associated by belongsTo (or any
other assoc)?

> Because what when I have multiple associations to the same model? Or a
> HABTM with myself?

The key is the model alias, actually. This is usually the same as the
name. And, if you've got a model associated with itself, you'd do:

(say, for a User model)

$this->hasMany = array(   // or other assoc
   'Friend' => array(
   'className' => 'User',
   

So, when you want to fetch a User's Friends, you're really fetching
other Users. But you refer to them by the alias to avoid confusion
(both for yourself and the DB query).

> Aside of this, I guess retrieving the "immediate" data of the model
> (not of it's related models') should have a special status and should
> be able to be retrieved in a faster way, like the one above...

Meh. Faster, how? It's a few extra keystrokes. And, besides, if all
your other data is going to come to you in an array, why not have it
all there? Besides, having it all together like that allows for
manipulating it with Set class. If some data was in an array, and
other inan object, that wouldn't be possible. Not without adding the
object's data to an array first. And that'd be a bunch of extra
keystrokes.

Personally, I've gotten into the habit of always fetching data into a
variable named $data. No $user = $this->User->find(...) or $post =
...Because then your constantly looking for data in
$user['User'][...], which seems a bit dumb. Or looks that way. But
$data['User'] makes perfect sense.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Redirect in a component

2010-10-19 Thread #2Will

Thanks Okalany,

Actually, i should have worked this out from the page i posted,

>From the cookbook (similar to your code)
function initialize(&$controller, $settings = array()) {
// saving the controller reference for later use
$this->controller =& $controller;
}

But in my tail chasing I'd added further code that was leading to
misinterpreted error messages.  My bad.

Thanks for helping me see.

will


On Oct 19, 6:53 pm, Okalany Daniel  wrote:
> Hi Will,
> I always redirect like this:
>
> $this->controller = null;
> // function run on init
> function startup(&$controller){
> $this->controller = $controller;
>
> }
>
> function someredirect(){
> $this->controller->redirect('/');
>
>
>
> }
> On Tue, Oct 19, 2010 at 10:35 AM, #2Will  wrote:
> > Hi,
>
> > Im trying to redirect from a component, and in the cookbook it says
> > this:
>
> > function redirectSomewhere($value) {
> >                // utilizing a controller method
> >                $this->controller->redirect($value);
> >        }
>
> >http://book.cakephp.org/view/64/Creating-Components
>
> > But that throws an error like this:
> > **
> >  Error:  The component file was not found.
>
> > Error: Create the class RedirectComponent in file: app/controllers/
> > components/redirect.php
>
> >  > class RedirectComponent extends Object {
>
> > }
> > ?>
> > ***
>
> > Can anyone explain why? And what do i do to redirect from my
> > component?
>
> > Thanks!
>
> > Will
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > 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.comFor
> >  more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en
>
> --
> OKALANY DANIEL,
> P.O BOX 26150,
> Kampala.,
> Uganda.http://okasoft.net
> --
> When confronted by our worst nightmares, the choices are few; Fight or
> flight. We hope to find the strength to stand against our fears but
> sometimes, despite ourselves, we run. What if the nightmare gives chase?
> Where can we hide then?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread cricket
On Tue, Oct 19, 2010 at 5:53 AM, psybear83  wrote:
> Hi everybody
>
> Sorry for this newbish question, but I don't seem to find much about
> this (although I should, I guess).
>
> $m = $this->Model->find(1);

Since when does find() work like that? What version are you using?

> echo $m->data['Model']['something];

How are you getting an object returned from find()? Did I miss something?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Dates before 1600-01-01 are not recognized by models' date fields?

2010-10-19 Thread cricket
On Tue, Oct 19, 2010 at 6:02 AM, psybear83  wrote:
> Hi everybody
>
> Is there a reason why CakePHP doesn't recognize dates before
> 1600-01-01? I get a validation error when submitting a date before
> that (e.g. 1599-31-12 or 1300-11-05).

Use the source, Luke.
http://api.cakephp.org/view_source/validation/#line-389

--snip--
$regex['ymd'] =
'%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.|\\x20)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.|\\x20)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]$%';
--snip--

Note the "1[6-9]|[2-9]". I believe that's saying, "(1 AND 6-9) OR (1
AND 2-9), which wouldn't be desirable. Although, if it's supposed to
be, "1 AND (6-9 OR 2-9) it still doesn't make much sense.

Or maybe it's the "16|[2468][048]|[3579][26])00" part. I'm going
cross-eyed looking at this.

I figured the trouble would be due to something like this. For routes,
one can use the built-in $Year, which is a regexp defined as
"[12][0-9]{3}". So, nothing before year 1000, in that case. I think it
should be "[12]?[0-9]{3}". But, then that would limit you only to
dates after 100AD, of course.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Find condition on joined table

2010-10-19 Thread jsalonen
Another possibility is specifying the joins in the find-call
explicitly, like this:

$users = $this->User->find('all', array (
'conditions' => array ('Order.id' => $orderId),
'joins' => array (
array ('alias' => 'Customer', 'table' => 'customers',
'conditions' => 'User.id=Customer.user_id'),
array ('alias' => 'Order', 'table' => 'orders', 'conditions'
=> 'Customer.id=Order.customer_id'),
),
));

...but this is just the sort of manual labor that the ORM was supposed
to handle.

On Oct 18, 5:02 pm, Dan  wrote:
> Hi,
>
> I am trying out CakePHP on an existing (and messy) website to see if
> it is going to be beneficial to use it for the new features from now
> on. I have been creating a test model that allows admin to search
> through users based on various fields (userId, name, email address,
> orderId).
>
> I have 3 tables that are being used for this:
> Users
> Customers
> Orders
>
> Users links to Customers on a 1 to 1 relationship on 'userId',
> Customers links to Orders on a 1 to many relationship on 'customerId'.
>
> The search feature is working correctly, except that I can't figure
> out how to set conditions on the Orders table.
> This is the query I would write normally to get the user who placed a
> certain order:
>
> SELECT * FROM users u
> LEFT JOIN customers c ON u.userId = c.userId
> LEFT JOIN orders o ON o.customerId = c.customerId
> WHERE o.orderId = $orderId.
>
> I have set up models for Users, Customers and Orders, With 'Users
> $hasOne ' referencing Customers, and 'Customers $hasMany' referencing
> Orders.
>
> If the conditions only reference the Users table, the script brings
> out the Orders data correctly, but I can't get it to allow me to
> search for an orderId, as Orders is referenced by Users through
> Customers.
>
> Any help on this would be great, I can upload code if necessary.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Joins destroys conditions?

2010-10-19 Thread cricket
On Tue, Oct 19, 2010 at 4:39 AM, torsten.edelm...@googlemail.com
 wrote:
> I have the following:
>
> A bug has a state and hasandbelongs to many usergroups among other
> things.
> Now, when listing the bugs I used the pagination helper and also give
> the user the ability to filter it by various setting. Works great so
> far. You can filter it by project, you can filter it by state (via the
> state_id property of the bug) and by several other items. Now they
> want it to be filtered by the groups that are responsible for the bug.
> Since this is a HABTM connection I used "joins" to connect up the
> tables.
>
> This is what my $this->paginate looks like:
>
>    [limit] => 10
>    [contain] => Array
>        (
>            [0] => Project
>            [1] => User
>            [2] => Priority
>            [3] => State
>            [Comment] => Array
>                (
>                    [0] => User
>                )
>
>            [4] => Screenshot
>            [5] => Group
>        )
>
>    [conditions] => Array
>        (
>            [Bug.project_id] => 26
>            [Bug.state_id] => 1
>        )
>
>    [Bug] => Array
>        (
>            [joins] => Array
>                (
>                    [0] => Array
>                        (
>                            [table] => bugs_groups
>                            [alias] => BugsGroups
>                            [type] => inner
>                            [conditions] => Array
>                                (
>                                    [0] => BugsGroups.bug_id = Bug.id
>                                )
>
>                        )
>
>                    [1] => Array
>                        (
>                            [table] => groups
>                            [alias] => Group
>                            [type] => inner
>                            [conditions] => Array
>                                (
>                                    [0] => Group.id =
> BugsGroups.group_id
>                                    [Group.id] => 9
>                                )
>
>                        )
>
>                )
>
>        )
>
>
> The strange thing is - as soon as I look for a Group by using the
> "join" it's as if part (but strangely enough not all) of the basic
> conditions are ignored. In fact, the condition for the project_id is
> still honored, but the condition for the state_id is ignored. And I
> can't seem to wrap my head around where the problem lies...
>

It doesn't make sense that you'd have [Group.id] => 9 hard-coded in
there. Is this after you've set further options inside the action?

Anyway, you can, if the controller has both models in its $uses array,
do something like:

public $paginate = array(
'Bug' => array(
'limit' => 10,
'contain' => array(...),
'joins' => array(
array(
'table' => 'bugs_groups'
'alias' => 'BugsGroup'
'type' => 'inner'
'conditions' => array(
'BugsGroup.bug_id' => 'Bug.id'
)
),
array(
'table' => 'groups'
'alias' => 'Group'
'type' => 'inner'
'conditions' => array(
'Group.id' => 'BugsGroup.group_id'
)
)
)
),
'BugsGroup' => array(
'limit' => 10,
'contain' => array(...),
// other info here  
)

);

Then, do $data = $this->paginate('BugsGroup');

Notice that the join-model name should be BugsGroup, although the
table is bugs_groups.

Another thing (and I'm pulling this out of my arse because I've never
tried it), I think you *might* be able to include the limit and
contain options just once, at the same level as 'Bug' & 'BugsGroup'.
Try it and see what happens.

The conditions themselves you'd add to $this->paginate array from
within the action, before calling paginate(). Whether you need to add
them to $this->paginate['Bug'] or at the top level depends on whether
the above suggestion works.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Find condition on joined table

2010-10-19 Thread cricket
On Mon, Oct 18, 2010 at 11:02 AM, Dan  wrote:
> Hi,
>
> I am trying out CakePHP on an existing (and messy) website to see if
> it is going to be beneficial to use it for the new features from now
> on. I have been creating a test model that allows admin to search
> through users based on various fields (userId, name, email address,
> orderId).
>
> I have 3 tables that are being used for this:
> Users
> Customers
> Orders
>
> Users links to Customers on a 1 to 1 relationship on 'userId',
> Customers links to Orders on a 1 to many relationship on 'customerId'.
>
> The search feature is working correctly, except that I can't figure
> out how to set conditions on the Orders table.
> This is the query I would write normally to get the user who placed a
> certain order:
>
> SELECT * FROM users u
> LEFT JOIN customers c ON u.userId = c.userId
> LEFT JOIN orders o ON o.customerId = c.customerId
> WHERE o.orderId = $orderId.
>
> I have set up models for Users, Customers and Orders, With 'Users
> $hasOne ' referencing Customers, and 'Customers $hasMany' referencing
> Orders.
>
> If the conditions only reference the Users table, the script brings
> out the Orders data correctly, but I can't get it to allow me to
> search for an orderId, as Orders is referenced by Users through
> Customers.

I think it would make more sense to search by order_id from the
CustomersController, as the Order is directly asociated with Customer.
You CAN do it from User but it seems less elegant. But you can easily
fetch the User info as well if runningfind() from Customer or Order..
In fact, I'd likely put this in Order model. But, if in Customer
model)

public function fetchByOrderId($order_id = null)
{
return $this->Order->find(
'first',
array(
'conditions' => array(
'Order.id' => $order_id
),
'contain' => array(
'Customer' => array(
'User'
)
)
)
);
}

If you were to run the same find from within the controller, it'd be
$this->Customer->Order->find(...). But it's usually a better idea to
put most of your code in the model. So, with above, $data =
$this->Customer->fetchByOrderId($order_id);

If in Order model:

public function fetch($id = null)
{
return $this->find(
'first',
array(
'conditions' => array(
'Order.id' => $order_id
),
'contain' => array(
'Customer' => array(
'User'
)
)
)
);
}

Note that I'm using the ContainableBehavior here. I recommend it, as
it allows for more control on which data you're fetching than working
with 'recursive' option. For that reason, I generally set it in
AppModel's $actsAs array.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Cache config in core.php

2010-10-19 Thread cricket
On Tue, Oct 19, 2010 at 1:04 PM, Paul Willis  wrote:
> I'm looking into turning on caching for my 1.3.4 site.
>
> In the cookbook 
>  it says "first 
> uncomment and set Configure::Cache.check to true in core.php" but that 
> doesn't appear in my core.php

Perhaps you deleted it. In any case, Configure::write('Cache.check',
true) is what you want. That, and Configure::write('Cache.disable',
false)

> Also while looking at core.php I noticed it's missing the closing ?> php tag 
> is this an error I should report or is this file closed somewhere else in the 
> code?

The stock file does include the closing tag, so, again, perhaps you
(or someone else) deleted it. But its absence is of no consequence. I
generally do not include it because any whitespace after it will often
cause the dreaded "headers already sent" error.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Routing question, need a department name before all URL's

2010-10-19 Thread Sam
What you could do is have your router dynamically get the names of all
controllers and cache them for a certain period of time- then use that
cached lists in your routes... anything that wasn't a controller you
would route as a department. Something like this(not tested...
slightly modified from an implementation I used):

$controllerList = Cache::read('controllers_flatlist', 'default');

if ($controllerList === false) {
$controllers = Configure::listObjects('controller');
foreach($controllers as &$value) {
$value = Inflector::underscore($value);
}

$controlerList = $controllers;
array_push($controlerList, 'sitemap', 'robots', 'sitemap.xml',
'robots.txt');
$controllerList = implode('|', $controlerList);
Cache::write('controllers_flatlist', $controllerList);
Cache::write('controllers_list', $controllers);
}

if(empty($controllers)){
$controllers = Cache::read('controllers_list', 'default');
}

if (empty($controllers)) {
$controllers = Configure::listObjects('controller');
Cache::write('controllers_list', $controllers);
}

foreach($controllers as &$value) {
Router::connect('/:department/'. $value . '/*', array(
'controller' => $value
) , array(
'department' => '(?!' . $controllerList . ')[a-zA-Z0-9\-]+'
));
}



On Oct 19, 10:55 am, ianmcn  wrote:
> I develop an internal booking/asset management system for my work, it
> has data separated by department, but I need a way to have the
> department specified in the URL as the first segment. For example:
>
> /:departmentname/bookings/add
>
> After that, the default cakephp conventions would work fine. At the
> moment I achieve this by having the application in many different
> folders, one for each department - but I know that is a seriously bad
> way to do it - it was just a quick way to achieve something to a
> deadline, but the number of departments is getting out of hand, so I
> want to put this right. Can anyone give me some hints as to what
> routing rules I'd need to do this?
>
> Thanks
>
> Ian McNaught

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Installation problem

2010-10-19 Thread cricket
On Tue, Oct 19, 2010 at 7:37 AM, Tilen Majerle  wrote:
> missing index.php file? :D

Or DirectoryIndex is set to index.html only.

DirectoryIndex index.php index.html

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: need help

2010-10-19 Thread cricket
On Tue, Oct 19, 2010 at 8:25 AM, Sunil Chugh  wrote:
> 'php' is not recognized as an internal or external command,
> operable program or batch file.
> how to remove this error

Is this a Windows setup? That error msg is unfamiliar but it appears
to suggest that you don't have PHP installed.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Routing question, need a department name before all URL's

2010-10-19 Thread cricket
On Tue, Oct 19, 2010 at 11:55 AM, ianmcn  wrote:
> I develop an internal booking/asset management system for my work, it
> has data separated by department, but I need a way to have the
> department specified in the URL as the first segment. For example:
>
> /:departmentname/bookings/add
>
> After that, the default cakephp conventions would work fine. At the
> moment I achieve this by having the application in many different
> folders, one for each department - but I know that is a seriously bad
> way to do it - it was just a quick way to achieve something to a
> deadline, but the number of departments is getting out of hand, so I
> want to put this right. Can anyone give me some hints as to what
> routing rules I'd need to do this?

You're also asking for more problems by having a slug as the first
part of the URL. To do that, you'd have to create routes for every
single action (including admin_*) and include them before this one.
Either that, or your regexp to match on department would have to
include the literal names of all departments, eg:

array('department' => '[foo|bar|this|that|another|and_another]'

That way, the regexp wouldn't match on your other controllers. But you
can probably see that this would be yet another maintenance nightmare.

Better to do this through a single controller. Create a Booking model
and a Department model. That way, it shouldn't matter how many new
departments are added.

BookingsController:

Router::connect(
'/bookings/:dept',
array('controller' => 'bookings', 'action' => 'view'),
array('dept' => '[a-z]+', 'pass' => array('dept')
);

Router::connect(
'/bookings/:dep/addt',
array('controller' => 'bookings', 'action' => 'add'),
array('dept' => '[a-z]+', 'pass' => array('dept')
);

public function view($dept = null) {

public function add($dept = null) {


Note that you wouldn't strictly need to add Department to
BookingsController's $uses array. As long as you properly associate it
with Booking model, you can do $this->Booking->Department->find(...)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread Miles J
You can use read.

$this->read('column');

If the data doesnt exist yet, pass an ID.

$this->read('column', $id);

But usually best to just grab the who result, then use read()
afterwards.

On Oct 19, 8:40 am, Joshua Muheim  wrote:
> Accepted. :-) Thanks for your opinion.
>
> On Tue, Oct 19, 2010 at 5:37 PM, Jeremy Burns | Class Outfit
>
>  wrote:
> > I hate to be contrary, but I disagree. Whatever else you come up with would 
> > be great for some, awkward for others. It works and I think it's very 
> > precise.
>
> > Jeremy Burns
> > Class Outfit
>
> > jeremybu...@classoutfit.com
> >http://www.classoutfit.com
>
> > On 19 Oct 2010, at 16:34, Joshua Muheim wrote:
>
> >> Thanks for your explanations, sounds good. Still I think
> >> $model->data['Model']['field'] is very awkward. ;-)
>
> >> On Tue, Oct 19, 2010 at 4:26 PM, Jeremy Burns | Class Outfit
> >>  wrote:
> >>> I think this is a mute point - it works really well as it is.
>
> >>> If a model has a self join relationship with itself you give it a 
> >>> different model alias, so it will appear with that name in the data 
> >>> array, not the name of the model. For example, an employees table might 
> >>> have a self join to denote a management structure. So the field 
> >>> employees.manager_id would join back onto employees.id. Your model would 
> >>> be something like this:
>
> >>> Employee...
> >>> var $belongsTo => array(
> >>>        'Manager' => array(
> >>>                'className' => 'Employee',
> >>>                'foreignKey' => 'manager_id'
> >>>        )
> >>> );
>
> >>> If you did a find containing the employee and his/her manager, you'd have 
> >>> a whole leaf of data under the Manager key.
>
> >>> This makes much more sense than grouping the data elements by the type of 
> >>> join. It also means that you can change the join type in your model and 
> >>> all of your finds and so on will still work.
>
> >>> Jeremy Burns
> >>> Class Outfit
>
> >>> jeremybu...@classoutfit.com
> >>>http://www.classoutfit.com
>
> >>> On 19 Oct 2010, at 14:59, Joshua Muheim wrote:
>
>  Maybe I don't really understand your point, but as far as I see that's
>  exactly what I've written here:
>
>  Then I saw that every related model has its own key there, so it makes
>  a bit sense. But why is the key in the array the model's name?
>  Wouldn't it be better to have the name of the association in there?
>  Because what when I have multiple associations to the same model? Or a
>  HABTM with myself?
>
>  On Tue, Oct 19, 2010 at 3:56 PM, euromark  
>  wrote:
> > i think you are missing the obvious point
> > is there a reason why this is done this way in cake? yes, there is
> > trust the guys that work with since several years
>
> > one example:
> > you have a BelongsTo relationshop
> > cake can easily get this data as well
>
> > now you can do:
>
> > $this->Model->recursive = 0;
> > $m = $this->Model->findById(1);
> > echo $res['Model']['something];
> > echo $res['OtherModel']['something];
>
> > without any additional stuff going on.
> > thats why you always have the model name first.
>
> > On 19 Okt., 14:30, Joshua Muheim  wrote:
> >> It looks really clumsy to me. What about the following?
>
> >> class AppModel extends Model {
> >>     function data($field) {
> >>         return $this->data[$this->name][$field];
> >>     }
>
> >> }
>
> >> First I was not sure why in the $data array there is a key
> >> 'ModelName', I would have expected something like this:
>
> >> array(
> >>     'id' => 1,
> >>     'name' => 'bla'
> >> )
>
> >> instead of
>
> >> array(
> >>     'ModelName' => array(
> >>         'id' => 1,
> >>         'name' => 'bla'
> >>     )
> >> )
>
> >> Then I saw that every related model has its own key there, so it makes
> >> a bit sense. But why is the key in the array the model's name?
> >> Wouldn't it be better to have the name of the association in there?
> >> Because what when I have multiple associations to the same model? Or a
> >> HABTM with myself?
>
> >> Aside of this, I guess retrieving the "immediate" data of the model
> >> (not of it's related models') should have a special status and should
> >> be able to be retrieved in a faster way, like the one above...
>
> >> On Tue, Oct 19, 2010 at 1:15 PM, euromark  
> >> wrote:
> >>> nope
> >>> but thats already a very neat way to do it
> >>> what is your problem with it?
>
> >>> On 19 Okt., 11:53, psybear83  wrote:
>  Hi everybody
>
>  Sorry for this newbish question, but I don't seem to find much about
>  this (although I should, I guess).
>
>  $m = $this->Model->find(1);
>  echo $m->data['Model']['something];
>
>  Is there a better way of getting a model's data fields instead of
>  this? I always thought this could be done

Re: So methods that are not an action should have a "_" in front of it?

2010-10-19 Thread Miles J
The _ is just to make it easier unlike Symfony:

function executeIndex() { }

Or unlike Zend:

function indexAction() { }

The callbacks are just restricted internally from being called.

On Oct 19, 9:12 am, Joshua Muheim  wrote:
> Hrhr, as said before, I will just have to accept stuff in future. ;-)
>
> On Tue, Oct 19, 2010 at 5:42 PM, Jeremy Burns | Class Outfit
>
>  wrote:
> > Are you rewriting Cake, PHP or just building your own stuff?  ;-)
>
> > Jeremy Burns
> > Class Outfit
>
> > jeremybu...@classoutfit.com
> >http://www.classoutfit.com
>
> > On 19 Oct 2010, at 16:37, Joshua Muheim wrote:
>
> >> Yeah I knew that, but still IMHO they should have been named with a "_" 
> >> prefix.
>
> >> I guess sometimes I'm searching for too much sense in stuff... I'd
> >> rather should just accept it as given and don't think too much about
> >> it... But I often feel like a child: I wanna know WHY something is the
> >> way it is... :-)
>
> >> On Tue, Oct 19, 2010 at 5:05 PM, euromark  
> >> wrote:
> >>> those are callbacks - special methods belonging to the controller
> >>> logic
> >>> thats why
>
> >>> On 19 Okt., 16:07, Joshua Muheim  wrote:
>  OK, so why do several CakePHP methods don't have an underscore? Like
>  beforeFilter()? I know, CakePHP will probably be smart enough to not
>  allow this to be called as an action through the browser, but
>  still...? :-P
>
>  On Tue, Oct 19, 2010 at 4:00 PM, Joshua Muheim  
>  wrote:
> > Thanks for the hint with the components! :-)
>
> > On Tue, Oct 19, 2010 at 3:59 PM, euromark  
> > wrote:
> >> yep, thats right (for example from the acl shell)
> >> or YOU could accidently misinterpret it as an action
>
> >> so either way it is still helpful to use the underscores :)
>
> >> but in most cases you usually can put that could in a component
> >> doesnt have to be a controller _function...
>
> >> On 19 Okt., 15:44, psybear83  wrote:
> >>> As mentioned before, I have taken over an existing CakePHP
> >>> application... and it's not a very good one. I'm working since a month
> >>> or more on things like writing tests (there haven't been any before),
> >>> cleaning and rewriting code etc.
>
> >>> So now I stumbled over some methods in a controller that aren't
> >>> actions, but they don't have underscores "_" in front of their
> >>> names... so I ask you: they *really should have*, right??
>
> >>> I know the conventions, that protected and private methods and
> >>> attributes should have an underscore (or even two in some conventions)
> >>> for visual reasons back from the days of PHP4, but that's not what's
> >>> really important here, right? It's important here because when not
> >>> having an underscore, it will be "mistaken" by CakePHP for an
> >>> available action, right?
>
> >>> So aside from that, are you following the convention mentioned above?
> >>> Should I use it when coding a CakePHP application? Or is it somewhat
> >>> outdated?
>
> >>> Thanks
> >>> Josh
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 
> >> others with their CakePHP related questions.
>
> >> 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 athttp://groups.google.com/group/cake-php?hl=en
>
> >>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> >>> with their CakePHP related questions.
>
> >>> 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 
> >>> athttp://groups.google.com/group/cake-php?hl=en
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> >> with their CakePHP related questions.
>
> >> 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 
> >> athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.goo

Re: How can i Optimize i18n ?

2010-10-19 Thread Miles J
I18n already caches the strings after it has been parsed. Make sure
you actually have caching enabled.

On Oct 19, 10:08 am, Adrian Arnautu  wrote:
> Oh, now I see that you gave us the output, my bad :).
>
> Thank you.
>
> On Tue, Oct 19, 2010 at 8:06 PM, Adrian Arnautu 
> wrote:
>
> > Hi,
>
> > I've not done this yet, I'm thinking to do it (I have also a multilanguage
> > app that needs to be fast), cache the output.
> > I'm not saying to cache every __() result, that will be childish :).
>
> > Maybe your content is in an element, if you can cache it, do it. Maybe you
> > have content that isn't "so dynamic", it can be refreshed every few hours or
> > at some events, try to cache it.
> > When possible, try to remove calls to __() from loops.
>
> > Like I said, so far I haven't done profiling. Can you please tell us, based
> > on your results, what are the most used functions/classes/methods, in
> > general, where are the bottlenecks?
>
> > Thank you,
> > Adrian
>
> > On Tue, Oct 19, 2010 at 12:37 PM, CakeME 
> > wrote:
>
> >> My website is very slow and i managed to install xdebug
> >> And after looking at the profile generated by the xdebug using
> >> kcachedgrind i found i18n::Translate took more inclusive , self and
> >> more counts compare to others
> >> i am thinking what to do how can i optimize this. can some one tell me
> >> how can i do this
>
> >> Here is my generated profile:  http://yfrog.com/f/n8xdebugprofilingp/
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> >> others with their CakePHP related questions.
>
> >> 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.comFor
> >>  more options, visit this group at
> >>http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: How can i Optimize i18n ?

2010-10-19 Thread Adrian Arnautu
Oh, now I see that you gave us the output, my bad :).

Thank you.

On Tue, Oct 19, 2010 at 8:06 PM, Adrian Arnautu wrote:

> Hi,
>
> I've not done this yet, I'm thinking to do it (I have also a multilanguage
> app that needs to be fast), cache the output.
> I'm not saying to cache every __() result, that will be childish :).
>
> Maybe your content is in an element, if you can cache it, do it. Maybe you
> have content that isn't "so dynamic", it can be refreshed every few hours or
> at some events, try to cache it.
> When possible, try to remove calls to __() from loops.
>
> Like I said, so far I haven't done profiling. Can you please tell us, based
> on your results, what are the most used functions/classes/methods, in
> general, where are the bottlenecks?
>
> Thank you,
> Adrian
>
> On Tue, Oct 19, 2010 at 12:37 PM, CakeME 
> wrote:
>
>> My website is very slow and i managed to install xdebug
>> And after looking at the profile generated by the xdebug using
>> kcachedgrind i found i18n::Translate took more inclusive , self and
>> more counts compare to others
>> i am thinking what to do how can i optimize this. can some one tell me
>> how can i do this
>>
>> Here is my generated profile:  http://yfrog.com/f/n8xdebugprofilingp/
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> 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.comFor
>>  more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: How can i Optimize i18n ?

2010-10-19 Thread Adrian Arnautu
Hi,

I've not done this yet, I'm thinking to do it (I have also a multilanguage
app that needs to be fast), cache the output.
I'm not saying to cache every __() result, that will be childish :).

Maybe your content is in an element, if you can cache it, do it. Maybe you
have content that isn't "so dynamic", it can be refreshed every few hours or
at some events, try to cache it.
When possible, try to remove calls to __() from loops.

Like I said, so far I haven't done profiling. Can you please tell us, based
on your results, what are the most used functions/classes/methods, in
general, where are the bottlenecks?

Thank you,
Adrian

On Tue, Oct 19, 2010 at 12:37 PM, CakeME wrote:

> My website is very slow and i managed to install xdebug
> And after looking at the profile generated by the xdebug using
> kcachedgrind i found i18n::Translate took more inclusive , self and
> more counts compare to others
> i am thinking what to do how can i optimize this. can some one tell me
> how can i do this
>
> Here is my generated profile:  http://yfrog.com/f/n8xdebugprofilingp/
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Cache config in core.php

2010-10-19 Thread Paul Willis
I'm looking into turning on caching for my 1.3.4 site.

In the cookbook  
it says "first uncomment and set Configure::Cache.check to true in core.php" 
but that doesn't appear in my core.php

Also while looking at core.php I noticed it's missing the closing ?> php tag is 
this an error I should report or is this file closed somewhere else in the code?

Paul

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: login page Redirection...

2010-10-19 Thread Tilen Majerle
no, just make method in users controller called idk  eg "users_login" and
use this for users login, and admin_login for admin logins with different
redirection after successfull login :D
--
Tilen Majerle
http://majerle.eu



2010/10/19 cakebaker 

> Hi Tilen
> Thanks for reply...
> But Do NOT i need to have  a table called users_posts? and
> controller,model,views for users_posts??
> Where do i need to put users_posts?? posts model or controller??
> thanks for help
>
> On Oct 19, 6:34 am, Tilen Majerle  wrote:
> > hmmmmake new method in posts section called idk users_posts($userid =
> > null)
> >
> > and then get posts from user id
> > --
> > Tilen Majerlehttp://majerle.eu
> >
> > 2010/10/18 cakebaker 
> >
> > > I am trying to learn and work on cakephp FW.
> > > I have a DB with Posts blog.
> > > I have implemented the ACL.
> > > I have Admin and User groups.
> > > When an Admin (some one belongs 2 admin grp) log in he needs to be
> > > redirected to a page where he can see all posts(belongs to all people)
> > > This is working
> > > I have implemented this with the following command in
> > > users_controller.php:
> > > function login() {
> > > if($this->Auth->user('role')=='admin')
> > > {
> > > $this->redirect(array('controller'=>'posts','action' => 'index'));
> > > }
> > > BUT When a user (some 1 belongs to user grp - NOT ADMIN) log in he
> > > needs to be redirected to see ( or redirect to posts page where he can
> > > see only his posts) ONLY his posts not others..
> > > How can I implement this>???
> >
> > > Thanks
> >
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> others
> > > with their CakePHP related questions.
> >
> > > 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
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: login page Redirection...

2010-10-19 Thread cakebaker
Hi Tilen
Thanks for reply...
But Do NOT i need to have  a table called users_posts? and
controller,model,views for users_posts??
Where do i need to put users_posts?? posts model or controller??
thanks for help

On Oct 19, 6:34 am, Tilen Majerle  wrote:
> hmmmmake new method in posts section called idk users_posts($userid =
> null)
>
> and then get posts from user id
> --
> Tilen Majerlehttp://majerle.eu
>
> 2010/10/18 cakebaker 
>
> > I am trying to learn and work on cakephp FW.
> > I have a DB with Posts blog.
> > I have implemented the ACL.
> > I have Admin and User groups.
> > When an Admin (some one belongs 2 admin grp) log in he needs to be
> > redirected to a page where he can see all posts(belongs to all people)
> > This is working
> > I have implemented this with the following command in
> > users_controller.php:
> > function login() {
> > if($this->Auth->user('role')=='admin')
> > {
> > $this->redirect(array('controller'=>'posts','action' => 'index'));
> > }
> > BUT When a user (some 1 belongs to user grp - NOT ADMIN) log in he
> > needs to be redirected to see ( or redirect to posts page where he can
> > see only his posts) ONLY his posts not others..
> > How can I implement this>???
>
> > Thanks
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > 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.comFor
> >  more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: So methods that are not an action should have a "_" in front of it?

2010-10-19 Thread Joshua Muheim
Hrhr, as said before, I will just have to accept stuff in future. ;-)

On Tue, Oct 19, 2010 at 5:42 PM, Jeremy Burns | Class Outfit
 wrote:
> Are you rewriting Cake, PHP or just building your own stuff?  ;-)
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.com
> http://www.classoutfit.com
>
> On 19 Oct 2010, at 16:37, Joshua Muheim wrote:
>
>> Yeah I knew that, but still IMHO they should have been named with a "_" 
>> prefix.
>>
>> I guess sometimes I'm searching for too much sense in stuff... I'd
>> rather should just accept it as given and don't think too much about
>> it... But I often feel like a child: I wanna know WHY something is the
>> way it is... :-)
>>
>> On Tue, Oct 19, 2010 at 5:05 PM, euromark  wrote:
>>> those are callbacks - special methods belonging to the controller
>>> logic
>>> thats why
>>>
>>>
>>> On 19 Okt., 16:07, Joshua Muheim  wrote:
 OK, so why do several CakePHP methods don't have an underscore? Like
 beforeFilter()? I know, CakePHP will probably be smart enough to not
 allow this to be called as an action through the browser, but
 still...? :-P

 On Tue, Oct 19, 2010 at 4:00 PM, Joshua Muheim  wrote:
> Thanks for the hint with the components! :-)

> On Tue, Oct 19, 2010 at 3:59 PM, euromark  
> wrote:
>> yep, thats right (for example from the acl shell)
>> or YOU could accidently misinterpret it as an action

>> so either way it is still helpful to use the underscores :)

>> but in most cases you usually can put that could in a component
>> doesnt have to be a controller _function...

>> On 19 Okt., 15:44, psybear83  wrote:
>>> As mentioned before, I have taken over an existing CakePHP
>>> application... and it's not a very good one. I'm working since a month
>>> or more on things like writing tests (there haven't been any before),
>>> cleaning and rewriting code etc.

>>> So now I stumbled over some methods in a controller that aren't
>>> actions, but they don't have underscores "_" in front of their
>>> names... so I ask you: they *really should have*, right??

>>> I know the conventions, that protected and private methods and
>>> attributes should have an underscore (or even two in some conventions)
>>> for visual reasons back from the days of PHP4, but that's not what's
>>> really important here, right? It's important here because when not
>>> having an underscore, it will be "mistaken" by CakePHP for an
>>> available action, right?

>>> So aside from that, are you following the convention mentioned above?
>>> Should I use it when coding a CakePHP application? Or is it somewhat
>>> outdated?

>>> Thanks
>>> Josh

>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>> with their CakePHP related questions.

>> 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 
>> athttp://groups.google.com/group/cake-php?hl=en
>>>
>>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>>> with their CakePHP related questions.
>>>
>>> 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
>>>
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> 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
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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-

Routing question, need a department name before all URL's

2010-10-19 Thread ianmcn
I develop an internal booking/asset management system for my work, it
has data separated by department, but I need a way to have the
department specified in the URL as the first segment. For example:

/:departmentname/bookings/add

After that, the default cakephp conventions would work fine. At the
moment I achieve this by having the application in many different
folders, one for each department - but I know that is a seriously bad
way to do it - it was just a quick way to achieve something to a
deadline, but the number of departments is getting out of hand, so I
want to put this right. Can anyone give me some hints as to what
routing rules I'd need to do this?

Thanks

Ian McNaught

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: So methods that are not an action should have a "_" in front of it?

2010-10-19 Thread Jeremy Burns | Class Outfit
Are you rewriting Cake, PHP or just building your own stuff?  ;-)

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 19 Oct 2010, at 16:37, Joshua Muheim wrote:

> Yeah I knew that, but still IMHO they should have been named with a "_" 
> prefix.
> 
> I guess sometimes I'm searching for too much sense in stuff... I'd
> rather should just accept it as given and don't think too much about
> it... But I often feel like a child: I wanna know WHY something is the
> way it is... :-)
> 
> On Tue, Oct 19, 2010 at 5:05 PM, euromark  wrote:
>> those are callbacks - special methods belonging to the controller
>> logic
>> thats why
>> 
>> 
>> On 19 Okt., 16:07, Joshua Muheim  wrote:
>>> OK, so why do several CakePHP methods don't have an underscore? Like
>>> beforeFilter()? I know, CakePHP will probably be smart enough to not
>>> allow this to be called as an action through the browser, but
>>> still...? :-P
>>> 
>>> On Tue, Oct 19, 2010 at 4:00 PM, Joshua Muheim  wrote:
 Thanks for the hint with the components! :-)
>>> 
 On Tue, Oct 19, 2010 at 3:59 PM, euromark  
 wrote:
> yep, thats right (for example from the acl shell)
> or YOU could accidently misinterpret it as an action
>>> 
> so either way it is still helpful to use the underscores :)
>>> 
> but in most cases you usually can put that could in a component
> doesnt have to be a controller _function...
>>> 
> On 19 Okt., 15:44, psybear83  wrote:
>> As mentioned before, I have taken over an existing CakePHP
>> application... and it's not a very good one. I'm working since a month
>> or more on things like writing tests (there haven't been any before),
>> cleaning and rewriting code etc.
>>> 
>> So now I stumbled over some methods in a controller that aren't
>> actions, but they don't have underscores "_" in front of their
>> names... so I ask you: they *really should have*, right??
>>> 
>> I know the conventions, that protected and private methods and
>> attributes should have an underscore (or even two in some conventions)
>> for visual reasons back from the days of PHP4, but that's not what's
>> really important here, right? It's important here because when not
>> having an underscore, it will be "mistaken" by CakePHP for an
>> available action, right?
>>> 
>> So aside from that, are you following the convention mentioned above?
>> Should I use it when coding a CakePHP application? Or is it somewhat
>> outdated?
>>> 
>> Thanks
>> Josh
>>> 
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> with their CakePHP related questions.
>>> 
> 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 
> athttp://groups.google.com/group/cake-php?hl=en
>> 
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>> 
>> 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
>> 
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread Joshua Muheim
Accepted. :-) Thanks for your opinion.

On Tue, Oct 19, 2010 at 5:37 PM, Jeremy Burns | Class Outfit
 wrote:
> I hate to be contrary, but I disagree. Whatever else you come up with would 
> be great for some, awkward for others. It works and I think it's very precise.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.com
> http://www.classoutfit.com
>
> On 19 Oct 2010, at 16:34, Joshua Muheim wrote:
>
>> Thanks for your explanations, sounds good. Still I think
>> $model->data['Model']['field'] is very awkward. ;-)
>>
>> On Tue, Oct 19, 2010 at 4:26 PM, Jeremy Burns | Class Outfit
>>  wrote:
>>> I think this is a mute point - it works really well as it is.
>>>
>>> If a model has a self join relationship with itself you give it a different 
>>> model alias, so it will appear with that name in the data array, not the 
>>> name of the model. For example, an employees table might have a self join 
>>> to denote a management structure. So the field employees.manager_id would 
>>> join back onto employees.id. Your model would be something like this:
>>>
>>> Employee...
>>> var $belongsTo => array(
>>>        'Manager' => array(
>>>                'className' => 'Employee',
>>>                'foreignKey' => 'manager_id'
>>>        )
>>> );
>>>
>>> If you did a find containing the employee and his/her manager, you'd have a 
>>> whole leaf of data under the Manager key.
>>>
>>> This makes much more sense than grouping the data elements by the type of 
>>> join. It also means that you can change the join type in your model and all 
>>> of your finds and so on will still work.
>>>
>>> Jeremy Burns
>>> Class Outfit
>>>
>>> jeremybu...@classoutfit.com
>>> http://www.classoutfit.com
>>>
>>> On 19 Oct 2010, at 14:59, Joshua Muheim wrote:
>>>
 Maybe I don't really understand your point, but as far as I see that's
 exactly what I've written here:

 Then I saw that every related model has its own key there, so it makes
 a bit sense. But why is the key in the array the model's name?
 Wouldn't it be better to have the name of the association in there?
 Because what when I have multiple associations to the same model? Or a
 HABTM with myself?

 On Tue, Oct 19, 2010 at 3:56 PM, euromark  
 wrote:
> i think you are missing the obvious point
> is there a reason why this is done this way in cake? yes, there is
> trust the guys that work with since several years
>
> one example:
> you have a BelongsTo relationshop
> cake can easily get this data as well
>
> now you can do:
>
> $this->Model->recursive = 0;
> $m = $this->Model->findById(1);
> echo $res['Model']['something];
> echo $res['OtherModel']['something];
>
> without any additional stuff going on.
> thats why you always have the model name first.
>
>
> On 19 Okt., 14:30, Joshua Muheim  wrote:
>> It looks really clumsy to me. What about the following?
>>
>> class AppModel extends Model {
>>     function data($field) {
>>         return $this->data[$this->name][$field];
>>     }
>>
>> }
>>
>> First I was not sure why in the $data array there is a key
>> 'ModelName', I would have expected something like this:
>>
>> array(
>>     'id' => 1,
>>     'name' => 'bla'
>> )
>>
>> instead of
>>
>> array(
>>     'ModelName' => array(
>>         'id' => 1,
>>         'name' => 'bla'
>>     )
>> )
>>
>> Then I saw that every related model has its own key there, so it makes
>> a bit sense. But why is the key in the array the model's name?
>> Wouldn't it be better to have the name of the association in there?
>> Because what when I have multiple associations to the same model? Or a
>> HABTM with myself?
>>
>> Aside of this, I guess retrieving the "immediate" data of the model
>> (not of it's related models') should have a special status and should
>> be able to be retrieved in a faster way, like the one above...
>>
>> On Tue, Oct 19, 2010 at 1:15 PM, euromark  
>> wrote:
>>> nope
>>> but thats already a very neat way to do it
>>> what is your problem with it?
>>
>>> On 19 Okt., 11:53, psybear83  wrote:
 Hi everybody
>>
 Sorry for this newbish question, but I don't seem to find much about
 this (although I should, I guess).
>>
 $m = $this->Model->find(1);
 echo $m->data['Model']['something];
>>
 Is there a better way of getting a model's data fields instead of
 this? I always thought this could be done with $m->field(), but this
 retrieves the data from the database, what is not what I want.
>>
 Thanks
 Josh
>>
>>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help 
>>> others with their CakePHP related questions.
>>
>>> You received this message because you are su

Re: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread Jeremy Burns | Class Outfit
I hate to be contrary, but I disagree. Whatever else you come up with would be 
great for some, awkward for others. It works and I think it's very precise.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 19 Oct 2010, at 16:34, Joshua Muheim wrote:

> Thanks for your explanations, sounds good. Still I think
> $model->data['Model']['field'] is very awkward. ;-)
> 
> On Tue, Oct 19, 2010 at 4:26 PM, Jeremy Burns | Class Outfit
>  wrote:
>> I think this is a mute point - it works really well as it is.
>> 
>> If a model has a self join relationship with itself you give it a different 
>> model alias, so it will appear with that name in the data array, not the 
>> name of the model. For example, an employees table might have a self join to 
>> denote a management structure. So the field employees.manager_id would join 
>> back onto employees.id. Your model would be something like this:
>> 
>> Employee...
>> var $belongsTo => array(
>>'Manager' => array(
>>'className' => 'Employee',
>>'foreignKey' => 'manager_id'
>>)
>> );
>> 
>> If you did a find containing the employee and his/her manager, you'd have a 
>> whole leaf of data under the Manager key.
>> 
>> This makes much more sense than grouping the data elements by the type of 
>> join. It also means that you can change the join type in your model and all 
>> of your finds and so on will still work.
>> 
>> Jeremy Burns
>> Class Outfit
>> 
>> jeremybu...@classoutfit.com
>> http://www.classoutfit.com
>> 
>> On 19 Oct 2010, at 14:59, Joshua Muheim wrote:
>> 
>>> Maybe I don't really understand your point, but as far as I see that's
>>> exactly what I've written here:
>>> 
>>> Then I saw that every related model has its own key there, so it makes
>>> a bit sense. But why is the key in the array the model's name?
>>> Wouldn't it be better to have the name of the association in there?
>>> Because what when I have multiple associations to the same model? Or a
>>> HABTM with myself?
>>> 
>>> On Tue, Oct 19, 2010 at 3:56 PM, euromark  
>>> wrote:
 i think you are missing the obvious point
 is there a reason why this is done this way in cake? yes, there is
 trust the guys that work with since several years
 
 one example:
 you have a BelongsTo relationshop
 cake can easily get this data as well
 
 now you can do:
 
 $this->Model->recursive = 0;
 $m = $this->Model->findById(1);
 echo $res['Model']['something];
 echo $res['OtherModel']['something];
 
 without any additional stuff going on.
 thats why you always have the model name first.
 
 
 On 19 Okt., 14:30, Joshua Muheim  wrote:
> It looks really clumsy to me. What about the following?
> 
> class AppModel extends Model {
> function data($field) {
> return $this->data[$this->name][$field];
> }
> 
> }
> 
> First I was not sure why in the $data array there is a key
> 'ModelName', I would have expected something like this:
> 
> array(
> 'id' => 1,
> 'name' => 'bla'
> )
> 
> instead of
> 
> array(
> 'ModelName' => array(
> 'id' => 1,
> 'name' => 'bla'
> )
> )
> 
> Then I saw that every related model has its own key there, so it makes
> a bit sense. But why is the key in the array the model's name?
> Wouldn't it be better to have the name of the association in there?
> Because what when I have multiple associations to the same model? Or a
> HABTM with myself?
> 
> Aside of this, I guess retrieving the "immediate" data of the model
> (not of it's related models') should have a special status and should
> be able to be retrieved in a faster way, like the one above...
> 
> On Tue, Oct 19, 2010 at 1:15 PM, euromark  
> wrote:
>> nope
>> but thats already a very neat way to do it
>> what is your problem with it?
> 
>> On 19 Okt., 11:53, psybear83  wrote:
>>> Hi everybody
> 
>>> Sorry for this newbish question, but I don't seem to find much about
>>> this (although I should, I guess).
> 
>>> $m = $this->Model->find(1);
>>> echo $m->data['Model']['something];
> 
>>> Is there a better way of getting a model's data fields instead of
>>> this? I always thought this could be done with $m->field(), but this
>>> retrieves the data from the database, what is not what I want.
> 
>>> Thanks
>>> Josh
> 
>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>> with their CakePHP related questions.
> 
>> 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 

Re: So methods that are not an action should have a "_" in front of it?

2010-10-19 Thread Joshua Muheim
Yeah I knew that, but still IMHO they should have been named with a "_" prefix.

I guess sometimes I'm searching for too much sense in stuff... I'd
rather should just accept it as given and don't think too much about
it... But I often feel like a child: I wanna know WHY something is the
way it is... :-)

On Tue, Oct 19, 2010 at 5:05 PM, euromark  wrote:
> those are callbacks - special methods belonging to the controller
> logic
> thats why
>
>
> On 19 Okt., 16:07, Joshua Muheim  wrote:
>> OK, so why do several CakePHP methods don't have an underscore? Like
>> beforeFilter()? I know, CakePHP will probably be smart enough to not
>> allow this to be called as an action through the browser, but
>> still...? :-P
>>
>> On Tue, Oct 19, 2010 at 4:00 PM, Joshua Muheim  wrote:
>> > Thanks for the hint with the components! :-)
>>
>> > On Tue, Oct 19, 2010 at 3:59 PM, euromark  
>> > wrote:
>> >> yep, thats right (for example from the acl shell)
>> >> or YOU could accidently misinterpret it as an action
>>
>> >> so either way it is still helpful to use the underscores :)
>>
>> >> but in most cases you usually can put that could in a component
>> >> doesnt have to be a controller _function...
>>
>> >> On 19 Okt., 15:44, psybear83  wrote:
>> >>> As mentioned before, I have taken over an existing CakePHP
>> >>> application... and it's not a very good one. I'm working since a month
>> >>> or more on things like writing tests (there haven't been any before),
>> >>> cleaning and rewriting code etc.
>>
>> >>> So now I stumbled over some methods in a controller that aren't
>> >>> actions, but they don't have underscores "_" in front of their
>> >>> names... so I ask you: they *really should have*, right??
>>
>> >>> I know the conventions, that protected and private methods and
>> >>> attributes should have an underscore (or even two in some conventions)
>> >>> for visual reasons back from the days of PHP4, but that's not what's
>> >>> really important here, right? It's important here because when not
>> >>> having an underscore, it will be "mistaken" by CakePHP for an
>> >>> available action, right?
>>
>> >>> So aside from that, are you following the convention mentioned above?
>> >>> Should I use it when coding a CakePHP application? Or is it somewhat
>> >>> outdated?
>>
>> >>> Thanks
>> >>> Josh
>>
>> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>> >> with their CakePHP related questions.
>>
>> >> 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 
>> >> athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread Joshua Muheim
Thanks for your explanations, sounds good. Still I think
$model->data['Model']['field'] is very awkward. ;-)

On Tue, Oct 19, 2010 at 4:26 PM, Jeremy Burns | Class Outfit
 wrote:
> I think this is a mute point - it works really well as it is.
>
> If a model has a self join relationship with itself you give it a different 
> model alias, so it will appear with that name in the data array, not the name 
> of the model. For example, an employees table might have a self join to 
> denote a management structure. So the field employees.manager_id would join 
> back onto employees.id. Your model would be something like this:
>
> Employee...
> var $belongsTo => array(
>        'Manager' => array(
>                'className' => 'Employee',
>                'foreignKey' => 'manager_id'
>        )
> );
>
> If you did a find containing the employee and his/her manager, you'd have a 
> whole leaf of data under the Manager key.
>
> This makes much more sense than grouping the data elements by the type of 
> join. It also means that you can change the join type in your model and all 
> of your finds and so on will still work.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.com
> http://www.classoutfit.com
>
> On 19 Oct 2010, at 14:59, Joshua Muheim wrote:
>
>> Maybe I don't really understand your point, but as far as I see that's
>> exactly what I've written here:
>>
>> Then I saw that every related model has its own key there, so it makes
>> a bit sense. But why is the key in the array the model's name?
>> Wouldn't it be better to have the name of the association in there?
>> Because what when I have multiple associations to the same model? Or a
>> HABTM with myself?
>>
>> On Tue, Oct 19, 2010 at 3:56 PM, euromark  wrote:
>>> i think you are missing the obvious point
>>> is there a reason why this is done this way in cake? yes, there is
>>> trust the guys that work with since several years
>>>
>>> one example:
>>> you have a BelongsTo relationshop
>>> cake can easily get this data as well
>>>
>>> now you can do:
>>>
>>> $this->Model->recursive = 0;
>>> $m = $this->Model->findById(1);
>>> echo $res['Model']['something];
>>> echo $res['OtherModel']['something];
>>>
>>> without any additional stuff going on.
>>> thats why you always have the model name first.
>>>
>>>
>>> On 19 Okt., 14:30, Joshua Muheim  wrote:
 It looks really clumsy to me. What about the following?

 class AppModel extends Model {
     function data($field) {
         return $this->data[$this->name][$field];
     }

 }

 First I was not sure why in the $data array there is a key
 'ModelName', I would have expected something like this:

 array(
     'id' => 1,
     'name' => 'bla'
 )

 instead of

 array(
     'ModelName' => array(
         'id' => 1,
         'name' => 'bla'
     )
 )

 Then I saw that every related model has its own key there, so it makes
 a bit sense. But why is the key in the array the model's name?
 Wouldn't it be better to have the name of the association in there?
 Because what when I have multiple associations to the same model? Or a
 HABTM with myself?

 Aside of this, I guess retrieving the "immediate" data of the model
 (not of it's related models') should have a special status and should
 be able to be retrieved in a faster way, like the one above...

 On Tue, Oct 19, 2010 at 1:15 PM, euromark  
 wrote:
> nope
> but thats already a very neat way to do it
> what is your problem with it?

> On 19 Okt., 11:53, psybear83  wrote:
>> Hi everybody

>> Sorry for this newbish question, but I don't seem to find much about
>> this (although I should, I guess).

>> $m = $this->Model->find(1);
>> echo $m->data['Model']['something];

>> Is there a better way of getting a model's data fields instead of
>> this? I always thought this could be done with $m->field(), but this
>> retrieves the data from the database, what is not what I want.

>> Thanks
>> Josh

> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> with their CakePHP related questions.

> 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 
> athttp://groups.google.com/group/cake-php?hl=en
>>>
>>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>>> with their CakePHP related questions.
>>>
>>> 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...@

Re: So methods that are not an action should have a "_" in front of it?

2010-10-19 Thread euromark
those are callbacks - special methods belonging to the controller
logic
thats why


On 19 Okt., 16:07, Joshua Muheim  wrote:
> OK, so why do several CakePHP methods don't have an underscore? Like
> beforeFilter()? I know, CakePHP will probably be smart enough to not
> allow this to be called as an action through the browser, but
> still...? :-P
>
> On Tue, Oct 19, 2010 at 4:00 PM, Joshua Muheim  wrote:
> > Thanks for the hint with the components! :-)
>
> > On Tue, Oct 19, 2010 at 3:59 PM, euromark  
> > wrote:
> >> yep, thats right (for example from the acl shell)
> >> or YOU could accidently misinterpret it as an action
>
> >> so either way it is still helpful to use the underscores :)
>
> >> but in most cases you usually can put that could in a component
> >> doesnt have to be a controller _function...
>
> >> On 19 Okt., 15:44, psybear83  wrote:
> >>> As mentioned before, I have taken over an existing CakePHP
> >>> application... and it's not a very good one. I'm working since a month
> >>> or more on things like writing tests (there haven't been any before),
> >>> cleaning and rewriting code etc.
>
> >>> So now I stumbled over some methods in a controller that aren't
> >>> actions, but they don't have underscores "_" in front of their
> >>> names... so I ask you: they *really should have*, right??
>
> >>> I know the conventions, that protected and private methods and
> >>> attributes should have an underscore (or even two in some conventions)
> >>> for visual reasons back from the days of PHP4, but that's not what's
> >>> really important here, right? It's important here because when not
> >>> having an underscore, it will be "mistaken" by CakePHP for an
> >>> available action, right?
>
> >>> So aside from that, are you following the convention mentioned above?
> >>> Should I use it when coding a CakePHP application? Or is it somewhat
> >>> outdated?
>
> >>> Thanks
> >>> Josh
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> >> with their CakePHP related questions.
>
> >> 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 
> >> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread Jeremy Burns | Class Outfit
I think this is a mute point - it works really well as it is.

If a model has a self join relationship with itself you give it a different 
model alias, so it will appear with that name in the data array, not the name 
of the model. For example, an employees table might have a self join to denote 
a management structure. So the field employees.manager_id would join back onto 
employees.id. Your model would be something like this:

Employee...
var $belongsTo => array(
'Manager' => array(
'className' => 'Employee',
'foreignKey' => 'manager_id'
)
);

If you did a find containing the employee and his/her manager, you'd have a 
whole leaf of data under the Manager key.

This makes much more sense than grouping the data elements by the type of join. 
It also means that you can change the join type in your model and all of your 
finds and so on will still work.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 19 Oct 2010, at 14:59, Joshua Muheim wrote:

> Maybe I don't really understand your point, but as far as I see that's
> exactly what I've written here:
> 
> Then I saw that every related model has its own key there, so it makes
> a bit sense. But why is the key in the array the model's name?
> Wouldn't it be better to have the name of the association in there?
> Because what when I have multiple associations to the same model? Or a
> HABTM with myself?
> 
> On Tue, Oct 19, 2010 at 3:56 PM, euromark  wrote:
>> i think you are missing the obvious point
>> is there a reason why this is done this way in cake? yes, there is
>> trust the guys that work with since several years
>> 
>> one example:
>> you have a BelongsTo relationshop
>> cake can easily get this data as well
>> 
>> now you can do:
>> 
>> $this->Model->recursive = 0;
>> $m = $this->Model->findById(1);
>> echo $res['Model']['something];
>> echo $res['OtherModel']['something];
>> 
>> without any additional stuff going on.
>> thats why you always have the model name first.
>> 
>> 
>> On 19 Okt., 14:30, Joshua Muheim  wrote:
>>> It looks really clumsy to me. What about the following?
>>> 
>>> class AppModel extends Model {
>>> function data($field) {
>>> return $this->data[$this->name][$field];
>>> }
>>> 
>>> }
>>> 
>>> First I was not sure why in the $data array there is a key
>>> 'ModelName', I would have expected something like this:
>>> 
>>> array(
>>> 'id' => 1,
>>> 'name' => 'bla'
>>> )
>>> 
>>> instead of
>>> 
>>> array(
>>> 'ModelName' => array(
>>> 'id' => 1,
>>> 'name' => 'bla'
>>> )
>>> )
>>> 
>>> Then I saw that every related model has its own key there, so it makes
>>> a bit sense. But why is the key in the array the model's name?
>>> Wouldn't it be better to have the name of the association in there?
>>> Because what when I have multiple associations to the same model? Or a
>>> HABTM with myself?
>>> 
>>> Aside of this, I guess retrieving the "immediate" data of the model
>>> (not of it's related models') should have a special status and should
>>> be able to be retrieved in a faster way, like the one above...
>>> 
>>> On Tue, Oct 19, 2010 at 1:15 PM, euromark  
>>> wrote:
 nope
 but thats already a very neat way to do it
 what is your problem with it?
>>> 
 On 19 Okt., 11:53, psybear83  wrote:
> Hi everybody
>>> 
> Sorry for this newbish question, but I don't seem to find much about
> this (although I should, I guess).
>>> 
> $m = $this->Model->find(1);
> echo $m->data['Model']['something];
>>> 
> Is there a better way of getting a model's data fields instead of
> this? I always thought this could be done with $m->field(), but this
> retrieves the data from the database, what is not what I want.
>>> 
> Thanks
> Josh
>>> 
 Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
 with their CakePHP related questions.
>>> 
 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 
 athttp://groups.google.com/group/cake-php?hl=en
>> 
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>> 
>> 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
>> 
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 

Re: hasMany: check for depending objects when deleting and deny?

2010-10-19 Thread Joshua Muheim
So it seems there's no such functionality yet? I will try to create a
component or something for this...

On Thu, Sep 16, 2010 at 12:17 PM, Jeremy Burns | Class Outfit
 wrote:
> Go directly to the source; use referential integrity in InnoDB.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.com
> http://www.classoutfit.com
>
> On 16 Sep 2010, at 11:12, psybear83 wrote:
>
>> Hi all
>>
>> I know that I can use the dependent flag to automatically delete all
>> the associated model objects.
>>
>> But I'd rather have an option to prevent deletion of the object as
>> long as it's having other depending objects. Is there an easy way to
>> do this?
>>
>> Thanks a lot
>> Josh
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> 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
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: So methods that are not an action should have a "_" in front of it?

2010-10-19 Thread Joshua Muheim
OK, so why do several CakePHP methods don't have an underscore? Like
beforeFilter()? I know, CakePHP will probably be smart enough to not
allow this to be called as an action through the browser, but
still...? :-P

On Tue, Oct 19, 2010 at 4:00 PM, Joshua Muheim  wrote:
> Thanks for the hint with the components! :-)
>
> On Tue, Oct 19, 2010 at 3:59 PM, euromark  wrote:
>> yep, thats right (for example from the acl shell)
>> or YOU could accidently misinterpret it as an action
>>
>> so either way it is still helpful to use the underscores :)
>>
>> but in most cases you usually can put that could in a component
>> doesnt have to be a controller _function...
>>
>> On 19 Okt., 15:44, psybear83  wrote:
>>> As mentioned before, I have taken over an existing CakePHP
>>> application... and it's not a very good one. I'm working since a month
>>> or more on things like writing tests (there haven't been any before),
>>> cleaning and rewriting code etc.
>>>
>>> So now I stumbled over some methods in a controller that aren't
>>> actions, but they don't have underscores "_" in front of their
>>> names... so I ask you: they *really should have*, right??
>>>
>>> I know the conventions, that protected and private methods and
>>> attributes should have an underscore (or even two in some conventions)
>>> for visual reasons back from the days of PHP4, but that's not what's
>>> really important here, right? It's important here because when not
>>> having an underscore, it will be "mistaken" by CakePHP for an
>>> available action, right?
>>>
>>> So aside from that, are you following the convention mentioned above?
>>> Should I use it when coding a CakePHP application? Or is it somewhat
>>> outdated?
>>>
>>> Thanks
>>> Josh
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> 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
>>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: So methods that are not an action should have a "_" in front of it?

2010-10-19 Thread Joshua Muheim
Thanks for the hint with the components! :-)

On Tue, Oct 19, 2010 at 3:59 PM, euromark  wrote:
> yep, thats right (for example from the acl shell)
> or YOU could accidently misinterpret it as an action
>
> so either way it is still helpful to use the underscores :)
>
> but in most cases you usually can put that could in a component
> doesnt have to be a controller _function...
>
> On 19 Okt., 15:44, psybear83  wrote:
>> As mentioned before, I have taken over an existing CakePHP
>> application... and it's not a very good one. I'm working since a month
>> or more on things like writing tests (there haven't been any before),
>> cleaning and rewriting code etc.
>>
>> So now I stumbled over some methods in a controller that aren't
>> actions, but they don't have underscores "_" in front of their
>> names... so I ask you: they *really should have*, right??
>>
>> I know the conventions, that protected and private methods and
>> attributes should have an underscore (or even two in some conventions)
>> for visual reasons back from the days of PHP4, but that's not what's
>> really important here, right? It's important here because when not
>> having an underscore, it will be "mistaken" by CakePHP for an
>> available action, right?
>>
>> So aside from that, are you following the convention mentioned above?
>> Should I use it when coding a CakePHP application? Or is it somewhat
>> outdated?
>>
>> Thanks
>> Josh
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread Joshua Muheim
Ah, and yes, I trust in these guys, don't worry! :-) I'm only trying
to figure out why things are the way they are so I can learn from
these wise guys.

On Tue, Oct 19, 2010 at 3:59 PM, Joshua Muheim  wrote:
> Maybe I don't really understand your point, but as far as I see that's
> exactly what I've written here:
>
> Then I saw that every related model has its own key there, so it makes
> a bit sense. But why is the key in the array the model's name?
> Wouldn't it be better to have the name of the association in there?
> Because what when I have multiple associations to the same model? Or a
> HABTM with myself?
>
> On Tue, Oct 19, 2010 at 3:56 PM, euromark  wrote:
>> i think you are missing the obvious point
>> is there a reason why this is done this way in cake? yes, there is
>> trust the guys that work with since several years
>>
>> one example:
>> you have a BelongsTo relationshop
>> cake can easily get this data as well
>>
>> now you can do:
>>
>> $this->Model->recursive = 0;
>> $m = $this->Model->findById(1);
>> echo $res['Model']['something];
>> echo $res['OtherModel']['something];
>>
>> without any additional stuff going on.
>> thats why you always have the model name first.
>>
>>
>> On 19 Okt., 14:30, Joshua Muheim  wrote:
>>> It looks really clumsy to me. What about the following?
>>>
>>> class AppModel extends Model {
>>>     function data($field) {
>>>         return $this->data[$this->name][$field];
>>>     }
>>>
>>> }
>>>
>>> First I was not sure why in the $data array there is a key
>>> 'ModelName', I would have expected something like this:
>>>
>>> array(
>>>     'id' => 1,
>>>     'name' => 'bla'
>>> )
>>>
>>> instead of
>>>
>>> array(
>>>     'ModelName' => array(
>>>         'id' => 1,
>>>         'name' => 'bla'
>>>     )
>>> )
>>>
>>> Then I saw that every related model has its own key there, so it makes
>>> a bit sense. But why is the key in the array the model's name?
>>> Wouldn't it be better to have the name of the association in there?
>>> Because what when I have multiple associations to the same model? Or a
>>> HABTM with myself?
>>>
>>> Aside of this, I guess retrieving the "immediate" data of the model
>>> (not of it's related models') should have a special status and should
>>> be able to be retrieved in a faster way, like the one above...
>>>
>>> On Tue, Oct 19, 2010 at 1:15 PM, euromark  
>>> wrote:
>>> > nope
>>> > but thats already a very neat way to do it
>>> > what is your problem with it?
>>>
>>> > On 19 Okt., 11:53, psybear83  wrote:
>>> >> Hi everybody
>>>
>>> >> Sorry for this newbish question, but I don't seem to find much about
>>> >> this (although I should, I guess).
>>>
>>> >> $m = $this->Model->find(1);
>>> >> echo $m->data['Model']['something];
>>>
>>> >> Is there a better way of getting a model's data fields instead of
>>> >> this? I always thought this could be done with $m->field(), but this
>>> >> retrieves the data from the database, what is not what I want.
>>>
>>> >> Thanks
>>> >> Josh
>>>
>>> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>>> > with their CakePHP related questions.
>>>
>>> > 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 
>>> > athttp://groups.google.com/group/cake-php?hl=en
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> 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
>>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread Joshua Muheim
Maybe I don't really understand your point, but as far as I see that's
exactly what I've written here:

Then I saw that every related model has its own key there, so it makes
a bit sense. But why is the key in the array the model's name?
Wouldn't it be better to have the name of the association in there?
Because what when I have multiple associations to the same model? Or a
HABTM with myself?

On Tue, Oct 19, 2010 at 3:56 PM, euromark  wrote:
> i think you are missing the obvious point
> is there a reason why this is done this way in cake? yes, there is
> trust the guys that work with since several years
>
> one example:
> you have a BelongsTo relationshop
> cake can easily get this data as well
>
> now you can do:
>
> $this->Model->recursive = 0;
> $m = $this->Model->findById(1);
> echo $res['Model']['something];
> echo $res['OtherModel']['something];
>
> without any additional stuff going on.
> thats why you always have the model name first.
>
>
> On 19 Okt., 14:30, Joshua Muheim  wrote:
>> It looks really clumsy to me. What about the following?
>>
>> class AppModel extends Model {
>>     function data($field) {
>>         return $this->data[$this->name][$field];
>>     }
>>
>> }
>>
>> First I was not sure why in the $data array there is a key
>> 'ModelName', I would have expected something like this:
>>
>> array(
>>     'id' => 1,
>>     'name' => 'bla'
>> )
>>
>> instead of
>>
>> array(
>>     'ModelName' => array(
>>         'id' => 1,
>>         'name' => 'bla'
>>     )
>> )
>>
>> Then I saw that every related model has its own key there, so it makes
>> a bit sense. But why is the key in the array the model's name?
>> Wouldn't it be better to have the name of the association in there?
>> Because what when I have multiple associations to the same model? Or a
>> HABTM with myself?
>>
>> Aside of this, I guess retrieving the "immediate" data of the model
>> (not of it's related models') should have a special status and should
>> be able to be retrieved in a faster way, like the one above...
>>
>> On Tue, Oct 19, 2010 at 1:15 PM, euromark  wrote:
>> > nope
>> > but thats already a very neat way to do it
>> > what is your problem with it?
>>
>> > On 19 Okt., 11:53, psybear83  wrote:
>> >> Hi everybody
>>
>> >> Sorry for this newbish question, but I don't seem to find much about
>> >> this (although I should, I guess).
>>
>> >> $m = $this->Model->find(1);
>> >> echo $m->data['Model']['something];
>>
>> >> Is there a better way of getting a model's data fields instead of
>> >> this? I always thought this could be done with $m->field(), but this
>> >> retrieves the data from the database, what is not what I want.
>>
>> >> Thanks
>> >> Josh
>>
>> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>> > with their CakePHP related questions.
>>
>> > 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 
>> > athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: So methods that are not an action should have a "_" in front of it?

2010-10-19 Thread euromark
yep, thats right (for example from the acl shell)
or YOU could accidently misinterpret it as an action

so either way it is still helpful to use the underscores :)

but in most cases you usually can put that could in a component
doesnt have to be a controller _function...

On 19 Okt., 15:44, psybear83  wrote:
> As mentioned before, I have taken over an existing CakePHP
> application... and it's not a very good one. I'm working since a month
> or more on things like writing tests (there haven't been any before),
> cleaning and rewriting code etc.
>
> So now I stumbled over some methods in a controller that aren't
> actions, but they don't have underscores "_" in front of their
> names... so I ask you: they *really should have*, right??
>
> I know the conventions, that protected and private methods and
> attributes should have an underscore (or even two in some conventions)
> for visual reasons back from the days of PHP4, but that's not what's
> really important here, right? It's important here because when not
> having an underscore, it will be "mistaken" by CakePHP for an
> available action, right?
>
> So aside from that, are you following the convention mentioned above?
> Should I use it when coding a CakePHP application? Or is it somewhat
> outdated?
>
> Thanks
> Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread euromark
i think you are missing the obvious point
is there a reason why this is done this way in cake? yes, there is
trust the guys that work with since several years

one example:
you have a BelongsTo relationshop
cake can easily get this data as well

now you can do:

$this->Model->recursive = 0;
$m = $this->Model->findById(1);
echo $res['Model']['something];
echo $res['OtherModel']['something];

without any additional stuff going on.
thats why you always have the model name first.


On 19 Okt., 14:30, Joshua Muheim  wrote:
> It looks really clumsy to me. What about the following?
>
> class AppModel extends Model {
>     function data($field) {
>         return $this->data[$this->name][$field];
>     }
>
> }
>
> First I was not sure why in the $data array there is a key
> 'ModelName', I would have expected something like this:
>
> array(
>     'id' => 1,
>     'name' => 'bla'
> )
>
> instead of
>
> array(
>     'ModelName' => array(
>         'id' => 1,
>         'name' => 'bla'
>     )
> )
>
> Then I saw that every related model has its own key there, so it makes
> a bit sense. But why is the key in the array the model's name?
> Wouldn't it be better to have the name of the association in there?
> Because what when I have multiple associations to the same model? Or a
> HABTM with myself?
>
> Aside of this, I guess retrieving the "immediate" data of the model
> (not of it's related models') should have a special status and should
> be able to be retrieved in a faster way, like the one above...
>
> On Tue, Oct 19, 2010 at 1:15 PM, euromark  wrote:
> > nope
> > but thats already a very neat way to do it
> > what is your problem with it?
>
> > On 19 Okt., 11:53, psybear83  wrote:
> >> Hi everybody
>
> >> Sorry for this newbish question, but I don't seem to find much about
> >> this (although I should, I guess).
>
> >> $m = $this->Model->find(1);
> >> echo $m->data['Model']['something];
>
> >> Is there a better way of getting a model's data fields instead of
> >> this? I always thought this could be done with $m->field(), but this
> >> retrieves the data from the database, what is not what I want.
>
> >> Thanks
> >> Josh
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: need help

2010-10-19 Thread Jeremy Burns | Class Outfit
http://book.cakephp.org/view/907/Developing-with-CakePHP

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 19 Oct 2010, at 13:28, Sunil Chugh wrote:

> steps to configure
> Cake Console and Bake
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Dates before 1600-01-01 are not recognized by models' date fields?

2010-10-19 Thread Joshua Muheim
I'm using MySQL.

mysql --version Ver 14.12 Distrib 5.0.51a, for apple-darwin9.0.0b5
(i686) using readline 5.0

On Tue, Oct 19, 2010 at 3:30 PM, Chris Burch  wrote:
> Sounds like a database issue. I know 1600-01-01 is Oracle's "first
> date".
>
> On Oct 19, 5:02 am, psybear83  wrote:
>> Hi everybody
>>
>> Is there a reason why CakePHP doesn't recognize dates before
>> 1600-01-01? I get a validation error when submitting a date before
>> that (e.g. 1599-31-12 or 1300-11-05).
>>
>> Thanks,
>> Josh
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Dates before 1600-01-01 are not recognized by models' date fields?

2010-10-19 Thread Chris Burch
Sounds like a database issue. I know 1600-01-01 is Oracle's "first
date".

On Oct 19, 5:02 am, psybear83  wrote:
> Hi everybody
>
> Is there a reason why CakePHP doesn't recognize dates before
> 1600-01-01? I get a validation error when submitting a date before
> that (e.g. 1599-31-12 or 1300-11-05).
>
> Thanks,
> Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


need help

2010-10-19 Thread Sunil Chugh
steps to configure
 Cake Console and Bake

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Joins destroys conditions?

2010-10-19 Thread Chris Burch

On Oct 19, 3:39 am, "torsten.edelm...@googlemail.com"
 wrote:
> I have the following:

...snip...

> The strange thing is - as soon as I look for a Group by using the
> "join" it's as if part (but strangely enough not all) of the basic
> conditions are ignored. In fact, the condition for the project_id is
> still honored, but the condition for the state_id is ignored. And I
> can't seem to wrap my head around where the problem lies...

Have you set debug to 2 and looked at what SQL Cake is generating?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


MS SQL schema (owners)

2010-10-19 Thread Chris Burch
Hello,

Are there plans of dbo_mssql.php supporting schema (owners) other than
dbo? Otherwise I may have a go at hacking it in but I'm a bit over my
head.

TIA,
Chris

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


So methods that are not an action should have a "_" in front of it?

2010-10-19 Thread psybear83
As mentioned before, I have taken over an existing CakePHP
application... and it's not a very good one. I'm working since a month
or more on things like writing tests (there haven't been any before),
cleaning and rewriting code etc.

So now I stumbled over some methods in a controller that aren't
actions, but they don't have underscores "_" in front of their
names... so I ask you: they *really should have*, right??

I know the conventions, that protected and private methods and
attributes should have an underscore (or even two in some conventions)
for visual reasons back from the days of PHP4, but that's not what's
really important here, right? It's important here because when not
having an underscore, it will be "mistaken" by CakePHP for an
available action, right?

So aside from that, are you following the convention mentioned above?
Should I use it when coding a CakePHP application? Or is it somewhat
outdated?

Thanks
Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread Joshua Muheim
It looks really clumsy to me. What about the following?

class AppModel extends Model {
function data($field) {
return $this->data[$this->name][$field];
}
}

First I was not sure why in the $data array there is a key
'ModelName', I would have expected something like this:

array(
'id' => 1,
'name' => 'bla'
)

instead of

array(
'ModelName' => array(
'id' => 1,
'name' => 'bla'
)
)

Then I saw that every related model has its own key there, so it makes
a bit sense. But why is the key in the array the model's name?
Wouldn't it be better to have the name of the association in there?
Because what when I have multiple associations to the same model? Or a
HABTM with myself?

Aside of this, I guess retrieving the "immediate" data of the model
(not of it's related models') should have a special status and should
be able to be retrieved in a faster way, like the one above...

On Tue, Oct 19, 2010 at 1:15 PM, euromark  wrote:
> nope
> but thats already a very neat way to do it
> what is your problem with it?
>
>
> On 19 Okt., 11:53, psybear83  wrote:
>> Hi everybody
>>
>> Sorry for this newbish question, but I don't seem to find much about
>> this (although I should, I guess).
>>
>> $m = $this->Model->find(1);
>> echo $m->data['Model']['something];
>>
>> Is there a better way of getting a model's data fields instead of
>> this? I always thought this could be done with $m->field(), but this
>> retrieves the data from the database, what is not what I want.
>>
>> Thanks
>> Josh
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Joins destroys conditions?

2010-10-19 Thread torsten.edelm...@googlemail.com
Actually I found that ALL conditions are ignored, it was just a
coincidence that the results were only from the project I expected.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


need help

2010-10-19 Thread Sunil Chugh
'php' is not recognized as an internal or external command,
operable program or batch file.
how to remove this error

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Installation problem

2010-10-19 Thread Tilen Majerle
missing index.php file? :D
--
Tilen Majerle
http://majerle.eu



2010/10/18 Greengny 

> Hello
>
> Trying to install Cake. Using Apache and PHP 5.
>
> I have installed it in c:\gg\apache22\htdocs\cake. c:\gg
> \apache22\htdocs\ is my document root.
>
> When  I try to access http:\\localhost\cakeI get a directory
> listing instead of the Cake PHP page.
>
> What am I doing wrong?
>
> Thank you
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: login page Redirection...

2010-10-19 Thread Tilen Majerle
hmmmmake new method in posts section called idk users_posts($userid =
null)

and then get posts from user id
--
Tilen Majerle
http://majerle.eu



2010/10/18 cakebaker 

> I am trying to learn and work on cakephp FW.
> I have a DB with Posts blog.
> I have implemented the ACL.
> I have Admin and User groups.
> When an Admin (some one belongs 2 admin grp) log in he needs to be
> redirected to a page where he can see all posts(belongs to all people)
> This is working
> I have implemented this with the following command in
> users_controller.php:
> function login() {
> if($this->Auth->user('role')=='admin')
> {
> $this->redirect(array('controller'=>'posts','action' => 'index'));
> }
> BUT When a user (some 1 belongs to user grp - NOT ADMIN) log in he
> needs to be redirected to see ( or redirect to posts page where he can
> see only his posts) ONLY his posts not others..
> How can I implement this>???
>
> Thanks
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread euromark
nope
but thats already a very neat way to do it
what is your problem with it?


On 19 Okt., 11:53, psybear83  wrote:
> Hi everybody
>
> Sorry for this newbish question, but I don't seem to find much about
> this (although I should, I guess).
>
> $m = $this->Model->find(1);
> echo $m->data['Model']['something];
>
> Is there a better way of getting a model's data fields instead of
> this? I always thought this could be done with $m->field(), but this
> retrieves the data from the database, what is not what I want.
>
> Thanks
> Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


How can i Optimize i18n ?

2010-10-19 Thread CakeME
My website is very slow and i managed to install xdebug
And after looking at the profile generated by the xdebug using
kcachedgrind i found i18n::Translate took more inclusive , self and
more counts compare to others
i am thinking what to do how can i optimize this. can some one tell me
how can i do this

Here is my generated profile:  http://yfrog.com/f/n8xdebugprofilingp/

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Enter directly into the web application via SMS

2010-10-19 Thread marco.rizze...@gmail.com
Hi
I have a particular question.
I have a web mobile application.
This application has his authentication part (with Auth component).
Now one features of the web application is that the user in certainly
situation receives a sms with a link.
If he clicks on link I must open a session that allows only to view
the page and then the session must expiry.
Have someone some suggestion to do this?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Joins destroys conditions?

2010-10-19 Thread torsten.edelm...@googlemail.com
I have the following:

A bug has a state and hasandbelongs to many usergroups among other
things.
Now, when listing the bugs I used the pagination helper and also give
the user the ability to filter it by various setting. Works great so
far. You can filter it by project, you can filter it by state (via the
state_id property of the bug) and by several other items. Now they
want it to be filtered by the groups that are responsible for the bug.
Since this is a HABTM connection I used "joins" to connect up the
tables.

This is what my $this->paginate looks like:

[limit] => 10
[contain] => Array
(
[0] => Project
[1] => User
[2] => Priority
[3] => State
[Comment] => Array
(
[0] => User
)

[4] => Screenshot
[5] => Group
)

[conditions] => Array
(
[Bug.project_id] => 26
[Bug.state_id] => 1
)

[Bug] => Array
(
[joins] => Array
(
[0] => Array
(
[table] => bugs_groups
[alias] => BugsGroups
[type] => inner
[conditions] => Array
(
[0] => BugsGroups.bug_id = Bug.id
)

)

[1] => Array
(
[table] => groups
[alias] => Group
[type] => inner
[conditions] => Array
(
[0] => Group.id =
BugsGroups.group_id
[Group.id] => 9
)

)

)

)


The strange thing is - as soon as I look for a Group by using the
"join" it's as if part (but strangely enough not all) of the basic
conditions are ignored. In fact, the condition for the project_id is
still honored, but the condition for the state_id is ignored. And I
can't seem to wrap my head around where the problem lies...

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Installation problem

2010-10-19 Thread Greengny
Hello

Trying to install Cake. Using Apache and PHP 5.

I have installed it in c:\gg\apache22\htdocs\cake. c:\gg
\apache22\htdocs\ is my document root.

When  I try to access http:\\localhost\cakeI get a directory
listing instead of the Cake PHP page.

What am I doing wrong?

Thank you

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Find condition on joined table

2010-10-19 Thread Dan
Hi,

I am trying out CakePHP on an existing (and messy) website to see if
it is going to be beneficial to use it for the new features from now
on. I have been creating a test model that allows admin to search
through users based on various fields (userId, name, email address,
orderId).

I have 3 tables that are being used for this:
Users
Customers
Orders

Users links to Customers on a 1 to 1 relationship on 'userId',
Customers links to Orders on a 1 to many relationship on 'customerId'.

The search feature is working correctly, except that I can't figure
out how to set conditions on the Orders table.
This is the query I would write normally to get the user who placed a
certain order:

SELECT * FROM users u
LEFT JOIN customers c ON u.userId = c.userId
LEFT JOIN orders o ON o.customerId = c.customerId
WHERE o.orderId = $orderId.

I have set up models for Users, Customers and Orders, With 'Users
$hasOne ' referencing Customers, and 'Customers $hasMany' referencing
Orders.

If the conditions only reference the Users table, the script brings
out the Orders data correctly, but I can't get it to allow me to
search for an orderId, as Orders is referenced by Users through
Customers.

Any help on this would be great, I can upload code if necessary.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


login page Redirection...

2010-10-19 Thread cakebaker
I am trying to learn and work on cakephp FW.
I have a DB with Posts blog.
I have implemented the ACL.
I have Admin and User groups.
When an Admin (some one belongs 2 admin grp) log in he needs to be
redirected to a page where he can see all posts(belongs to all people)
This is working
I have implemented this with the following command in
users_controller.php:
function login() {
if($this->Auth->user('role')=='admin')
{
$this->redirect(array('controller'=>'posts','action' => 'index'));
}
BUT When a user (some 1 belongs to user grp - NOT ADMIN) log in he
needs to be redirected to see ( or redirect to posts page where he can
see only his posts) ONLY his posts not others..
How can I implement this>???

Thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: The action img is not defined in controller

2010-10-19 Thread AD7six


On Oct 19, 11:18 am, Dunc  wrote:
> Hi,
>
> I've implimented CakePHP's app_error.php file to keep track of any
> system errors via email, using the system detailed here:
>
> http://nuts-and-bolts-of-cakephp.com/2008/08/29/dealing-with-errors-i...
>
> The problem I have is I'm getting through a huge number of messages
> telling me there's no action for img (see below).  I thought it must
> be a missing image, but I've checked the code and run through the site
> whilst running Fiddler, and there doesn't seem to be any missing
> images.
>
> Has anyone come across this before?  If so, what was the problem and
> how was it fixed?

Obviously the error /is/ that you've got a relative reference to an
image somewhere, the fix is to find it, and correct it ;)

Why not log the current url and the referer to see where the error is
coming from. IME something like that is caused by your WYSIWYG editor
(or some other js you didn't write yourself) using a relative route
for a placeholder image or the likes. I'd start by looking at your
Reporting controller's links/js files ;).

hth

AD

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Dates before 1600-01-01 are not recognized by models' date fields?

2010-10-19 Thread psybear83
Hi everybody

Is there a reason why CakePHP doesn't recognize dates before
1600-01-01? I get a validation error when submitting a date before
that (e.g. 1599-31-12 or 1300-11-05).

Thanks,
Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Help with CakePHP

2010-10-19 Thread Péter Maróti
Hi!

I did a short video series, about the blog tutorial (its a plan to do
the acl tutorial too)
http://www.youtube.com/user/JARJARMP?feature=mhum#g/p

Jar

2010/10/17 cricket :
> On Sun, Oct 17, 2010 at 6:56 AM, chris_p  wrote:
>> Hi there.  I have just downloaded CakePHP and have tried to basic
>> tutorial they reccomend.  I have created application where you can
>> edit, add, delete posts.  However I am not sure how to change the
>> style of the page.  I know that certain elements make up the view of
>> the page e.g add.ctp but how do I change the appearance of the index
>> page.
>>
>> For example every time you add a post it display the sql at the bottom
>> of the page.  How can I get rid of this?
>
> Create your own layout files in app/views/layouts dir.
>
> http://book.cakephp.org/view/1080/Layouts
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2010-10-19 Thread psybear83
Hi everybody

Sorry for this newbish question, but I don't seem to find much about
this (although I should, I guess).

$m = $this->Model->find(1);
echo $m->data['Model']['something];

Is there a better way of getting a model's data fields instead of
this? I always thought this could be done with $m->field(), but this
retrieves the data from the database, what is not what I want.

Thanks
Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


The action img is not defined in controller

2010-10-19 Thread Dunc
Hi,

I've implimented CakePHP's app_error.php file to keep track of any
system errors via email, using the system detailed here:

http://nuts-and-bolts-of-cakephp.com/2008/08/29/dealing-with-errors-in-cakephp/

The problem I have is I'm getting through a huge number of messages
telling me there's no action for img (see below).  I thought it must
be a missing image, but I've checked the code and run through the site
whilst running Fiddler, and there doesn't seem to be any missing
images.

Has anyone come across this before?  If so, what was the problem and
how was it fixed?

Thanks in advance

/ snip /---

Missing Method in ZZZController
Error: The action img is not defined in controller ZZZController
Error: Create ReportingController::img() in file: app/controllers/
zzz_controller.php.



Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Redirect in a component

2010-10-19 Thread Okalany Daniel
Hi Will,
I always redirect like this:

$this->controller = null;
// function run on init
function startup(&$controller){
$this->controller = $controller;
}

function someredirect(){
$this->controller->redirect('/');
}


On Tue, Oct 19, 2010 at 10:35 AM, #2Will  wrote:

> Hi,
>
> Im trying to redirect from a component, and in the cookbook it says
> this:
>
> function redirectSomewhere($value) {
>// utilizing a controller method
>$this->controller->redirect($value);
>}
>
>
> http://book.cakephp.org/view/64/Creating-Components
>
> But that throws an error like this:
> **
>  Error:  The component file was not found.
>
> Error: Create the class RedirectComponent in file: app/controllers/
> components/redirect.php
>
>  class RedirectComponent extends Object {
>
>
> }
> ?>
> ***
>
> Can anyone explain why? And what do i do to redirect from my
> component?
>
> Thanks!
>
> Will
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>



-- 
OKALANY DANIEL,
P.O BOX 26150,
Kampala.,
Uganda.
http://okasoft.net
--
When confronted by our worst nightmares, the choices are few; Fight or
flight. We hope to find the strength to stand against our fears but
sometimes, despite ourselves, we run. What if the nightmare gives chase?
Where can we hide then?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Redirect in a component

2010-10-19 Thread #2Will
Hi,

Im trying to redirect from a component, and in the cookbook it says
this:

function redirectSomewhere($value) {
// utilizing a controller method
$this->controller->redirect($value);
}


http://book.cakephp.org/view/64/Creating-Components

But that throws an error like this:
**
 Error:  The component file was not found.

Error: Create the class RedirectComponent in file: app/controllers/
components/redirect.php


***

Can anyone explain why? And what do i do to redirect from my
component?

Thanks!

Will

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Block every http connection except mine using .htaccess mod_rewrite?

2010-10-19 Thread O.J. Tibi
I also have a solution (actually got it from my boss, thanks boss), it
might not work for you (because it doesn't use .htaccess and
mod_rewrite, and this one uses PHP), but I hope you like the idea.
This also uses IPv4 functions so you might need another function for
IPv6.

1.) Get a DynamicDNS account and bind a dynamic subdomain to it
(something like dyndns.yourdomain.com)
2.) Download a DynDNS client using the details associated with your
account, running it in the background so your subdomain's IP updates
automatically
3.) On your app, write some configuration entries / logic checks for
allowed specific domains like so:
  a.) Get the list of allowed domains from your storage
  b.) Loop through each domain (where your dyndns.yourdomain.com is
also included), getting the IP address using gethostbyname()
  3.) Check if the visitor's $_SERVER['REMOTE_ADDR'] matches one of
these IPs, if not, then you can redirect them somewhere.

HTH,
OJ Tibi

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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