Re: Complex find

2010-08-30 Thread milimber
Thanks for the start.  It works great!

On Aug 27, 11:49 pm, "eugenioc...@hotmail.com" 
wrote:
> Have you try making joins intead of subselects? the subselects are not
> recommended because they usually are very slow. Joins are really
> faster.
>
> Try with something like this;
>
> $options = array(
>   'recursive'=>1,
>   'conditions'=>array(
>     'Encounter.encounterStartTimeStamp >= 2010-08-26'
>   ),'joins'=>array(
>     array(
>       'type'=>'INNER',
>       'table' => 'entryReasons',
>       'alias' => 'entryReason',
>       'conditions'=>array(
>         'Encounter.entryReason_id=entryReason.id AND
> `entryReason`.`ReasonName` LIKE "SUB%"'
>       )
>     )
>   )
> );
>
> $this->Model->find('all',$options);
>
> Cheers!, Eugenio Fage
>
> On 27 ago, 21:59, milimber  wrote:
>
>
>
> > I need to translate this query into afind() statement
>
> > select id, `encounterStartTimeStamp`, `entryReason_id` from
> > `encounters` where encounterStartTimeStamp >= '2010-08-26' and
> > `encounters`.`entryReason_id` in (SELECT `entryReasons`.`ID` FROM
> > `entryReasons` WHERE `ReasonName` LIKE "SUB%")
>
> > I have looked over the docs for thefindfunction and i see the
> > example of using an array to run the SELECT IN: array(    "Post.title"
> > => array("First post", "Second post", "Third post")) But since my
> > SELECT IN is a query its self im not sure on how to proceed.  I have
> > tried:
>
> > $conditions = array('Encounter.encounterStartTimeStamp >=' =>
> > '2010-08-26',
> >                                 'Encounter.entryReason_id' => 'SELECT
> > `entryReasons`.`ID` FROM `entryReasons` WHERE `ReasonName` LIKE "SUB
> > %"');
>
> > Im kinda lost here.. any help would be appreciated
>
> > 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


Complex find

2010-08-27 Thread milimber
I need to translate this query into a find() statement

select id, `encounterStartTimeStamp`, `entryReason_id` from
`encounters` where encounterStartTimeStamp >= '2010-08-26' and
`encounters`.`entryReason_id` in (SELECT `entryReasons`.`ID` FROM
`entryReasons` WHERE `ReasonName` LIKE "SUB%")

I have looked over the docs for the find function and i see the
example of using an array to run the SELECT IN: array("Post.title"
=> array("First post", "Second post", "Third post")) But since my
SELECT IN is a query its self im not sure on how to proceed.  I have
tried:

$conditions = array('Encounter.encounterStartTimeStamp >=' =>
'2010-08-26',
'Encounter.entryReason_id' => 'SELECT
`entryReasons`.`ID` FROM `entryReasons` WHERE `ReasonName` LIKE "SUB
%"');

Im kinda lost here.. any help would be appreciated

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: preprocess data returned from SELECT

2010-08-25 Thread milimber
I need the value to be converted as the query returns results to the
model.  I cant convert after the fact
because an association query is run immediately after the initial
query.

On Aug 25, 9:06 am, Jon Bennett  wrote:
> > I have a column defined as a varbinary() field.  I need to convert the
> > data returned from the query to hex before its applied to the model.
> > The resulting data is being used in a second query to pull related
> > datasets. I have added a column type hex to the db_mysql.php columns
> > array and each varbinary() field is recognized as that type.  What
> > function do i need to look at/change to accomplish this?
>
> perhaps you could wrap this up into a single method, looping over it
> in an afterFind (or just on the results) before running the second
> query?
>
> J
>
> --
> jon bennett -www.jben.net- blog.jben.net

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


preprocess data returned from SELECT

2010-08-25 Thread milimber
I have a column defined as a varbinary() field.  I need to convert the
data returned from the query to hex before its applied to the model.
The resulting data is being used in a second query to pull related
datasets. I have added a column type hex to the db_mysql.php columns
array and each varbinary() field is recognized as that type.  What
function do i need to look at/change to accomplish 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