Re: 3.0 change default table order

2015-01-19 Thread Ernesto
you're right

thank for your help

Il giorno lunedì 19 gennaio 2015 18:55:58 UTC+1, José Lorenzo ha scritto:
>
> How would it know it is useless?
>
> On Monday, January 19, 2015 at 5:25:38 PM UTC+1, Ernesto wrote:
>>
>> Shouldn't Cake itself take care of useless clauses?
>>
>> Il giorno lunedì 19 gennaio 2015 16:57:43 UTC+1, José Lorenzo ha scritto:
>>>
>>> That's almost right. I would change it a bit by doing this:
>>>
>>> public function beforeFind ($event, $query, $options, $primary) {
>>> $order = $query->clause('order');
>>> if ($order === null || !count($order)) {
>>>  $query->order("nome");
>>> }
>>> return parent::beforeFind($event, $query, $options, $primary);
>>> }
>>>
>>> That will prevent adding more order clauses than you'd need.
>>>
>>> On Monday, January 19, 2015 at 4:04:09 PM UTC+1, Ernesto wrote:

 Hi all

 i noticed that the variable "order", used in cake 1.x/2.x models to 
 alter the default table sort, has gone.
 i haven't found any hint in the 3.0 cookbook so i'm asking: what's the 
 best practice to do this in 3.0?

 i did this:

 public function beforeFind ($event, $query, $options, $primary) {
 $query->order("nome");
 return parent::beforeFind($event, $query, $options, $primary);
 }

 is that right?

 Sorry for my engRish

>>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Session date missing after redirect

2015-01-19 Thread kdubya
Euromark,

Thanks for your response. I updated my version of CakePHP to the 2.6.1. Now 
I can change the setup so that session cookies on the server are written to 
/app/tmp/sessions. I now see the cookies - each with a name like 
sess_abd5g143. The client-side cookie content is the GUID that matches 
the GUID that is part of the server-side cookie name.

My session setup (at least on the CakePHP side) is very much default except 
that I now have Session.default='cake'. The server is a WHM/Cpanel type. 
Very generic too.

I have setup another 2.x app that uses the same UsersController code and I 
get the same symptoms. I agree it seems like a server problem - but where 
do I look? Especially since on the same server a 1.3 app works. I have 
asked the company I lease my servers from to help.

Ken

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Session date missing after redirect

2015-01-19 Thread euromark
You must have some special session setup.
For no one else this happens - ever.

Try to set up a completely fresh system and debug that one piece by piece.
If that happens there too its most likely a server issue.

Otherwise it is probably a misconfiguration in your configs in CakePHP etc.

mark


Am Montag, 19. Januar 2015 23:15:29 UTC+1 schrieb kdubya:
>
> A kind person on IRC suggested that the problem might be fixed by going to 
> the latest version of Cake. So I updated to 2.6.1 and the problem still 
> exists.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Session date missing after redirect

2015-01-19 Thread kdubya
A kind person on IRC suggested that the problem might be fixed by going to 
the latest version of Cake. So I updated to 2.6.1 and the problem still 
exists.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Cakephp 3.0 Get and Modify Query conditions in beforeFind function

2015-01-19 Thread José Lorenzo
I don't think it is possible in an easy way, I also think you are trying to 
complicate the problem, given the existence of other clean solutions that 
already work.

There are two methods that clause('where') object has that can be used to 
traverse the query. They are iterateParts() and traverse(). iterateParts() 
will call the passed function for each of the conditions in the same level 
of depth. traverse() will call the passed function for all the conditions 
that are stored in a ExpressionInterface object.

There are basically 2 types of interesting ExpressionInterface objects. 
QueryExpression (contains multiple conditions in the same level and you can 
call iterateParts() on it) and Comparison, which is a single condition.

With a bit (maybe  a lot) of work you can traverse each of the levels of 
conditions and build an array out of it. Again, sounds like something 
complicated for something that can be done differently in a simpler way.

On Monday, January 19, 2015 at 5:45:55 PM UTC+1, Cake Developer wrote:
>
> Hi Jose,
>
> I gone through both of the plugin links you provided, It seems they are 
> complicated and do not meet my requirements.
>
> I am trying to write a generic solution to filter records with less code. 
> Is there any way to get original conditions from query object as an array 
> format.
>
> For e.g.
>
> $this->paginate = ['conditions'=>['Users.active'=>1]];
>
> I want original conditions in beforeFind method like
>
> function beforeFind(Event $event, Query $query, $options, $primary) {
> $orgCondtions = $query->clause('where'); //it returns Expression 
> Object
>
> $orgCondtions = convertExpressionObjectToArray($orgCondtions);
> pr($orgCondtions);
> output should be  array('Users.active'=>1)
> }
>
>
> I am looking for a way to convert Expression Object to Array. Please help 
> me if possible.
>
> Thanks in advance.
>
>
>
> On Mon, Jan 19, 2015 at 4:22 PM, José Lorenzo  wrote:
>
>> Sorry, I forgot to answer... What you are doing sounds similar to what 
>> some plugins are doing as well. Please try these:
>>
>> https://github.com/skie/plum_search
>>
>> https://github.com/FriendsOfCake/search
>>
>> As for the second case. I suggest doing as I suggested at the beginning, 
>> use the query options to hint the beforeFind() or any other finder method 
>> on what to do or overwrite. That way you can avoid traversing the 
>> conditions tree.
>>
>> If you are in absolute need of inspecting the where clause and modifying 
>> stuff, you will need to do as follows:
>>
>> $query->clause('where')->traverse(function ($expression) {
>> if ($expression instanceof \Cake\Database\Expression\Comparison) {
>> if ($expression->getField() === 'Users.active' && 
>> $expression->getValue() === true) {
>>  $expression->setValue(false);
>> }
>> }
>> });
>>
>> But that can get a bit complicated and difficult to read. Hence my 
>> suggestion to treat the Query as a command by passing options to it.
>>
>>
>> On Monday, January 19, 2015 at 10:32:22 AM UTC+1, Cake Developer wrote:
>>>
>>> Hi Experts,
>>>
>>> any help?
>>>
>>> Thanks in advance.
>>>
>>> On Friday, January 16, 2015 at 12:47:39 AM UTC+5:30, José Lorenzo wrote:

 Even though that is possible you are tying to do it the hard way. The 
 easiest way you can implement the same is by using the query as a 
 "command" 
 object,
 thus instructing the custom finders to do stuff based on the passed 
 options. An example

 $table->find('forUser', ['user' => $user])->find('withStatus', 
 ['status' => 'active']);

 Then in your table you would create your finders this way:

 public function finWithStatus($query, $options) {
 if (!empty($options['user'])) {
  // The user is available from the previous finder, I can add 
 more conditions here based on that
 }
 }


 I guess the best way I can help you find the best strategy is if you 
 mention what exactly you are trying to do :D
 On Thursday, January 15, 2015 at 3:26:09 PM UTC+1, Cake Developer wrote:
>
> Hello,
>
> I am trying to get and modify query conditions in beforeFind function 
> of Behaviour.
>
> function beforeFind(Event $event, Query $query, $options, $primary) {
>// here is what I tried so far.
> $conditions = $query->clause('where');
> // this gives me Object of Expression Interface and I am not able to 
> convert it in condition array like we have in cakephp 2.x
>
> //what I want to achieve... 
> //I want to modify existing conditions in query.
> //I want to add new condition in query
>
> }
>
> I spent last 2 days but could not figure out any solution.
> Thanks for any help you may be able to provide regarding this.
>
>  -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> --- 
>> You rece

Re: 3.0 change default table order

2015-01-19 Thread José Lorenzo
How would it know it is useless?

On Monday, January 19, 2015 at 5:25:38 PM UTC+1, Ernesto wrote:
>
> Shouldn't Cake itself take care of useless clauses?
>
> Il giorno lunedì 19 gennaio 2015 16:57:43 UTC+1, José Lorenzo ha scritto:
>>
>> That's almost right. I would change it a bit by doing this:
>>
>> public function beforeFind ($event, $query, $options, $primary) {
>> $order = $query->clause('order');
>> if ($order === null || !count($order)) {
>>  $query->order("nome");
>> }
>> return parent::beforeFind($event, $query, $options, $primary);
>> }
>>
>> That will prevent adding more order clauses than you'd need.
>>
>> On Monday, January 19, 2015 at 4:04:09 PM UTC+1, Ernesto wrote:
>>>
>>> Hi all
>>>
>>> i noticed that the variable "order", used in cake 1.x/2.x models to 
>>> alter the default table sort, has gone.
>>> i haven't found any hint in the 3.0 cookbook so i'm asking: what's the 
>>> best practice to do this in 3.0?
>>>
>>> i did this:
>>>
>>> public function beforeFind ($event, $query, $options, $primary) {
>>> $query->order("nome");
>>> return parent::beforeFind($event, $query, $options, $primary);
>>> }
>>>
>>> is that right?
>>>
>>> Sorry for my engRish
>>>
>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Cakephp 3.0 Get and Modify Query conditions in beforeFind function

2015-01-19 Thread God bless
Hi Jose,

I gone through both of the plugin links you provided, It seems they are
complicated and do not meet my requirements.

I am trying to write a generic solution to filter records with less code.
Is there any way to get original conditions from query object as an array
format.

For e.g.

$this->paginate = ['conditions'=>['Users.active'=>1]];

I want original conditions in beforeFind method like

function beforeFind(Event $event, Query $query, $options, $primary) {
$orgCondtions = $query->clause('where'); //it returns Expression Object

$orgCondtions = convertExpressionObjectToArray($orgCondtions);
pr($orgCondtions);
output should be  array('Users.active'=>1)
}


I am looking for a way to convert Expression Object to Array. Please help
me if possible.

Thanks in advance.



On Mon, Jan 19, 2015 at 4:22 PM, José Lorenzo  wrote:

> Sorry, I forgot to answer... What you are doing sounds similar to what
> some plugins are doing as well. Please try these:
>
> https://github.com/skie/plum_search
>
> https://github.com/FriendsOfCake/search
>
> As for the second case. I suggest doing as I suggested at the beginning,
> use the query options to hint the beforeFind() or any other finder method
> on what to do or overwrite. That way you can avoid traversing the
> conditions tree.
>
> If you are in absolute need of inspecting the where clause and modifying
> stuff, you will need to do as follows:
>
> $query->clause('where')->traverse(function ($expression) {
> if ($expression instanceof \Cake\Database\Expression\Comparison) {
> if ($expression->getField() === 'Users.active' &&
> $expression->getValue() === true) {
>  $expression->setValue(false);
> }
> }
> });
>
> But that can get a bit complicated and difficult to read. Hence my
> suggestion to treat the Query as a command by passing options to it.
>
>
> On Monday, January 19, 2015 at 10:32:22 AM UTC+1, Cake Developer wrote:
>>
>> Hi Experts,
>>
>> any help?
>>
>> Thanks in advance.
>>
>> On Friday, January 16, 2015 at 12:47:39 AM UTC+5:30, José Lorenzo wrote:
>>>
>>> Even though that is possible you are tying to do it the hard way. The
>>> easiest way you can implement the same is by using the query as a "command"
>>> object,
>>> thus instructing the custom finders to do stuff based on the passed
>>> options. An example
>>>
>>> $table->find('forUser', ['user' => $user])->find('withStatus', ['status'
>>> => 'active']);
>>>
>>> Then in your table you would create your finders this way:
>>>
>>> public function finWithStatus($query, $options) {
>>> if (!empty($options['user'])) {
>>>  // The user is available from the previous finder, I can add
>>> more conditions here based on that
>>> }
>>> }
>>>
>>>
>>> I guess the best way I can help you find the best strategy is if you
>>> mention what exactly you are trying to do :D
>>> On Thursday, January 15, 2015 at 3:26:09 PM UTC+1, Cake Developer wrote:

 Hello,

 I am trying to get and modify query conditions in beforeFind function
 of Behaviour.

 function beforeFind(Event $event, Query $query, $options, $primary) {
// here is what I tried so far.
 $conditions = $query->clause('where');
 // this gives me Object of Expression Interface and I am not able to
 convert it in condition array like we have in cakephp 2.x

 //what I want to achieve...
 //I want to modify existing conditions in query.
 //I want to add new condition in query

 }

 I spent last 2 days but could not figure out any solution.
 Thanks for any help you may be able to provide regarding this.

  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0 change default table order

2015-01-19 Thread Ernesto
Shouldn't Cake itself take care of useless clauses?

Il giorno lunedì 19 gennaio 2015 16:57:43 UTC+1, José Lorenzo ha scritto:
>
> That's almost right. I would change it a bit by doing this:
>
> public function beforeFind ($event, $query, $options, $primary) {
> $order = $query->clause('order');
> if ($order === null || !count($order)) {
>  $query->order("nome");
> }
> return parent::beforeFind($event, $query, $options, $primary);
> }
>
> That will prevent adding more order clauses than you'd need.
>
> On Monday, January 19, 2015 at 4:04:09 PM UTC+1, Ernesto wrote:
>>
>> Hi all
>>
>> i noticed that the variable "order", used in cake 1.x/2.x models to alter 
>> the default table sort, has gone.
>> i haven't found any hint in the 3.0 cookbook so i'm asking: what's the 
>> best practice to do this in 3.0?
>>
>> i did this:
>>
>> public function beforeFind ($event, $query, $options, $primary) {
>> $query->order("nome");
>> return parent::beforeFind($event, $query, $options, $primary);
>> }
>>
>> is that right?
>>
>> Sorry for my engRish
>>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0 change default table order

2015-01-19 Thread Ernesto
Nice thought

Thank you

Il giorno lunedì 19 gennaio 2015 16:57:43 UTC+1, José Lorenzo ha scritto:
>
> That's almost right. I would change it a bit by doing this:
>
> public function beforeFind ($event, $query, $options, $primary) {
> $order = $query->clause('order');
> if ($order === null || !count($order)) {
>  $query->order("nome");
> }
> return parent::beforeFind($event, $query, $options, $primary);
> }
>
> That will prevent adding more order clauses than you'd need.
>
> On Monday, January 19, 2015 at 4:04:09 PM UTC+1, Ernesto wrote:
>>
>> Hi all
>>
>> i noticed that the variable "order", used in cake 1.x/2.x models to alter 
>> the default table sort, has gone.
>> i haven't found any hint in the 3.0 cookbook so i'm asking: what's the 
>> best practice to do this in 3.0?
>>
>> i did this:
>>
>> public function beforeFind ($event, $query, $options, $primary) {
>> $query->order("nome");
>> return parent::beforeFind($event, $query, $options, $primary);
>> }
>>
>> is that right?
>>
>> Sorry for my engRish
>>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0 change default table order

2015-01-19 Thread José Lorenzo
That's almost right. I would change it a bit by doing this:

public function beforeFind ($event, $query, $options, $primary) {
$order = $query->clause('order');
if ($order === null || !count($order)) {
 $query->order("nome");
}
return parent::beforeFind($event, $query, $options, $primary);
}

That will prevent adding more order clauses than you'd need.

On Monday, January 19, 2015 at 4:04:09 PM UTC+1, Ernesto wrote:
>
> Hi all
>
> i noticed that the variable "order", used in cake 1.x/2.x models to alter 
> the default table sort, has gone.
> i haven't found any hint in the 3.0 cookbook so i'm asking: what's the 
> best practice to do this in 3.0?
>
> i did this:
>
> public function beforeFind ($event, $query, $options, $primary) {
> $query->order("nome");
> return parent::beforeFind($event, $query, $options, $primary);
> }
>
> is that right?
>
> Sorry for my engRish
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


3.0 change default table order

2015-01-19 Thread Ernesto
Hi all

i noticed that the variable "order", used in cake 1.x/2.x models to alter 
the default table sort, has gone.
i haven't found any hint in the 3.0 cookbook so i'm asking: what's the best 
practice to do this in 3.0?

i did this:

public function beforeFind ($event, $query, $options, $primary) {
$query->order("nome");
return parent::beforeFind($event, $query, $options, $primary);
}

is that right?

Sorry for my engRish

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Session date missing after redirect

2015-01-19 Thread kdubya
Another factor that might have a bearing on this: the old server had PHP 
5.2.17 - the new server has 5.4.36.

In my original post I said I had a CakePHP 2.3 and a 1.3 app that were 
misbehaving. When I switched the 1.3 app to use Session.default='cake', it 
started working. Now I can switch it back to 'php' and it still works. The 
2.3 app still does not retain the session data after redirect (everything 
else works).

Weird

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Session date missing after redirect

2015-01-19 Thread kdubya
I have tried changing the Session settings in core.php. I have tried both 
Configure::write('Session', array('defaults' => 'cake')); and 'database'. 
Each time I do that my error.log fills up with repeated errors that begin:
2015-01-18 17:15:13 Error: [CakeSessionException] Unable to configure the 
session, setting session.auto_start failed.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Cakephp 3.0 Get and Modify Query conditions in beforeFind function

2015-01-19 Thread José Lorenzo
Sorry, I forgot to answer... What you are doing sounds similar to what some 
plugins are doing as well. Please try these:

https://github.com/skie/plum_search

https://github.com/FriendsOfCake/search

As for the second case. I suggest doing as I suggested at the beginning, 
use the query options to hint the beforeFind() or any other finder method 
on what to do or overwrite. That way you can avoid traversing the 
conditions tree.

If you are in absolute need of inspecting the where clause and modifying 
stuff, you will need to do as follows:

$query->clause('where')->traverse(function ($expression) {
if ($expression instanceof \Cake\Database\Expression\Comparison) {
if ($expression->getField() === 'Users.active' && 
$expression->getValue() === true) {
 $expression->setValue(false);
}
}
});

But that can get a bit complicated and difficult to read. Hence my 
suggestion to treat the Query as a command by passing options to it.

On Monday, January 19, 2015 at 10:32:22 AM UTC+1, Cake Developer wrote:
>
> Hi Experts,
>
> any help?
>
> Thanks in advance.
>
> On Friday, January 16, 2015 at 12:47:39 AM UTC+5:30, José Lorenzo wrote:
>>
>> Even though that is possible you are tying to do it the hard way. The 
>> easiest way you can implement the same is by using the query as a "command" 
>> object,
>> thus instructing the custom finders to do stuff based on the passed 
>> options. An example
>>
>> $table->find('forUser', ['user' => $user])->find('withStatus', ['status' 
>> => 'active']);
>>
>> Then in your table you would create your finders this way:
>>
>> public function finWithStatus($query, $options) {
>> if (!empty($options['user'])) {
>>  // The user is available from the previous finder, I can add 
>> more conditions here based on that
>> }
>> }
>>
>>
>> I guess the best way I can help you find the best strategy is if you 
>> mention what exactly you are trying to do :D
>> On Thursday, January 15, 2015 at 3:26:09 PM UTC+1, Cake Developer wrote:
>>>
>>> Hello,
>>>
>>> I am trying to get and modify query conditions in beforeFind function of 
>>> Behaviour.
>>>
>>> function beforeFind(Event $event, Query $query, $options, $primary) {
>>>// here is what I tried so far.
>>> $conditions = $query->clause('where');
>>> // this gives me Object of Expression Interface and I am not able to 
>>> convert it in condition array like we have in cakephp 2.x
>>>
>>> //what I want to achieve... 
>>> //I want to modify existing conditions in query.
>>> //I want to add new condition in query
>>>
>>> }
>>>
>>> I spent last 2 days but could not figure out any solution.
>>> Thanks for any help you may be able to provide regarding this.
>>>
>>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Cakephp 3.0 Get and Modify Query conditions in beforeFind function

2015-01-19 Thread Cake Developer
Hi Experts,

any help?

Thanks in advance.

On Friday, January 16, 2015 at 12:47:39 AM UTC+5:30, José Lorenzo wrote:
>
> Even though that is possible you are tying to do it the hard way. The 
> easiest way you can implement the same is by using the query as a "command" 
> object,
> thus instructing the custom finders to do stuff based on the passed 
> options. An example
>
> $table->find('forUser', ['user' => $user])->find('withStatus', ['status' 
> => 'active']);
>
> Then in your table you would create your finders this way:
>
> public function finWithStatus($query, $options) {
> if (!empty($options['user'])) {
>  // The user is available from the previous finder, I can add more 
> conditions here based on that
> }
> }
>
>
> I guess the best way I can help you find the best strategy is if you 
> mention what exactly you are trying to do :D
> On Thursday, January 15, 2015 at 3:26:09 PM UTC+1, Cake Developer wrote:
>>
>> Hello,
>>
>> I am trying to get and modify query conditions in beforeFind function of 
>> Behaviour.
>>
>> function beforeFind(Event $event, Query $query, $options, $primary) {
>>// here is what I tried so far.
>> $conditions = $query->clause('where');
>> // this gives me Object of Expression Interface and I am not able to 
>> convert it in condition array like we have in cakephp 2.x
>>
>> //what I want to achieve... 
>> //I want to modify existing conditions in query.
>> //I want to add new condition in query
>>
>> }
>>
>> I spent last 2 days but could not figure out any solution.
>> Thanks for any help you may be able to provide regarding this.
>>
>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.