Re: CakePHP: How to remove LEFT JOIN in updateAll()

2013-08-05 Thread Indrajeet Singh
affected with this error > message: > > UPDATE `files_folders` AS `FilesFolders` LEFT JOIN `course_files` AS > `CourseFile` ON (`FilesFolders`.`account_id` = `CourseFile`.`id`) SET > `FilesFolders`.`deleted` = 0 WHERE `FilesFolders`.`instance_id` = ‘8′ > >

Re: CakePHP: How to remove LEFT JOIN in updateAll()

2013-08-05 Thread Indrajeet Singh
On Wednesday, 12 November 2008 13:27:10 UTC+5:30, Kryptonian wrote: > > Hi, I have this problem that if my model uses a var $belongsTo = array > (), my updateAll() generated statement was affected with this error > message: > > UPDATE `files_folders` AS `FilesFolders` LEFT

Re: Mysql Left join query returns null

2012-07-16 Thread soumavo chatterjee
Remove the quotes. suburb1 ='2'" On Mon, Jul 16, 2012 at 1:00 PM, Ditshwanelo wrote: > This is my query,i dnt knw wat is wrong it was working nd nw it returns > null > $search_query=$this->Suburb->query("SELECT suburbs.*, matchsuburbs.* FROM

Mysql Left join query returns null

2012-07-16 Thread Ditshwanelo
This is my query,i dnt knw wat is wrong it was working nd nw it returns null $search_query=$this->Suburb->query("SELECT suburbs.*, matchsuburbs.* FROM matchsuburbs LEFT JOIN suburbs ON matchsuburbs.suburb2 = suburbs.id WHERE matchsuburbs.suburb1 ='2'"); print_r($se

Re: left join

2012-03-05 Thread Milina Udara
Problem solved $allleaves = $this->Leavetype->find('all', array( 'joins' => array( array( 'table' => 'vacations', 'alias' => 'vacationsJoin', 'type' => 'left', 'conditions' => array('vacation

Re: HABTM, LEFT JOIN and cakephp

2010-05-25 Thread WebbedIT
So you're after a list of agents who are not assigned to a branch? How about using counter_cache_habtm to count how many branches each agent belongs to and how many agents each branch has? http://bakery.cakephp.org/articles/view/counter-cache-behavior-for-habtm-relations Otherwise you are looking

HABTM, LEFT JOIN and cakephp

2010-05-24 Thread Heidi Grab
t one) agents_branches (for joining the two together) In the model, the HABTM relationship is defined accordingly. To get a list of agents that are not assigned to any branch, I need the following code: SELECT * FROM `agents` LEFT JOIN agents_branches ON agents_branches.agent_id = agents.id

Re: Doing a mysql left join

2009-09-13 Thread Whitty
d hold an array with the users > addressdetails, calling view.cpt but I'm getting the error: > > Notice (8): Undefined property: FullnamesController::$Addresses [APP/ > controllers/fullnames_controller.php, line 10] > Fatal error: Call to a member function read() on

Re: Doing a mysql left join

2009-09-11 Thread Whitty
Notice (8): Undefined property: FullnamesController::$Addresses [APP/ controllers/fullnames_controller.php, line 10] Fatal error: Call to a member function read() on a non-object in /controllers/fullnames_controller.php on line 10 Would be grateful for some pointers? Thanks Darren On Sep 11,

Doing a mysql left join

2009-09-11 Thread Whitty
Hi, I'm a bit new to this, I'm trying to do a left join. I have a db with People table (id:name_id) in it a linking table (linking name_id to addr_id) and an address table with the index (addr_id) the sql command I usually use is: SELECT persons_address.addr_id FROM addresses

Model->find LEFT JOIN issue

2009-08-28 Thread Aivaras
ay('CarTemplate.*', 'COUNT(CarTemplateCategory.id)'))); $aTemplates = $this->CarTemplate->query("SELECT `CarTemplate`.*, COUNT(CarTemplateCategory.id) FROM `car_templates` AS `CarTemplate` LEFT JOIN `car_template_categories` AS `CarTemplateCategory` ON `CarTemplate`.`id` = `

Re: Model->find LEFT JOIN issue

2009-08-28 Thread Aivaras
Well, I can't replicate the error, but it was only selecting data from one table which was surely the case. Thank you for reminding about counterCache, I used to love it! Cheers, Faifas On Fri, Aug 28, 2009 at 19:53, WebbedIT wrote: > > What SQL and error is it generating? Why not run the fi

Re: Model->find LEFT JOIN issue

2009-08-28 Thread WebbedIT
What SQL and error is it generating? Why not run the find on the CarTemplateCategory model with CarTemplate.id as a condition or better still use counterCache automagic to save yourself time and resources. http://book.cakephp.org/view/816/counterCache-Cache-your-count --~--~-~--~~---

Re: Double left join?

2009-03-31 Thread Amit
Take a look at the Containable behavior. You should able to something as simple as: http://book.cakephp.org/view/474/Containable $this->Model->contain('Company', 'Category'); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Double left join?

2009-03-31 Thread Richard
Hi, I'm fairly new to CakePHP so if this is a stupid mistake forgive me. A user will post a complaint against a company, so the complaint table has company_id. I use a left join to get the company data. Then the company has a field category_id which is simply the industry of the co

Re: updateAll gets a Left join sql

2009-03-24 Thread Amit Badkas
As per http://book.cakephp.org/view/75/Saving-Your-Data, updateAll() method needs two arguments and you have provided only one. Also keep in mind that literal values of fields to save should be quoted Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org

updateAll gets a Left join sql

2009-03-24 Thread Trandaburu Tiberiu Andrei
hi , when i trie to update a model i get : Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@yahoo.comArray WHERE 1 = 1' at line 1 my model looks like that class User extends Ap

Re: Help with left join

2009-03-03 Thread brian
On Tue, Mar 3, 2009 at 9:35 AM, Henrik Gemal wrote: > > Hi > > I'm having a little problem with converting an old sql request to use > cakephp. > > The sql is: > select name, if(module_id is null,0,1) activated from module left join > active_modules on (id = m

Help with left join

2009-03-03 Thread Henrik Gemal
Hi I'm having a little problem with converting an old sql request to use cakephp. The sql is: select name, if(module_id is null,0,1) activated from module left join active_modules on (id = module_id and res_id = $id) I have something like: var $useTable = "modules&quo

Re: Paginate forcing a LEFT JOIN to a HABTM table

2009-01-06 Thread WebbedIT
I think this should help http://teknoid.wordpress.com/2008/08/06/habtm-and-join-trickery-with-cakephp/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-p

Paginate forcing a LEFT JOIN to a HABTM table

2009-01-06 Thread Aidan Lister
I'm trying to do the following query: $query = 'select Paper.* from papers as Paper left join volumes as Volume on (Paper.volume_id = Volume.id) left join users_volumes as UsersVolume on (UsersVolume.volume_id = Volume.id) where UsersVolume.user_id = %d or Paper.us

Re: CakePHP: How to remove LEFT JOIN in updateAll()

2008-11-12 Thread Serge Rodovnichenko
o = array > (), my updateAll() generated statement was affected with this error > message: > > UPDATE `files_folders` AS `FilesFolders` LEFT JOIN `course_files` AS > `CourseFile` ON (`FilesFolders`.`account_id` = `CourseFile`.`id`) SET > `FilesFolders`.`deleted` = 0 WHERE `FilesFolde

Re: CakePHP: How to remove LEFT JOIN in updateAll()

2008-11-12 Thread Mathew
I've had the same problems with updateAll. I can't remember if setting the recursive to -1 solved the problem. $this->controller->FilesFolders->recursive = -1; If that doesn't work you can call unBind. --~--~-~--~~~---~--~~ You received this message because you a

CakePHP: How to remove LEFT JOIN in updateAll()

2008-11-12 Thread Kryptonian
Hi, I have this problem that if my model uses a var $belongsTo = array (), my updateAll() generated statement was affected with this error message: UPDATE `files_folders` AS `FilesFolders` LEFT JOIN `course_files` AS `CourseFile` ON (`FilesFolders`.`account_id` = `CourseFile`.`id`) SET

Re: Join instead of LEFT JOIN

2008-10-09 Thread Deon Heunis
join' => 'INNER JOIN', ), ); Deon Heunis wrote: > [EMAIL PROTECTED] wrote: > >> Is there anyway to dynamically override cake to use a JOIN instead of >> LEFT JOIN ? >> >> > > I added a condition in my model to only r

Re: Join instead of LEFT JOIN

2008-10-09 Thread Deon Heunis
[EMAIL PROTECTED] wrote: > Is there anyway to dynamically override cake to use a JOIN instead of > LEFT JOIN ? > I added a condition in my model to only return Job.active, but with the LEFT JOIN, it will always be return a record, but with the Job empty. So to exclude the row,

Join instead of LEFT JOIN

2008-10-09 Thread [EMAIL PROTECTED]
Is there anyway to dynamically override cake to use a JOIN instead of LEFT JOIN ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegro

Re: LEFT JOIN association type

2008-05-01 Thread KooT
model: var $belongsTo = array ( 'Type' => array ( 'className' => 'Type', 'foreignKey' => 'type', )

Re: LEFT JOIN association type

2008-05-01 Thread validkeys
in you wouldn't use left join explicity. cake will use left join to query your data. Your film model belongs to your type model and your type model hasMany of your film model. So use those associations and you will get hwat you are looking.. let me know if that works for you On May 1, 4:

LEFT JOIN association type

2008-05-01 Thread KooT
How to make this query below, with one of this association type: hasOne, hasMany ,belongsTo, hasAndBelongsToMany ? Its just one simple LEFT JOIN, but i cant figure out how to make it... function getData() { $ret = $this->query("SELECT films.id, films.title, films.body, films

Re: Cake uses JOIN instead of LEFT JOIN

2007-10-09 Thread [EMAIL PROTECTED]
s Mysql3 and development server runs mysql4. I > know, I know, should upgrade, but can't do that now. Post HABTM Tags The > problem with the query is that it misses word LEFT just in front of JOIN. If > I change JOIN to LEFT JOIN it work perfectly. What's th

Re: Cake uses JOIN instead of LEFT JOIN

2007-10-09 Thread Joshua Benner
isses word LEFT just in front of JOIN. If I change JOIN to LEFT JOIN it work perfectly. What's the best way to fix this problem or should I just hack cake core? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups &

Cake uses JOIN instead of LEFT JOIN

2007-10-09 Thread [EMAIL PROTECTED]
Production server runs Mysql3 and development server runs mysql4. I know, I know, should upgrade, but can't do that now. Post HABTM Tags The problem with the query is that it misses word LEFT just in front of JOIN. If I change JOIN to LEFT JOIN it work perfectly. What's the best way to

Re: Fetch the associated models with a left join

2007-05-28 Thread RommeDeSerieux
Sorry, that was a typo in the email. Still, it doesn't work, and setting $recursive to 2 makes cake perform about 12 queries like those ones: 10 SELECT `Author`.`id`, `Author`.`username`, `Author`.`password`, `Author`.`email`, `Author`.`created` FROM `users` AS `Author` WHERE `Author`.`id` =

Re: Fetch the associated models with a left join

2007-05-28 Thread Matthias Bauer
On 28.05.2007 20:11 RommeDeSerieux wrote: > That's fine, but a Category also hasMany Downloads, but when i do > categories/view, it fetches only one table, which results in raw > values of category_id, author_id and translator_id displayed as > integers, while i need it to behave like in the firs

Fetch the associated models with a left join

2007-05-28 Thread RommeDeSerieux
A Download belongsTo Categories, Authors and Translators, so when i do downloads/view, it fetches the data from three tables with a left join and resolves category_id, author_id and translator_id. That's fine, but a Category also hasMany Downloads, but when i do categories/view, it fetches

Re: LEFT JOIN missing in SELECT statement

2006-07-23 Thread francky06l
ening of course.. Actually it'a an idea that can be used, I mean making a LEFT JOIN for "special cases", using this (as id is never null) i could have a condition such as "model2.id IS NOT NULL" .. Thanks Franck --~--~-~--~~~---~--~~ You received th

Re: LEFT JOIN missing in SELECT statement

2006-07-23 Thread nate
Okay, I'm like 80% sure I get what you're saying. Besides manually modifying the association manually at runtime (do pr($this->Model->hasMany) and you'll see what I'm talking about), you could do: $this->Model1->Model2->findCount('user_id != ' . $current_user_id); --~--~-~--~~-

Re: LEFT JOIN missing in SELECT statement

2006-07-23 Thread francky06l
ied the reverse, meaning seaching by model 2 (since it has a LEFT JOIN to model1) and I can make conditions, that can work partially by then I have a problem when 2 records model2 exist referering to the same record model1, the model1 record appear then twice ... Not simple, and actually basically I want

Re: LEFT JOIN missing in SELECT statement

2006-07-23 Thread Samuel DeVore
you should look at the bindModel stuffcake baker as a little bit about it here http://cakebaker.wordpress.com/2006/02/22/new-feature-bindmodelunbindmodel/ Sam DOn 7/23/06, francky06l <[EMAIL PROTECTED]> wrote: Thanks,The problem is that the condition changes depending of the user role(in my case),

Re: LEFT JOIN missing in SELECT statement

2006-07-23 Thread francky06l
Thanks, The problem is that the condition changes depending of the user role (in my case), so I can't stick it into the model relation. I can do this using the bindModel on the fly, but even so I can;t succeed. Basically I will have to write the SQL query .. I will try to find better way ... but

Re: LEFT JOIN missing in SELECT statement

2006-07-23 Thread nate
when specifying your model associations, you can define additional conditions like so: class Model1 extends AppModel { var $hasMany = array('Model2' => array('conditions' => 'Model2.x = 1')); } --~--~-~--~~~---~--~~ You received this message because you are s

Re: LEFT JOIN missing in SELECT statement

2006-07-23 Thread francky06l
Sorry, my question is stupid ..probably as I am .. Left join can be only of a belongTo or HasOne ...not hasMany .. However what is the best way when having 2 models link by a HasMany and BelongsTo, and make a query into the first having condition on the second ?? I know might seems weird bu from

LEFT JOIN missing in SELECT statement

2006-07-23 Thread francky06l
Hello, Using the debug = 2, I found a very weird stuff .. When I look to the Select statement, it appears not having the JOIN with 2 models .. Model1 one hasMany model2, and model2 belongsTo model1, but looking at the SELECT statement I do not see any LEFT JOIN ON in the query...but plenty of