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

2015-02-27 Thread Cake Developer
Hi, Ok I managed solution. Thanks On Thursday, January 29, 2015 at 8:26:57 PM UTC+5:30, Cake Developer wrote: > > Hi Mark Story, > > any help please? > > thanks > > On Friday, January 23, 2015 at 6:02:46 PM UTC+5:30, Cake Developer wrote: >> >> Hi Josh, >> >> I tried both PlumSearch and Search P

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

2015-01-29 Thread Cake Developer
Hi Mark Story, any help please? thanks On Friday, January 23, 2015 at 6:02:46 PM UTC+5:30, Cake Developer wrote: > > Hi Josh, > > I tried both PlumSearch and Search Plugin in my application and they are > not working as expected. > > They are adding search arguments in existing conditions in qu

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

2015-01-23 Thread Cake Developer
Hi Josh, I tried both PlumSearch and Search Plugin in my application and they are not working as expected. They are adding search arguments in existing conditions in query object. Failing Situation. Existing condition has Users.active = 1 and If new condition array has Users.active = 0 so this

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

2015-01-23 Thread José Lorenzo
What have you tried so far? On Friday, January 23, 2015 at 9:25:21 AM UTC+1, Cake Developer wrote: > > Hi Experts, > > Can anyone solve my problem please? > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message becau

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

2015-01-23 Thread Cake Developer
Hi Experts, Can anyone solve my problem please? -- 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 receivin

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

2015-01-20 Thread Cake Developer
t;> >> 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.acti

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

2015-01-19 Thread José Lorenzo
ts. > > 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]]; >

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

2015-01-19 Thread God bless
. $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 re

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

2015-01-19 Thread José Lorenzo
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')->t

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

2015-01-19 Thread Cake Developer
t; 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 beforeFi

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

2015-01-16 Thread Cake Developer
;", Active, Inactive) etc these should be anything based on configuration [Search][Reset] buttons Users data in HTML table Searchable Behaviour FYI- In Search Component I attach a Search behaviour with current model table and pass predefined Search Form Fields(same we displayed in

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

2015-01-15 Thread José Lorenzo
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, &

Cakephp 3.0 Get and Modify Query conditions in beforeFind function

2015-01-15 Thread Cake Developer
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

Re: add subquery to every find-statement in beforeFind

2012-11-03 Thread bs28723
oogle.com/group/cake-php?hl=en .     If you reply to this email, your message will be added to the discussion below: http://cakephp.1045679.n5.nabble.com/add-subquery-to-every-find-statement-in-beforeFind-tp5712054.html

add subquery to every find-statement in beforeFind

2012-11-02 Thread Mathias R
Hi, i have a model which belongs to another like "model car belongs to rent-time". in table for rent-time there are two timestamps (start and end). now i want to modify every find-statement for model car and add a subquery like this: select *, (select id from rent-time where start >= time() and

Expandable Behavior and beforeFind()

2010-11-17 Thread excess^
I was wondering if anyone has used the Expandable Behavior and created a beforeFind() method that allows you to pull meta data through a condition, as follows: $this->Upload- >find('first',array('conditions'=>array('UploadField.key' => 'width'

BeforeFind not being called but AfterFind is

2010-04-06 Thread Kyle Decot
I have two different models, Skatepark and Weather. I am calling $this- >Skatepark->read(). The Weather's beforeFind() never gets called but it's afterFind() does. Any ideas why this is happening? Check out the new CakePHP Questions site http://cakeqs.org and help others wit

Re: Set containable vars in beforeFind() callback of model

2009-08-23 Thread Dr. Loboto
cket`.`ticket_status` = 'New' AND > `Ticket`.`ticket_support_group_id` = 2 AND `Ticket`.`ticket_status` != > 'Deleted' AND ((`Ticket`.`ticket_client_group_id` = 84) AND > (`ClientUser`.`user_group_id` = 204) AND (((`Ticket`.`ticket_openedby` > = 1024) OR (`Ticket`.`ticket

Re: Set containable vars in beforeFind() callback of model

2009-08-21 Thread Adrian
s` != 'Deleted' AND ((`Ticket`.`ticket_client_group_id` = 84) AND (`ClientUser`.`user_group_id` = 204) AND (((`Ticket`.`ticket_openedby` = 1024) OR (`Ticket`.`ticket_client_user_id` = 1024 LIMIT 51 On 21 Aug, 09:24, Adrian wrote: > Hi > > I am trying to set my contain array f

Re: Set containable vars in beforeFind() callback of model

2009-08-21 Thread Adrian
Btw when I add debug($queryData); it confirms the contain array is present: app\models\ticket.php (line 175) Array ( [conditions] => Array ( [Ticket.ticket_status] => New ) [fields] => Array ( [0] => Ticket.ticket_id ) [joins]

Set containable vars in beforeFind() callback of model

2009-08-21 Thread Adrian
Hi I am trying to set my contain array from within the models beforeFind () callback so a certain model is always contained. I have the following code: function beforeFind($queryData) { // Always contain the client user if(empty($queryData['co

Re: Isseu with beforeFind($queryData) in Behaviors

2009-08-14 Thread j0n4s.h4rtm...@googlemail.com
Be aware of this bug when using beforeFind in a behavior to to permission stuff: https://trac.cakephp.org/ticket/2056 If you really want to do such things. To it in afterFind with array filtering (see Set:: and array_) Have fun and good luck. On Aug 13, 2:14 pm, subnoodle wrote: > Hello, &g

Re: Isseu with beforeFind($queryData) in Behaviors

2009-08-13 Thread subnoodle
ds of a model. And exactly there is the difference: Model::beforeFind($queryData) => this appears as the only one in api- doc ModelBehavior::beforeFind(&$model,$query) For me, i really couldn't guess that the header of the one beforeFind is different than another beforeFind-Header, si

Re: Isseu with beforeFind($queryData) in Behaviors

2009-08-13 Thread brian
nditions'][$model->alias.'.YOUR_FIELD' = 'YOUR_CONDITION'; ... should be: $queryData['conditions'][$this->alias.'.YOUR_FIELD'] = 'YOUR_CONDITION'; ... when it's in Model::beforeFind(). When in a Behavior's beforeFind(), you

Re: Isseu with beforeFind($queryData) in Behaviors

2009-08-13 Thread subnoodle
" in models in   general way. > > > So, i put some filtering in beforeFind, first. > > SInce i regognized, that parameter $queryData does not work as > > expected. > > > In CakeDoc is described, that queryData is an arrray of find- > > parameters. But is &#

Re: Isseu with beforeFind($queryData) in Behaviors

2009-08-13 Thread brian
On Thu, Aug 13, 2009 at 8:14 AM, subnoodle wrote: > > Hello, > i'd like to add "ownership-support" in models in   general way. > > So, i put some filtering in beforeFind, first. > SInce i regognized, that parameter $queryData does not work as > expecte

Isseu with beforeFind($queryData) in Behaviors

2009-08-13 Thread subnoodle
Hello, i'd like to add "ownership-support" in models in general way. So, i put some filtering in beforeFind, first. SInce i regognized, that parameter $queryData does not work as expected. In CakeDoc is described, that queryData is an arrray of find- parameters. But is '

Re: Passing extra parameters to a behavior's beforeFind callback method from the controller

2009-04-13 Thread mattalexx
For anyone that's interested, I decided to go a completely different route: http://www.sitepoint.com/forums/showthread.php?t=608370 On Mar 19, 1:49 pm, Miles J wrote: > Oops I meant to say "Your not able to pass controller data to the > behavior". I was thinking something like this. > > In the

Re: Passing extra parameters to a behavior's beforeFind callback method from the controller

2009-03-19 Thread Miles J
Oops I meant to say "Your not able to pass controller data to the behavior". I was thinking something like this. In the controller: $this->Model->data['Thumbnail'] = array('image', 294, 200); Then in then behavior, grab that data. $Model->data['Thumbnail']; --~--~-~--~~

Re: Passing extra parameters to a behavior's beforeFind callback method from the controller

2009-03-19 Thread mattalexx
Something like this? loadModel('IndustryLink'); $this->IndustryLink->actsAs['Thumbnail'] = array('image', 294, 200); $industry_links = $this->IndustryLink->find('all', array( 'conditions' => array('IndustryLink.active <>' => '0'), )); ?> This seems to work, but is there a better

Re: Passing extra parameters to a behavior's beforeFind callback method from the controller

2009-03-19 Thread Miles J
Your not able to pass controller data to the model. You should store the data into the Model object and then use that. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email

Passing extra parameters to a behavior's beforeFind callback method from the controller

2009-03-18 Thread mattalexx
I have a table named 'IndustryLinks'. Each record in that table corresponds to an image file of the company's logo. I store these image files in a directory on the server's filesystem. I have created (rather, I'm trying to create) a behavior class to handle the action of thumbnailing these image

Re: BeforeFind

2009-02-02 Thread Martin Westin
I'd say that beforeFind should be used for thing that you want to run at all times. Instead of doing this in beforeFind you might want to create a custom find which is a good way to enforce custom logic to the find operation while leaving any associations and other internal queries alone.

Re: BeforeFind

2009-02-02 Thread j0n4s.h4rtm...@googlemail.com
t;http://book.cakephp.org/view/73/Retrieving-Your-Data > > > On Feb 1, 11:59 am, Fred wrote: > > > > I am using BeforeFind in my Model to filter based on criteria for a > > > logged in user. This works great and I love how easy this is to do... > > > However, I

Re: BeforeFind

2009-02-01 Thread Fred
Fred On Feb 1, 4:33 pm, Miles J wrote: > In your find() queries, you can add a parameter: 'callbacks' => false > > http://book.cakephp.org/view/73/Retrieving-Your-Data > > On Feb 1, 11:59 am, Fred wrote: > > > I am using BeforeFind in my Model to filter based

Re: BeforeFind

2009-02-01 Thread Miles J
In your find() queries, you can add a parameter: 'callbacks' => false http://book.cakephp.org/view/73/Retrieving-Your-Data On Feb 1, 11:59 am, Fred wrote: > I am using BeforeFind in my Model to filter based on criteria for a > logged in user. This works great and I love how

BeforeFind

2009-02-01 Thread Fred
I am using BeforeFind in my Model to filter based on criteria for a logged in user. This works great and I love how easy this is to do... However, I am running into a problem. There are certain times that I don't want to add the filter. For example I have a tree of company's that a user

beforeFind called one too many times with hasMany?

2008-09-29 Thread Agamon
Hey All, I have a model, hasMany associated-model, and I'm finding when using the beforeFind callback inside associated-model, it is called more times than I'm expecting. For each associated record found it is called (with results like [0][associated-model]), and then for all t

Re: Preventing the execution of beforeFind() on calling an admin function?

2008-01-26 Thread AD7six
On Jan 25, 5:57 pm, powtac <[EMAIL PROTECTED]> wrote: > In the beforeFind() I delete some data of the current user which > should only be in the database for 60 minutes. > But when I want to take a look on the data as admin I dont want to > delete anything... In your mo

Re: Preventing the execution of beforeFind() on calling an admin function?

2008-01-25 Thread [EMAIL PROTECTED]
Write wrappers for the find() function in your Library model. function adminFind() { return $this->find(); } fuction userFind() { $this->deleteStuff(); return $this->find(); } On Jan 25, 9:57 am, powtac <[EMAIL PROTECTED]> wrote: > In the beforeFind() I delete some data o

Re: Preventing the execution of beforeFind() on calling an admin function?

2008-01-25 Thread powtac
In the beforeFind() I delete some data of the current user which should only be in the database for 60 minutes. But when I want to take a look on the data as admin I dont want to delete anything... --~--~-~--~~~---~--~~ You received this message because you are

Re: Preventing the execution of beforeFind() on calling an admin function?

2008-01-25 Thread grigri
it to, which DOES know if the user is an administrator or not. What are you doing in your model's beforeFind() that needs to be deactivated for administrators? On Jan 25, 4:11 pm, powtac <[EMAIL PROTECTED]> wrote: > Hi red, > I'm sorry this seems not to be working in the

Re: Preventing the execution of beforeFind() on calling an admin function?

2008-01-25 Thread powtac
Hi red, I'm sorry this seems not to be working in the (1.2) model: Undefined property: library::$params How can I access to the params in model? powtac --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" gro

Re: Preventing the execution of beforeFind() on calling an admin function?

2008-01-25 Thread red
Don't know any. But you can still put this 'global' things in global AppController. On 25 Sty, 16:49, powtac <[EMAIL PROTECTED]> wrote: > Great! Thanks. > > Is there an other more global solution to prevent before*() after*() > functions to be executed? --~--~-~--~~~-

Re: Preventing the execution of beforeFind() on calling an admin function?

2008-01-25 Thread red
16:39, powtac <[EMAIL PROTECTED]> wrote: > How can I avoid the execution of any before*() function in the modell > when calling an admin function in ancontroller? > > Example:http://www.example.com/admin/libraries/ > > In my Libraries-controller I have a function named admin

Re: Preventing the execution of beforeFind() on calling an admin function?

2008-01-25 Thread powtac
Great! Thanks. Is there an other more global solution to prevent before*() after*() functions to be executed? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cak

Preventing the execution of beforeFind() on calling an admin function?

2008-01-25 Thread powtac
How can I avoid the execution of any before*() function in the modell when calling an admin function in ancontroller? Example: http://www.example.com/admin/libraries/ In my Libraries-controller I have a function named admin_index(). Now the beforeFind() in my model "Library" is cal

Re: how can i use beforeFind to return a field name AS something else?

2008-01-17 Thread [EMAIL PROTECTED]
d twice in the same > form. To differentiate between the two ajax call, the [modelname] > [fieldname] needs to be different. Since I can't change the way the > Ajax method makes the call, I though I'd use beforeFind in the model > to return "SELECT fieldname AS tempname WHERE...".

how can i use beforeFind to return a field name AS something else?

2008-01-17 Thread papajoe
I'm using Ajax calls from the same table and field twice in the same form. To differentiate between the two ajax call, the [modelname] [fieldname] needs to be different. Since I can't change the way the Ajax method makes the call, I though I'd use beforeFind in the model to

how does Cake 1.1 order its JOIN clauses (using a beforeFind)

2007-09-05 Thread twgillis
a join on User.id is invoked before users is aliased? the JOIN to relationships is shoved into the query via a beforeFind() call - it just adds the hardcoded sql into $queryData["joins"] (in theory this is to filter the display of data by a user's social network). is there a way to get

RE: beforeFind example

2007-02-25 Thread Mariano Iglesias
Do not modify the queryData as the parameter, but instead return the modified data: function beforeFind($queryData) { if (!empty($queryData['fields'])) { foreach ($this->fieldsRequired as $required_field) {

Re: beforeFind example

2007-02-25 Thread Mikee Freedom
mikee On 23/02/07, Mikee Freedom <[EMAIL PROTECTED]> wrote: > afternoon all, > > a very simple one. all i would like to do is make sure certain fields > are being included in any read / find / findAll. Could someone have a > look at the code and see where my problem might lie?

beforeFind example

2007-02-22 Thread Mikee Freedom
afternoon all, a very simple one. all i would like to do is make sure certain fields are being included in any read / find / findAll. Could someone have a look at the code and see where my problem might lie? function beforeFind(&$queryData) { if (!empty($queryData[&#x