Re: $this->...->query("...");

2010-04-07 Thread Dominik Kukacka
Hello, I dunno what I have done but now it works very vell. sry for wasting your time!! Enjoy, Dominik 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 "C

Re: $this->...->query("...");

2010-03-31 Thread John Andersen
I suggest you turn on debug and print out what is returned from the query, because the query is going straight to the database - CakePHP is not doing anything to it! So what you see in your debug information in your first post is not related to this query! What your first post debug information

Re: $this->...->query("...");

2010-03-31 Thread Dominik Kukacka
Hey my complete function is: $user = $this->Auth->user(); $this->Planet->recursive = 0; $planets = $this->Planet->query("SELECT * FROM planets AS Planet LEFT OUTER JOIN buildings AS Building

Re: $this->...->query("...");

2010-03-31 Thread John Andersen
We need more information! How are you realizing your query - are you using CakePHP models find or query method? Please show the code where you are using your query! Enjoy, John On Mar 31, 6:18 pm, Dominik Kukacka wrote: > Hey everyone, > > i tried to make an join query on two tables! > > my qu

$this->...->query("...");

2010-03-31 Thread Dominik Kukacka
Hey everyone, i tried to make an join query on two tables! my query is: SELECT * FROM planets AS Planet LEFT OUTER JOIN buildings AS Building ON (Planet.id = Building.planet_id) WHERE Building.user_id=1; so, the query works well in my PMA and in Workbench (CL), but in cakePHP it ma

Re: how to execute this query with cakephp

2010-01-20 Thread Cariolano
You can to use something as $this->Model->updateAll(array('Model.field +=' =>'Model.field', array ('Model.id' => '$id'); On 17 jan, 23:15, Saleh Souzanchi wrote: > how to execute this query with cakephp : > > update table_name

Re: how to execute this query with cakephp

2010-01-18 Thread djogo
//bin.cakephp.org/view/429049354 > > On Jan 18, 2:52 am, Saleh Souzanchi wrote: > > > Is there another way? > > > On Jan 18, 4:46 am, Jon Bennett wrote: > > > > > how to execute this query with cakephp : > > > > > update table_name set hit = hi

Re: how to execute this query with cakephp

2010-01-18 Thread WyriHaximus
Afaik not thats why I wrote this function for in my appModel a while ago: http://bin.cakephp.org/view/429049354 On Jan 18, 2:52 am, Saleh Souzanchi wrote: > Is there another way? > > On Jan 18, 4:46 am, Jon Bennett wrote: > > > > how to execute this query with cak

Re: how to execute this query with cakephp

2010-01-17 Thread Saleh Souzanchi
Is there another way? On Jan 18, 4:46 am, Jon Bennett wrote: > > how to execute this query with cakephp : > > > update table_name set hit = hit+1 > > $this->Table->query('update table set hit = hit+1); > > j > > -- > jon bennett -www.jben.net- bl

Re: how to execute this query with cakephp

2010-01-17 Thread Jon Bennett
> how to execute this query with cakephp : > > update table_name set hit = hit+1 $this->Table->query('update table set hit = hit+1); j -- jon bennett - www.jben.net - blog.jben.net Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakeP

how to execute this query with cakephp

2010-01-17 Thread Saleh Souzanchi
how to execute this query with cakephp : update table_name set hit = hit+1 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 po

Re: How to make this query the Cake way?

2009-10-13 Thread Amit Rawat
Try the Ad-hoc joins:- http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php

Re: How to make this query the Cake way?

2009-10-13 Thread lapinski
ot > Robot belongsTo User > > I want to get related robots based on his tags. More tags in common, > more related. > > So, whats the way to put this query using $this->Robot->find(...) or > $this->Robot->RobotsTag->find(...) > > SELECT count(tag_id) as to

How to make this query the Cake way?

2009-10-13 Thread Xoubaman
Robot HABTM Tag User hasMany Robot Robot belongsTo User I want to get related robots based on his tags. More tags in common, more related. So, whats the way to put this query using $this->Robot->find(...) or $this->Robot->RobotsTag->find(...) SELECT count(tag_id) a

Re: How can I do this query in CakePHP 1.1.x

2009-04-02 Thread keogh
Well, I solved my issue making the query with SELECT COUNT(*) to get the selected rows. Thanks for your advices On 2 abr, 10:28, keogh wrote: > Thanks Reggie, but the problem is that I have to use CakePHP v1.1.x, > so I need a way to do that query in CakePHP or I need to do the query > but it s

Re: How can I do this query in CakePHP 1.1.x

2009-04-02 Thread keogh
Thanks Reggie, but the problem is that I have to use CakePHP v1.1.x, so I need a way to do that query in CakePHP or I need to do the query but it should return only the affected rows or a resource type which I can use it to know the affected rows, I don't want that the query return the data. Than

Re: How can I do this query in CakePHP 1.1.x

2009-04-02 Thread keogh
Thanks Reggie, but the problem is that I have to use CakePHP v1.1.x, so I need a way to do that query in CakePHP or I need to do the query but it should return only the affected rows or a resource type which I can use it to know the affected rows, I don't want that the query return the data. Than

Re: How can I do this query in CakePHP 1.1.x

2009-04-01 Thread Reggie Mason
I don't know for CakePHP v1.1.x. However, if you use CakePHP v1.2.2 - -- Here is the User Model array( 'foreignKey'=>false, 'type'=>'INNER', 'conditions'=>array('Page.user_id=User.id'),

How can I do this query in CakePHP 1.1.x

2009-04-01 Thread keogh
ilike '%$variable%' AND pages.page_status = '1' AND pages.allow_page = '1' ORDER BY users.last_name ASC LIMIT $limit OFFSET $offset Where $variable, $limit and $offset are variables. I would like to know how can I make this query in CakePHP 1.1.x using the functions

Re: How would I write this query

2008-12-27 Thread gearvOsh
This is what I came up with, I dont know if theres another solution. Also im completely lost how to paginate this. function getMyFriends($user_id, $status = 'approved', $limit = 5) { $friends = $this->find('all', array( 'fields' => array('Friend.*')

Re: How would I write this query

2008-12-27 Thread gearvOsh
I got something working on this but I ran into a problem. When joining the user table to the friend data, I dont know if its the friend_id or the user_id. So I will have to do some filtering and extra queries after i grab all friends. --~--~-~--~~~---~--~~ You recei

Re: How would I write this query

2008-12-27 Thread Arthur Pemberton
Assuming that translates to: SELECT Friend.*, User.username, User.avatar, User.handler FROM friends AS Friend, INNER JOIN users AS User ON User.id = Friend.user_id WHERE Friend.status = 'approved' AND ( (Friend.user_id = ':us

Re: How would I write this query

2008-12-27 Thread gearvOsh
Snippets of the code: CREATE TABLE IF NOT EXISTS `friends` ( `user_id` int(10) unsigned NOT NULL, `friend_id` int(10) unsigned NOT NULL, `status` enum('approved','pending') NOT NULL default 'pending', `requestTime` int(10) NOT NULL, KEY `user_id` (`user_id`), KEY `friend_id` (`friend_

RE: How would I write this query

2008-12-27 Thread Steven Wright
What do your tables, models and controllers look like? -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of gearvOsh Sent: Saturday, December 27, 2008 7:48 PM To: CakePHP Subject: How would I write this query Im a bit new to the model

How would I write this query

2008-12-27 Thread gearvOsh
Im a bit new to the model system, trying to understand how I would do a query like so. SELECT Friend.*, User.username, User.avatar, User.handler FROM friends AS Friend, users AS User WHERE Friend.status = 'approved' AND ((user_id = ':user_id') OR (friend_id = ':user_id')) AND User.id = Friend.use

Re: I'm not sure how to write this query...

2008-12-27 Thread Webweave
I would do something like (note that you'll need to modify to fit your data model and field names): $posts_w_tags = $this->Post->Tag->find('all', array( 'conditions' => array(

Re: I'm not sure how to write this query...

2008-12-27 Thread Andrew McCafferty
Hi Kyle, Here's a function you could try in your Post model -> http://bin.cakephp.org/view/607120740 I've given it a default of 5 tags if called with no params. Obviously you can change this to suit or override it when you call it from your controller. e.g. $this->Post->postCountByTagCount(2)

Re: I'm not sure how to write this query...

2008-12-27 Thread Kyle Decot
Tags are in their own table. They are associated to the blog model via a HABTM relationship. On Dec 27, 2:41 am, gearvOsh wrote: > How is your database setup? Are tags a column in the blog table or is > it its own table? --~--~-~--~~~---~--~~ You received this mes

Re: I'm not sure how to write this query...

2008-12-26 Thread gearvOsh
How is your database setup? Are tags a column in the blog table or is it its own table? --~--~-~--~~~---~--~~ 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 T

I'm not sure how to write this query...

2008-12-26 Thread Kyle Decot
I'm trying to write a query that finds how many blog posts have more then x number of tags. Could anyone provide me with an example of how to do this? I would be most grateful. Thank you as always. --~--~-~--~~~---~--~~ You received this message because you are

Re: Is it possible to make this query with the find method?

2008-12-18 Thread Rob
Funny, your original SQL said NOT NULL, maybe that was your problem ;-) On Dec 18, 2:07 pm, Ramiro Araujo wrote: > Hah, yes I see. thanks for the response. > > btw, I need i.id IS NULL, not IS NOT NULL > > On Dec 18, 7:59 pm, AD7six wrote: > > > On Dec 18, 9:50 pm, Ramiro Araujo wrote: > > > >

Re: Is it possible to make this query with the find method?

2008-12-18 Thread Ramiro Araujo
Hah, yes I see. thanks for the response. btw, I need i.id IS NULL, not IS NOT NULL On Dec 18, 7:59 pm, AD7six wrote: > On Dec 18, 9:50 pm, Ramiro Araujo wrote: > > > > > no, I'm trying stuff like this: > > $data = $this->User->find('all', > >         array( > >                 'fields' => arra

Re: Is it possible to make this query with the find method?

2008-12-18 Thread Ramiro Araujo
OK!! got it working! Here it is: $this->User->unbindModel(array('hasMany' => array('Invitation'))); $this->User->bindModel(array('hasOne' => array('Invitation'))); $data = $this->User->find('all', array( 'fields' => array('User.*', 'Invitation.*'), 'condit

Re: Is it possible to make this query with the find method?

2008-12-18 Thread AD7six
On Dec 18, 9:50 pm, Ramiro Araujo wrote: > no, I'm trying stuff like this: > $data = $this->User->find('all', >         array( >                 'fields' => array('User.*', 'Invitation.*'), >                 'conditions' => array( >                                 'Invitation.id' => NULL >    

Re: Not Sure How To Write This Query

2008-12-18 Thread AD7six
On Dec 18, 8:27 pm, Kyle Decot wrote: > I have a Skateparks Model and a Photos Model. I want to query the > Skateparks model and get the number of skateparks that have 1 photos, > 2 photos, etc. I'm not really sure how to go about this. > > Any help would be greatly appreciated. Thank you. you

Re: Is it possible to make this query with the find method?

2008-12-18 Thread Ramiro Araujo
no, I'm trying stuff like this: $data = $this->User->find('all', array( 'fields' => array('User.*', 'Invitation.*'), 'conditions' => array( 'Invitation.id' => NULL ), 'limit' => 100,

Re: Is it possible to make this query with the find method?

2008-12-18 Thread Rob
Probably a dumb question, but did you try a NOT condition on your find? array ("not" => array ( "Invitation.id" => null, ) ) http://book.cakephp.org/view/74/Complex-Find-Conditions On Dec 18, 10:58 am, Ramiro Araujo wrote: > Hi all > > I wasn't really fond to the find method bef

Re: Not Sure How To Write This Query

2008-12-18 Thread Rob
The cake way is to do a find('count'), so you'd do something like $this->Skatepark->Photo->find('count') http://book.cakephp.org/view/449/find Alternatively, you can cheat and use a correlated sub-query as one of your fields in the find, although I'm sure this violates all sorts of Cake principl

Not Sure How To Write This Query

2008-12-18 Thread Kyle Decot
I have a Skateparks Model and a Photos Model. I want to query the Skateparks model and get the number of skateparks that have 1 photos, 2 photos, etc. I'm not really sure how to go about this. Any help would be greatly appreciated. Thank you. --~--~-~--~~~---~--~~

Is it possible to make this query with the find method?

2008-12-18 Thread Ramiro Araujo
Hi all I wasn't really fond to the find method before, and made a lot of custom query()ies. Now im using it a lot, with quite nice results. Still, im having trouble trying to build a query. Let me explain the situation. I have 2 tables: a users table, and a invitations table. User hasMany Invita

Re: Why is this query returning such an odd array?

2008-12-15 Thread Rob
The array doesn't really look odd, it's doing exactly what Cake normally does and encapsulating results in an array. If I had to guess it would probably be due to the way your model is structured, and how Cake is building the SQL based on the data you are giving it. Look at the generated query (

Re: Why is this query returning such an odd array?

2008-12-11 Thread the_woodsman
I think this is because it's nigh on impossible to determine the table that a function, like COUNT or SUM etc, is getting its data from. For more information and some work-arounds, see: http://groups.google.com/group/cake-php/browse_thread/thread/2fa2cd69422dfcf/81e7a5ea50266a15 On Dec 11, 4

Why is this query returning such an odd array?

2008-12-11 Thread matth
The keywords query in the view() function is returning the following array: Array ( [Hit] => Array ( [keyword] => banana ) [0] => Array ( [count] => 1 ) ) I am going for: Array ( [Hit] => Array ( [keyword] => banana, [count] => 1 ) ) class ItemsController extends AppController { var $nam

Re: How to Handle Special Fields on $this->query() statements - Forking from "MySQL Having Clausule "

2008-10-15 Thread David C. Zentgraf
/ Fields should contain '((something)) AS Model__field' >> >> Hope this helps. >> >> On 15 Oct 2008, at 02:59, Dérico Filho wrote: >> >> >> >>> Hello guys, >> >>> So I asked a question about having clauses using $this-&

Re: How to Handle Special Fields on $this->query() statements - Forking from "MySQL Having Clausule "

2008-10-15 Thread grigri
t; > > > > Hello guys, > > > So I asked a question about having clauses using $this->Model->find() > > method, and the answer was daunting, in my opinion: use in Model Class > > $this->query() method within a custom method... OK. I shall do it this > >

Re: How to Handle Special Fields on $this->query() statements - Forking from "MySQL Having Clausule "

2008-10-14 Thread David C. Zentgraf
ld' Hope this helps. On 15 Oct 2008, at 02:59, Dérico Filho wrote: > > Hello guys, > > > So I asked a question about having clauses using $this->Model->find() > method, and the answer was daunting, in my opinion: use in Model Class > $this->query() method within a

Re: How to Handle Special Fields on $this->query() statements - Forking from "MySQL Having Clausule "

2008-10-14 Thread ORCC
Use Set classs for manipulating your find's results, particularly the Set::combine method maybe helpful for you.. http://book.cakephp.org/view/662/combine --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" gr

How to Handle Special Fields on $this->query() statements - Forking from "MySQL Having Clausule "

2008-10-14 Thread Dérico Filho
Hello guys, So I asked a question about having clauses using $this->Model->find() method, and the answer was daunting, in my opinion: use in Model Class $this->query() method within a custom method... OK. I shall do it this way. One of the problems I face using $this->query() is:

Re: how to perform this query

2007-08-01 Thread rtanz
ah ok tnx fixed that, any help on my last post for inserting the $ret data returned from the tasklist model into the tasklist controller's $this->data ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" gro

Re: how to perform this query

2007-07-31 Thread Beertigger
You've got $taklist_data and (later) $tasklist_data On Jul 31, 2:17 pm, rtanz <[EMAIL PROTECTED]> wrote: > why is it a typo? function beforeSave() { $taklist_data = $this->Tasklist->query("SELECT `memberships`.`module_id`, `memberships`.`user_id`, `tasks`.`id`as task_id

Re: how to perform this query

2007-07-31 Thread rtanz
$this->set('tasks', $this->Tasklist->Task->generateList()); $this->set('users', $this->Tasklist->User->generateList()); } } } Tasklist model: fu

Re: how to perform this query

2007-07-31 Thread Geoff Ford
in.cakephp.org/view/1697492973 > > this is the part where im getting confused. as far as i can see i need > to use the beforeSave function in the Membership model in order to > trigger this creation of a new record in the tasklist model. however i > am not sure in what way to do this. s

Re: how to perform this query

2007-07-31 Thread rtanz
getting confused. as far as i can see i need to use the beforeSave function in the Membership model in order to trigger this creation of a new record in the tasklist model. however i am not sure in what way to do this. should i put this query code in say tasklist::addtasklist and then call that

Re: how to perform this query

2007-07-31 Thread Geoff Ford
A Membership belongsTo User hasOne TaskList from what I can see. Once you have your associations set up properly try $this->User->TaskList Make sure the associations are set up correctly. You cannot call arbitrary members and just pray that CakePHP will figure out what you mean. It's good but

Re: how to perform this query

2007-07-31 Thread rtanz
why is it a typo? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For

Re: how to perform this query

2007-07-31 Thread Beertigger
Try fixing that typo on 9, first. ; ) --~--~-~--~~~---~--~~ 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 [

Re: how to perform this query

2007-07-31 Thread rtanz
well that is my problem, how should i go about doing this? the Tasklist model itself is not really related to the Membership model. The thing is that when a User is given Membership to a Module, I would like to build a Tasklist for that user (a to do list of things he has to do within this member

Re: how to perform this query

2007-07-31 Thread Chris Hartjes
On 7/31/07, rtanz <[EMAIL PROTECTED]> wrote: > ERROR: > Notice: Undefined property: Membership::$Tasklist in W:\www\cake\app > \models\membership.php on line 9 > > Fatal error: Call to a member function query() on a non-object in W: > \www\cake\app\models\membership.php on line 9 > > > > > Where

how to perform this query

2007-07-31 Thread rtanz
hi i am trying to perform an sql query but am getting an error. This is my membership model, as the action will be triggered whenever a new membership is created. Then i will like to pull the data shown in the sql query and save that in the Tasklist model. here is the code and error: Tasklist->qu

Apparent unwanted query caching when using $this->query in a Model.

2007-04-24 Thread RayChicago
Hello everyone ! My intentions: - to get a (kind of) sequence nr for naming an object - (maybe) save someone a headache My (first) approach was to use the function "query()" in the Model like so: *snip* function getNextSeqNr() { $seqnr = $this->query("SELECT (MAX(It

Re: This->query output

2006-11-07 Thread floepi
Hi, thanks for your reply. You are right - i seem to work against the framework due to my working habbits. I need to get used to cake first i think. Even so - do you know how to create your own query function. It looks really confusing to me. Cheers Phil On Nov 7, 1:33 pm, "lloydhome" <[EMAIL

Re: This->query output

2006-11-07 Thread lloydhome
Phil, For most things it is better to have the data the way it is returned. I would encourage you to work within the framework and not against it. That said, maybe you have some logic that is legacy like I do. I am porting a clumsy mess of code into Cake but it cannot be done all at once. I hav

This->query output

2006-11-07 Thread floepi
Hi all, i was wondering why cake gives me a weird output array for my query Query: SELECT jobName, ujc.id, roleName, userName, disciplineName FROM user_job_con