Re: Query Help

2011-06-28 Thread Johan
Are these the conditions for a model related by a HasMany relationship? Most probably CakePHP is using PHP's empty() function [http://php.net/empty] to check the value of the foreignKey. If that's the case, you may want to fill a ticket, but I doubt they would fix it as it would change the current

Query Help

2011-06-27 Thread Krissy Masters
I am submitting a value thru a form, based on the value a var is passed to the query. function getValueSub( $data) { $primary = ( $data['primary'] == 4) ? array(0,1,2) : $data['primary']; return array($this->alias . '.primary' => $primary); } But if zero is the value submitted its not p

Re: Query help

2010-09-04 Thread Mohsin kabir
$params = array( 'conditions' => array("Profile.company Like " => $i."%"), 'fields' => array('Profile.company','Profile.id'), 'contain' => false); $this->find('first', $params); Hope , it will work On Sep 4, 3:49 am, "Dave Maharaj" wrote: > I have this query in the model > > $pa

Re: Query help

2010-09-03 Thread Andras Kende
Dave, 'conditions' => array('Profile.company LIKE' => $i . '%'), http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html Andras Kende http://www.kende.com/ On Sep 3, 2010, at 5:49 PM, Dave Maharaj wrote: > I have this query in the model > > $params = array( > 'conditions' =>

Re: Query help

2010-09-03 Thread Blackymetal
You should use % instead of * On Sep 3, 4:49 pm, "Dave Maharaj" wrote: > I have this query in the model > > $params = array( > > 'conditions' => array( > > 'Profile.company LIKE' => $i.'*'), > > 'fields' => array( > > 'Profile.company', > > 'Profile.id'), > > 'contain' => false); > > $this->fin

Query help

2010-09-03 Thread Dave Maharaj
I have this query in the model $params = array( 'conditions' => array( 'Profile.company LIKE' => $i.'*'), 'fields' => array( 'Profile.company', 'Profile.id'), 'contain' => false); $this->find('first', $params); Where $i is a single letter so I am trying to get the first record sta

Re: Query Help

2009-09-09 Thread WebbedIT
@Miles J - Of course, I was concentrating on using cake to build the SQL so much that I missed the obvious mistake in creating the conditions array. I don't suppose cake would handle the following: array('Post.title LIKE'=>array('%mary%', '%tom%'), 'Post.description LIKE'=>array('%mary%', '%tom%

Re: Query Help

2009-09-08 Thread Miles J
@WebbedIT - Although that is correct, your example wont work. Simply because you have conflicting indexes because they match, so 2 of them would be overwritten. To fix this though you have to wrap them in an array. array(array('Post.title LIKE'=>'%mary%'), array('Post.description LIKE'=>'%mary%')

Re: Query Help

2009-09-08 Thread WebbedIT
I reckon you glossed over Miles J's point without full consideration. Cake will do the OR work for you, consider ... $this->Post->find('all', array( 'conditions' => array( 'Post.status' => 0, 'Post.rank <=' => 0, 'OR' => $convertedSearchString ) )); All you need to do then is pas

RE: Query Help

2009-09-07 Thread Dave Maharaj :: WidePixels.com
Perfect. Works exactly as it should. Thanks. Dave -Original Message- From: Dr. Loboto [mailto:drlob...@gmail.com] Sent: September-07-09 12:07 AM To: CakePHP Subject: Re: Query Help Looks like you just forgot enclose your custom sql into brackets. array( 'Post.status&

Re: Query Help

2009-09-07 Thread Dr. Loboto
Cake 1.2 do not work with PHP 5.3. Downgrade PHP or take cake 1.3-dev or wait for cake 1.3 stable. On Sep 7, 1:12 pm, king wrote: > Yestoday,i  installed cakephp . > > Then,i visitedhttp://127.0.0.1。 > > it displayed : > > Deprecated: Assigning the return value of new by reference is > deprecate

Query Help

2009-09-07 Thread king
Yestoday,i installed cakephp . Then,i visited http://127.0.0.1。 it displayed : Deprecated: Assigning the return value of new by reference is deprecated in E:\Program Files\Apache Software Foundation \Apache2.2\htdocs\cake-1.2\cake\libs\i18n.php on line 109 Deprecated: Assigning the return valu

Re: Query Help

2009-09-06 Thread Dr. Loboto
Looks like you just forgot enclose your custom sql into brackets. array( 'Post.status' => 0, 'Post.rank <=' => $rank, '('.$sql.')' ) On Sep 7, 1:56 am, "Dave Maharaj :: WidePixels.com" wrote: > For some reason this query is pulling more results then that which is > possible. > >

RE: Query Help

2009-09-06 Thread Dave Maharaj :: WidePixels.com
` LIKE '%tom%' OR `Post`.`description` LIKE '%tom%' And not LIKE '%marytom%' It creates a string based on the values entered into the search. -Original Message- From: Miles J [mailto:mileswjohn...@gmail.com] Sent: September-06-09 6:07 PM To: CakePHP Subject: R

Re: Query Help

2009-09-06 Thread Miles J
Why dont you just use the built it or mechanics? 'OR' => array('Post.title LIKE' => '%'. $value .'%', 'Post.description LIKE' => '%'. $value .'%') --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To p

RE: Query Help

2009-09-06 Thread Dave Maharaj :: WidePixels.com
escription` LIKE '%mary%' -Original Message- From: Miles J [mailto:mileswjohn...@gmail.com] Sent: September-06-09 4:42 PM To: CakePHP Subject: Re: Query Help It seems like the OR is breaking it. What does the $sql variable look like? --~--~-~--~~~---~--~

Re: Query Help

2009-09-06 Thread Miles J
It seems like the OR is breaking it. What does the $sql variable look like? --~--~-~--~~~---~--~~ 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 unsubscrib

Query Help

2009-09-06 Thread Dave Maharaj :: WidePixels.com
For some reason this query is pulling more results then that which is possible. I am running a contain $params = array('contain' => false, 'conditions' => array( 'Post.status' => 0, 'Post.rank <=' => $rank, $sql ),

Re: Query help

2007-10-22 Thread grigri
Try something like this: $this->Article->bindModel(array('hasOne' => array( 'Category1' => array('className' => 'ArticleCategory'), 'Category2' => array('className' => 'ArticleCategory') ))); $blah = $this->Article->findAll(array('Category1.name' => 'Blobble', 'Category2.name' => 'Blibble'));

Re: Query help

2007-10-22 Thread LS
Amit I don't really think the declarations are wrong... but there can be duplicate names in the Category model... Here: class Article extends AppModel { var $name = 'Article'; var $hasMany = 'ArticleCategory'; } class ArticleCategory extends AppModel { var $name = 'ArticleCategory'; va

Re: Query help

2007-10-22 Thread Amit Badkas
On 10/22/07, LS <[EMAIL PROTECTED]> wrote: > > > Hello everyone! > I promise I tried searching for this in this group and other sql- > related groups... Maybe I just haven't searched for the right thing... > Or even, maybe my head is not working properly... > > Here's the thing: I have 2 tables. On

Re: Query help

2007-10-22 Thread LS
Not really... This is a one-to-many association... The ArticleCategory field 'name' is what i want to search for. I know I can do a one-to-many relationship... and then, I can grab all the fields and show only those that match the criteria... What I was wanting is for the sql server return me only

Re: Query help

2007-10-22 Thread Charlie van de Kerkhof
I assume that you also have a Category model? Then setup the right associations in Article and Category and ArticleCategory and use the $this->resursive = 1 var in Article or Category to get the associations of that article or category - Charlie On Oct 22, 1:25 pm, LS <[EMAIL PROTECTED]> wrote:

Query help

2007-10-22 Thread LS
Hello everyone! I promise I tried searching for this in this group and other sql- related groups... Maybe I just haven't searched for the right thing... Or even, maybe my head is not working properly... Here's the thing: I have 2 tables. One with articles and one with categories... It goes like t

Re: Simple query help with a compound condition

2007-10-14 Thread MikeK
Thanks francky, that did the trick! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMA

Re: Simple query help with a compound condition

2007-10-14 Thread francky06l
try conditions = array('AND' => array("Obj.length" => '>=6'), "Obj.length' => '<=13'))) On Oct 14, 4:29 am, MikeK <[EMAIL PROTECTED]> wrote: > Can soeone please show me how to code this condition? 3 <= length <= > 13 > > conditions = array("Obj.length" => '>=6', "Obj.length' => '<=13'); > > Only

Simple query help with a compound condition

2007-10-13 Thread MikeK
Can soeone please show me how to code this condition? 3 <= length <= 13 conditions = array("Obj.length" => '>=6', "Obj.length' => '<=13'); Only the second condition is evaluated because conditions['Obj.length'] = '<=13' is what gets set before the find. The BETWEEN condition excludes the endpoi