Re: Model-find() using group parameter
right, thank you. On Aug 20, 5:37 pm, teknoid [EMAIL PROTECTED] wrote: It's a feature, find('list') is usually done to build options for a select box. On Aug 20, 8:39 am, bitkidoku [EMAIL PROTECTED] wrote: What about using 'list' instead of 'all', it is failing: $this-Production-find('list', array('fields' = 'DISTINCT supplier')); CakePHP is trying to fetch Product.id as well. Is this a feature or a bug? :) On Aug 20, 3:12 pm, Amit Badkas [EMAIL PROTECTED] wrote: 2008/8/20 Amit Badkas [EMAIL PROTECTED] 2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products - Or using cake, $this-Production-find('all', array('fields' = 'DISTINCT supplier')); I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/http://coppermine-gallery.net/http://chee... --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Model-find() using group parameter
Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Model-find() using group parameter
2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org/ http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Model-find() using group parameter
2008/8/20 Amit Badkas [EMAIL PROTECTED] 2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products - Or using cake, $this-Production-find('all', array('fields' = 'DISTINCT supplier')); I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org/ http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Model-find() using group parameter
Oh, I just got here to reply my own question, and there are two answers already. Thanks for the answer! On Aug 20, 3:12 pm, Amit Badkas [EMAIL PROTECTED] wrote: 2008/8/20 Amit Badkas [EMAIL PROTECTED] 2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products - Or using cake, $this-Production-find('all', array('fields' = 'DISTINCT supplier')); I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/http://coppermine-gallery.net/http://cheesecake-photoblog.org/http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Model-find() using group parameter
What about using 'list' instead of 'all', it is failing: $this-Production-find('list', array('fields' = 'DISTINCT supplier')); CakePHP is trying to fetch Product.id as well. Is this a feature or a bug? :) On Aug 20, 3:12 pm, Amit Badkas [EMAIL PROTECTED] wrote: 2008/8/20 Amit Badkas [EMAIL PROTECTED] 2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products - Or using cake, $this-Production-find('all', array('fields' = 'DISTINCT supplier')); I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/http://coppermine-gallery.net/http://cheesecake-photoblog.org/http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Model-find() using group parameter
It's a feature, find('list') is usually done to build options for a select box. On Aug 20, 8:39 am, bitkidoku [EMAIL PROTECTED] wrote: What about using 'list' instead of 'all', it is failing: $this-Production-find('list', array('fields' = 'DISTINCT supplier')); CakePHP is trying to fetch Product.id as well. Is this a feature or a bug? :) On Aug 20, 3:12 pm, Amit Badkas [EMAIL PROTECTED] wrote: 2008/8/20 Amit Badkas [EMAIL PROTECTED] 2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products - Or using cake, $this-Production-find('all', array('fields' = 'DISTINCT supplier')); I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/http://coppermine-gallery.net/http://chee... --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---