Filtering by multiple associated data

2015-05-26 Thread ProFire
hey guys, is there a way to filter associated results with 2 tags? 

http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#filtering-by-associated-data
 

The documentation only shows 1 tag to filter. I'm hoping to filter with 2 
tags, like articles with Finance and Tips tag.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Model Behavior and filtering results in a DboSource class Options

2012-05-12 Thread kirill_z
I've noticed that _queryAssociation method, within DboSource class,
calls
linked models afterFind callback, but does not calls linked models
behavior callbacks.
IMHO, it can be potential risk when you protect some model with
AclBehavior. Because, Model-find() method returns associated model
data
disregarding permissions of the last.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Asset filtering CakePHP 2.0.5 / css.php not included anymore?

2012-01-09 Thread LDSign
Hi there

I've tried to enable the CSS asset filtering in CakePHP 2.0.5, but it
doesn't work. csspp is placed in vendors.

It seems the required file css.php in the webroot-dir is missing.
Any hints? Or has the scheme changed in 2.0?

Thank you,
Frank

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Asset filtering CakePHP 2.0.5 / css.php not included anymore?

2012-01-09 Thread José Lorenzo
Use more advanced solutions like the AssetCompress plugin

github.com/markstory/asset_compress

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Filtering Component - Correct way of filtering results between two dates

2011-12-13 Thread René Weber
Since there was not reply, I want to post my solution:

1. I added two input field 'date_before', 'date_after'

2. I created another component class 'myfilter' which extends the
filter component

3. In this class I handle 'date_before' and 'date_after' and set them
to $data['date']['BETWEEN'] = array( date_before, date_after ) and
call Parent Filter Components processor.

4. This way my query still fails, since filter component in my version
will try to add 'date_before' as fields to the query, but these fields
do not exist

5. In order to have date_before and date_after saved in session but
not in my query, I extended my filter components with an option
saveToSessionOnly which will be saved but ignored in the filter
creation loop

Probably not the best solution, but in the end the only solution I
found so far.

On 1 Dez., 18:29, web_rene web_r...@gmx.de wrote:
 I am quite new to CakePHp and the MVC way of thinking.

 Up to know I was able to create resultsetfiltering by the use of the Filter
 Component by Nik Chankov.

 The way I am using it, is to call it in my Controller, saving the condition
 statement and passing it to the Paginator.

 Now, I have one column which holds a 'created_at' date and I want to give
 the user a possibility to enter a start date and an end date and to pass it
 to the filter component.

 I tried creating two input text fields 'created_after' and 'created_before'
 and to join these to an array[created_at][BETWEEN] in my controller since
 the Filter Component handles 'BETWEEN' arrays.

 Unfortunatelly, if I do not unset the original values I get a SQL Error
 since the component will create a statement including 'created_after' and
 created_before' which are not defined in my database. But if I do unset
 created_before and _after, they won't be saved to the session ( this is
 handled byfilteringcomponent aswell ) and I can not use Paginator anymore.

 What would be the correct way of doing this? Please give me advise how and
 into which direction I should proceed to solve this issue... I am kind of
 stuck and I would love to somehow add this to theFilteringand not to
 create a hack in my Controller...

 thanks!

 --
 View this message in 
 context:http://cakephp.1045679.n5.nabble.com/Filtering-Component-Correct-way-...
 Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Filtering Component - Correct way of filtering results between two dates

2011-12-01 Thread web_rene
I am quite new to CakePHp and the MVC way of thinking.

Up to know I was able to create resultsetfiltering by the use of the Filter
Component by Nik Chankov. 

The way I am using it, is to call it in my Controller, saving the condition
statement and passing it to the Paginator. 

Now, I have one column which holds a 'created_at' date and I want to give
the user a possibility to enter a start date and an end date and to pass it
to the filter component.

I tried creating two input text fields 'created_after' and 'created_before'
and to join these to an array[created_at][BETWEEN] in my controller since
the Filter Component handles 'BETWEEN' arrays.

Unfortunatelly, if I do not unset the original values I get a SQL Error
since the component will create a statement including 'created_after' and
created_before' which are not defined in my database. But if I do unset
created_before and _after, they won't be saved to the session ( this is
handled by filtering component aswell ) and I can not use Paginator anymore.

What would be the correct way of doing this? Please give me advise how and
into which direction I should proceed to solve this issue... I am kind of
stuck and I would love to somehow add this to the Filtering and not to
create a hack in my Controller...

thanks!

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Filtering-Component-Correct-way-of-filtering-results-between-two-dates-tp5039403p5039403.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: filtering model result bases on user rights

2011-10-20 Thread Timmay
Sorry for my late respons, I would have expected a notification when
someone replies to my post.
I solved the problem using joins, like Zaky suggested.
I use the beforeFind method in my docs model to modify the select
query.
It adds the join and some extra criteria, so that the model cannot
return a doc where a user has no rights to.

On Sep 16, 5:28 am, Zaky Katalan-Ezra procsh...@gmail.com wrote:
 For the list result you join docs and docs token and check that the user
 tokens are IN the join result.
 To prevent url changes I suggest
 1. use uuid as document id.
 2. Create a function in the database that take user_id and doc_id and return
 true/false
 Call this function in  documents/view or edit.



 On Thu, Sep 15, 2011 at 5:59 PM, Timmay tim.smi...@gmail.com wrote:
  the example I gave is a simplified version of the real situation.

  The real situation is that a user has two sets of tokens (lets say A
  and B).
  These properties are stored in another table, named user_tokens.

  A document also has two sets of tokens (lets also call them A and B).
  These properties are stored in a table 'document_tokens'.

  A user is allowed to see the document if:
  the user and the document have at least one token in set A in common
  and
  the user and the document have at least one token in set B in common.

  On Sep 15, 10:42 am, Zaky Katalan-Ezra procsh...@gmail.com wrote:
   How do you save the permissions in the database?

   On Thu, Sep 15, 2011 at 10:53 AM, Timmay tim.smi...@gmail.com wrote:
Hi all,

I'm working on a multi user website with a collection of documents.
Every user is only allowed to see a subset of the documents.

I want the Documents model to only return the documents that a user is
allowed to see.
If a users requests one particular document, and he doesn't have
rights to see the document (e.g. he modified the url), I want the
model to return nothing.

Is there an easy way to achieve this?

--
Our newest site for the community: CakePHP Video Tutorials
   http://tv.cakephp.org
Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
others with their CakePHP related questions.

To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this
  group
athttp://groups.google.com/group/cake-php

   --
   Regards,
   Zaky Katalan-Ezra
   QA Administratorwww.IGeneriX.com
   Sites.IGeneriX.com
   054-7762312

  --
  Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
  others with their CakePHP related questions.

  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group
  athttp://groups.google.com/group/cake-php

 --
 Regards,
 Zaky Katalan-Ezra
 QA Administratorwww.IGeneriX.com
 Sites.IGeneriX.com
 054-7762312

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: filtering

2011-09-24 Thread WebbedIT
The exact code depends if you are using a Javascript framework (I
reccomend jQuery) or plain javascript, but a quick google search
brings up loads of examples of how other people have done this:
http://www.google.co.uk/search?q=cakephp+ajax+select

HTH, Paul

P.S. As soon as you start doing any AJAX work I reccomend you have
FireBug installed so you can see what data is being fired.

On Sep 23, 9:25 am, Elizebert Eona elizeber...@gmail.com wrote:
 I want to do filtering using ajax. Do u have any idea/advice/suggestion?

 On 23 September 2011 16:19, WebbedIT p...@webbedit.co.uk wrote:









  Do you want to do this with AJAX or full page load?

  HTH, Paul.

  On Sep 23, 2:49 am, ms_liz_87 elizeber...@gmail.com wrote:
   Can anyone give me any idea how I want to do a filtering? example:
   after i select one 1st cat, it will show all list under 1st cat.

  --
  Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
  others with their CakePHP related questions.

  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group
  athttp://groups.google.com/group/cake-php

 --
 Regards,
 Elizebert Eona.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: filtering

2011-09-23 Thread WebbedIT
Do you want to do this with AJAX or full page load?

HTH, Paul.

On Sep 23, 2:49 am, ms_liz_87 elizeber...@gmail.com wrote:
 Can anyone give me any idea how I want to do a filtering? example:
 after i select one 1st cat, it will show all list under 1st cat.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: filtering

2011-09-23 Thread Elizebert Eona
I want to do filtering using ajax. Do u have any idea/advice/suggestion?

On 23 September 2011 16:19, WebbedIT p...@webbedit.co.uk wrote:

 Do you want to do this with AJAX or full page load?

 HTH, Paul.

 On Sep 23, 2:49 am, ms_liz_87 elizeber...@gmail.com wrote:
  Can anyone give me any idea how I want to do a filtering? example:
  after i select one 1st cat, it will show all list under 1st cat.

 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 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




-- 
Regards,
Elizebert Eona.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


filtering

2011-09-22 Thread ms_liz_87
Can anyone give me any idea how I want to do a filtering? example:
after i select one 1st cat, it will show all list under 1st cat.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: filtering model result bases on user rights

2011-09-16 Thread WebbedIT
Can you give us an overview of how you have declared the relationships
of those 4 tables?  I.e. r u using HABTM or hasMany - belongsTo?

On Sep 16, 4:28 am, Zaky Katalan-Ezra procsh...@gmail.com wrote:
 For the list result you join docs and docs token and check that the user
 tokens are IN the join result.
 To prevent url changes I suggest
 1. use uuid as document id.
 2. Create a function in the database that take user_id and doc_id and return
 true/false
 Call this function in  documents/view or edit.









 On Thu, Sep 15, 2011 at 5:59 PM, Timmay tim.smi...@gmail.com wrote:
  the example I gave is a simplified version of the real situation.

  The real situation is that a user has two sets of tokens (lets say A
  and B).
  These properties are stored in another table, named user_tokens.

  A document also has two sets of tokens (lets also call them A and B).
  These properties are stored in a table 'document_tokens'.

  A user is allowed to see the document if:
  the user and the document have at least one token in set A in common
  and
  the user and the document have at least one token in set B in common.

  On Sep 15, 10:42 am, Zaky Katalan-Ezra procsh...@gmail.com wrote:
   How do you save the permissions in the database?

   On Thu, Sep 15, 2011 at 10:53 AM, Timmay tim.smi...@gmail.com wrote:
Hi all,

I'm working on a multi user website with a collection of documents.
Every user is only allowed to see a subset of the documents.

I want the Documents model to only return the documents that a user is
allowed to see.
If a users requests one particular document, and he doesn't have
rights to see the document (e.g. he modified the url), I want the
model to return nothing.

Is there an easy way to achieve this?

--
Our newest site for the community: CakePHP Video Tutorials
   http://tv.cakephp.org
Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
others with their CakePHP related questions.

To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this
  group
athttp://groups.google.com/group/cake-php

   --
   Regards,
   Zaky Katalan-Ezra
   QA Administratorwww.IGeneriX.com
   Sites.IGeneriX.com
   054-7762312

  --
  Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
  others with their CakePHP related questions.

  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group
  athttp://groups.google.com/group/cake-php

 --
 Regards,
 Zaky Katalan-Ezra
 QA Administratorwww.IGeneriX.com
 Sites.IGeneriX.com
 054-7762312

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


filtering model result bases on user rights

2011-09-15 Thread Timmay
Hi all,

I'm working on a multi user website with a collection of documents.
Every user is only allowed to see a subset of the documents.

I want the Documents model to only return the documents that a user is
allowed to see.
If a users requests one particular document, and he doesn't have
rights to see the document (e.g. he modified the url), I want the
model to return nothing.

Is there an easy way to achieve this?








-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: filtering model result bases on user rights

2011-09-15 Thread Zaky Katalan-Ezra
How do you save the permissions in the database?

On Thu, Sep 15, 2011 at 10:53 AM, Timmay tim.smi...@gmail.com wrote:

 Hi all,

 I'm working on a multi user website with a collection of documents.
 Every user is only allowed to see a subset of the documents.

 I want the Documents model to only return the documents that a user is
 allowed to see.
 If a users requests one particular document, and he doesn't have
 rights to see the document (e.g. he modified the url), I want the
 model to return nothing.

 Is there an easy way to achieve this?








 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 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




-- 
Regards,
Zaky Katalan-Ezra
QA Administrator
www.IGeneriX.com
Sites.IGeneriX.com
054-7762312

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: filtering model result bases on user rights

2011-09-15 Thread Timmay
the example I gave is a simplified version of the real situation.

The real situation is that a user has two sets of tokens (lets say A
and B).
These properties are stored in another table, named user_tokens.

A document also has two sets of tokens (lets also call them A and B).
These properties are stored in a table 'document_tokens'.

A user is allowed to see the document if:
the user and the document have at least one token in set A in common
and
the user and the document have at least one token in set B in common.


On Sep 15, 10:42 am, Zaky Katalan-Ezra procsh...@gmail.com wrote:
 How do you save the permissions in the database?



 On Thu, Sep 15, 2011 at 10:53 AM, Timmay tim.smi...@gmail.com wrote:
  Hi all,

  I'm working on a multi user website with a collection of documents.
  Every user is only allowed to see a subset of the documents.

  I want the Documents model to only return the documents that a user is
  allowed to see.
  If a users requests one particular document, and he doesn't have
  rights to see the document (e.g. he modified the url), I want the
  model to return nothing.

  Is there an easy way to achieve this?

  --
  Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
  others with their CakePHP related questions.

  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group
  athttp://groups.google.com/group/cake-php

 --
 Regards,
 Zaky Katalan-Ezra
 QA Administratorwww.IGeneriX.com
 Sites.IGeneriX.com
 054-7762312

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: filtering model result bases on user rights

2011-09-15 Thread Zaky Katalan-Ezra
For the list result you join docs and docs token and check that the user
tokens are IN the join result.
To prevent url changes I suggest
1. use uuid as document id.
2. Create a function in the database that take user_id and doc_id and return
true/false
Call this function in  documents/view or edit.

On Thu, Sep 15, 2011 at 5:59 PM, Timmay tim.smi...@gmail.com wrote:

 the example I gave is a simplified version of the real situation.

 The real situation is that a user has two sets of tokens (lets say A
 and B).
 These properties are stored in another table, named user_tokens.

 A document also has two sets of tokens (lets also call them A and B).
 These properties are stored in a table 'document_tokens'.

 A user is allowed to see the document if:
 the user and the document have at least one token in set A in common
 and
 the user and the document have at least one token in set B in common.


 On Sep 15, 10:42 am, Zaky Katalan-Ezra procsh...@gmail.com wrote:
  How do you save the permissions in the database?
 
 
 
  On Thu, Sep 15, 2011 at 10:53 AM, Timmay tim.smi...@gmail.com wrote:
   Hi all,
 
   I'm working on a multi user website with a collection of documents.
   Every user is only allowed to see a subset of the documents.
 
   I want the Documents model to only return the documents that a user is
   allowed to see.
   If a users requests one particular document, and he doesn't have
   rights to see the document (e.g. he modified the url), I want the
   model to return nothing.
 
   Is there an easy way to achieve this?
 
   --
   Our newest site for the community: CakePHP Video Tutorials
  http://tv.cakephp.org
   Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
   others with their CakePHP related questions.
 
   To unsubscribe from this group, send email to
   cake-php+unsubscr...@googlegroups.com For more options, visit this
 group
   athttp://groups.google.com/group/cake-php
 
  --
  Regards,
  Zaky Katalan-Ezra
  QA Administratorwww.IGeneriX.com
  Sites.IGeneriX.com
  054-7762312

 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 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




-- 
Regards,
Zaky Katalan-Ezra
QA Administrator
www.IGeneriX.com
Sites.IGeneriX.com
054-7762312

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: data filtering

2011-07-09 Thread krisspnet
It seems to be a classical ACL problem.

See this :

http://book.cakephp.org/view/465/Understanding-How-ACL-Works
Understanding-How-ACL-Works 

Starting from this, you will have the opportunity to do fine restriction on
your controller functions (or pages) 

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/data-filtering-tp4563439p4567611.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


data filtering

2011-07-08 Thread Plastika
Please forgive me, I am still fairly new to cakephp and in the process of
reviving my redundant PhP skills. 

I have searched all over the interweb for the answer, sadly to no avail. 

Here is the scenario: 

I have 4 tables - 1 being Users the other Groups ( for permissions). 

users table - pretty standard plus some additional profile info. 
Groups table - holds Administrators, Super Users, Auth Users and Unauth
Users. 

The Users table is being used for authentication and profiles (other users
can browse user profiles).  Now with this in mind, I cannot work out how to
filter out which users get rendered into the index view based on which group
the users (not the the currently logged user) belong. 

For example, The admin and Super user accounts profiles are being rendered
and belongs to the Administrators and Super users groups respectively
along with all the other Users.  However all I want end users (Auth Users)
to be able to see are other user profiles which are part of the Auth Users
group. 

So my hairline and I both would greatly appreciate any and all help in
resolving to this problem. 
  

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/data-filtering-tp4563439p4563439.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Filtering search results by using checkboxes

2011-05-26 Thread MeatSandwich
Hey there everyone.

I'm a bit of a newb so apologies if this question is a bit simple,
although I can't get my head round how to go about doing it.

I have a search page where a user can type in a search box, or they
can use an alphabetical list to search for the record they're looking
for. Eg they click 'a' and all the records beginning with the letter
'a' appear.

I'd also like to have it so that each record has a number of tags, and
I'd then like to be able to filter records according to which tags
have been selected - preferably using checkboxes.

For example, perhaps the tags would be colours and the records
represented shoes. There'd be checkboxes for blue, yellow, black,
brown and so on. At first all colours would be shown, but if the user
clicks on brown the all but the brown shoes dissappear.

like I say, I'm new to cakephp and learning php so please be gentle.

thanks ;)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Plan for adding filtering/search capabilities to index.ctp view

2011-01-23 Thread opike
I have a view that will potentially be displaying thousands of records
and I want to add search/filtering controls to the top of the index
view. I'm working with cake 1.3.7 and I did some preliminary research
and it doesn't appear that 1.3.7 provides this type of functionality
out of the box. A couple of questions:

1) Will version 2.0 include any enhancements in this area?

2) Are there any plugins or add on components that can be obtained
that will add this functionality?

3) If I have to build it from scratch, I'm thinking that I will have
to:
  a) Add the necessary controls to index.ctp (duh)
  b) add logic to the index() function in the controllers php to to
filter the data (based off of the inputs from step a ) that ends up
being passed to index.ctp.


Any comments or guidance is much appreciated...

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Plan for adding filtering/search capabilities to index.ctp view

2011-01-23 Thread cricket
On Sun, Jan 23, 2011 at 12:58 PM, opike hastapast...@gmail.com wrote:
 I have a view that will potentially be displaying thousands of records
 and I want to add search/filtering controls to the top of the index
 view. I'm working with cake 1.3.7 and I did some preliminary research
 and it doesn't appear that 1.3.7 provides this type of functionality
 out of the box. A couple of questions:

 1) Will version 2.0 include any enhancements in this area?

 2) Are there any plugins or add on components that can be obtained
 that will add this functionality?

 3) If I have to build it from scratch, I'm thinking that I will have
 to:
  a) Add the necessary controls to index.ctp (duh)
  b) add logic to the index() function in the controllers php to to
 filter the data (based off of the inputs from step a ) that ends up
 being passed to index.ctp.

You could do it with AJAX calls. Maybe add a $filters param to index

function index($filters = null)

$filters could then be checked for 'limit', 'search' keys, etc. which
would be passed depending on which filter request was made.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Plan for adding filtering/search capabilities to index.ctp view

2011-01-23 Thread Zaky Katalan-Ezra
Never used myself but check this.
cakedc search pluginhttp://cakedc.com/downloads/view/cakephp_search_plugin

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Filtering by related model...

2011-01-09 Thread Amit Badkas
Hi,

Could you please show me the structure of categories table. I need to know
surely if Product belongs to Category or Product has many Category or
Product has and belongs to many Category.

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Sat, Jan 8, 2011 at 1:25 AM, TSG ke...@thatscriptguy.com wrote:

 I know I've read this somewhere, but I've been searching for an hour
 now and cannot find it.

 I have a Product model
 I have a Category model

 A product can have many categories

 The categories table has a field, slug, that is used for SEO purposes.

 I currently have a beautifully formatted, paginated list of my
 products at /products and that works just great.  But I need to be
 able to filter by the category slug (I'm thinking /products/category/
 my-slug-goes-here) and have it use my same view, just with the
 filtered data.

 How do I do this?  It is driving me absolutely nuts.  I know it's a
 simple thing, as the relationships are all set up in the models
 perfectly fine.  But for the life of me, I just can't get it to work.

 My index method:

 function index() {
$this-Product-recursive = 1;
$this-Product-contain('WordAd');
$this-set('products', $this-paginate());
}

 Can someone please help me with this?  I'm loving Cake so far.  It has
 greatly sped up my development.  I've just hit a snag.

 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.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


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


Filtering by related model...

2011-01-07 Thread TSG
I know I've read this somewhere, but I've been searching for an hour
now and cannot find it.

I have a Product model
I have a Category model

A product can have many categories

The categories table has a field, slug, that is used for SEO purposes.

I currently have a beautifully formatted, paginated list of my
products at /products and that works just great.  But I need to be
able to filter by the category slug (I'm thinking /products/category/
my-slug-goes-here) and have it use my same view, just with the
filtered data.

How do I do this?  It is driving me absolutely nuts.  I know it's a
simple thing, as the relationships are all set up in the models
perfectly fine.  But for the life of me, I just can't get it to work.

My index method:

function index() {
$this-Product-recursive = 1;
$this-Product-contain('WordAd');
$this-set('products', $this-paginate());
}

Can someone please help me with this?  I'm loving Cake so far.  It has
greatly sped up my development.  I've just hit a snag.

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: Behavior afterFind not filtering data?

2010-07-31 Thread cricket
On Fri, Jul 30, 2010 at 11:03 AM, DragonFlyEye dragonflyey...@gmail.com wrote:
 Ok, the problem appears to be that somewhere in the bowels of
 CakePHP's Models, it doesn't seem to like certain characters and just
 replaces them with ?

 I've discovered this because I'm attempting to run batches through the
 Console. So, I'm only using a Shell script and the Model in question
 and I'm definitely getting ? where I should be getting ™. I've
 verified that my database.php file is using 'encoding'  = 'iso-8859-1'
 and that my core.php shows Configure::write('App.encoding',
 'iso-8859-1'); but neither of these two things is solving the problem.

 Cricket: I've finally convinced people here to get rid of the blasted
 weird characters and replace with HTML entities, but now the battle is
 actually getting that done! Trying to use SQL Server's Import and
 Export utility is at least as unsuccessful so far as doing it the
 CakePHP way and for a variety of reasons, I'd prefer to go CakePHP.


Sorry, can't help if it's a Windows environment. But my inclination
would be to convert everything to UTF-8 using iconv.

And I haven't used SQL-Server in over ten years, so I can't suggest
anything on that end.

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: Behavior afterFind not filtering data?

2010-07-31 Thread Dr. Loboto
 I've discovered this because I'm attempting to run batches through the
 Console. So, I'm only using a Shell script and the Model in question
 and I'm definitely getting ? where I should be getting ™. I've
 verified that my database.php file is using 'encoding'  = 'iso-8859-1'
 and that my core.php shows Configure::write('App.encoding',
 'iso-8859-1'); but neither of these two things is solving the problem.

There is no ™ sign in iso-8859-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 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: Behavior afterFind not filtering data?

2010-07-30 Thread DragonFlyEye
Ok, the problem appears to be that somewhere in the bowels of
CakePHP's Models, it doesn't seem to like certain characters and just
replaces them with ?

I've discovered this because I'm attempting to run batches through the
Console. So, I'm only using a Shell script and the Model in question
and I'm definitely getting ? where I should be getting ™. I've
verified that my database.php file is using 'encoding'  = 'iso-8859-1'
and that my core.php shows Configure::write('App.encoding',
'iso-8859-1'); but neither of these two things is solving the problem.

Cricket: I've finally convinced people here to get rid of the blasted
weird characters and replace with HTML entities, but now the battle is
actually getting that done! Trying to use SQL Server's Import and
Export utility is at least as unsuccessful so far as doing it the
CakePHP way and for a variety of reasons, I'd prefer to go CakePHP.

Thanks to anyone who can help.

On Jul 22, 3:15 pm, DragonFlyEye dragonflyey...@gmail.com wrote:
 Not really. We're talking about thousands of products for a start. And
 I expect to have problems with data entry in the future, like cutting
 and pasting from Word. Plus there is some resistence to changing
 things around here that I've got to slowly overcome. In the meanwhile,
 I have to be able to show progress.

 The result I'm getting is exactly the same as the original query. IOW:
 as though the filtering isn't happening. I've intentionally put errors
 in the code to make sure that the Model that it's being declared in is
 correctly identifying the file, which it is. But even if I put in
 return 'Bupkis', I still get the same response.

 On Jul 22, 2:59 pm, cricket zijn.digi...@gmail.com wrote:

  You haven't said what results you're seeing. Anyway, at a glance, I
  can see one problem.

  Sanitize::clean($results);

  should be:

  $results = Sanitize::clean($results);

  But, wouldn't it be simpler to just write a script that cleans up the
  DB once and forget about it?

  On Thu, Jul 22, 2010 at 2:06 PM, DragonFlyEye dragonflyey...@gmail.com 
  wrote:
   I'm sure I'm missing something silly, but I cannot get this Behavior
   to work. I've got data with a bunch of nasty characters in the
   database that I need to avoid or escape before presenting to the
   browser. Also, it's got a lot of white space at the end of much of the
   data because someone erroneously used the nchar datatype on the MS-SQL
   database I'm working off of. So this Behavior is just to be able to
   get rid of those problems going forward. Right now, I'm using it on
   the afterFind hook, but once I know it works safely I'll apply it to
   the beforeSave hook:

   ?php
   App::import('Sanitize');
   class TrimAndEscapeBehavior extends ModelBehavior {
          var $errors             = array();

          function afterFind($Model, $results, $primary) {
                  $results = $this-cleanText($results);
                  Sanitize::clean($results);
                  return $results;
          }

          /*
          // cleanText:                   Recursive function trims text and 
   removes illegal
   characters.
          // @var mixed $data:    The data to inspect and clean.
          // @data mixed $data:   The cleaned data.
          */
          function cleanText($results) {
                  // If this is an array, send it back through:
                  if(is_array($results)) :
                          foreach($results as $key=$value) :
                                  $results[$key]  = $this-cleanText($value);
                          endforeach;
                  // We have a text node. Trim and escape:
                  else :
                          // replace Trademarks:
                          $results = str_replace(chr(8482), 
   'suptrade;/sup', $results);
                          // Replace Registered Trademarks
                          $results = str_replace(chr(174), 
   'supreg;/sup', $results);
                          // replace Trademarks:
                          $results = str_replace('#8482;', 
   'suptrade;/sup', $results);
                          // Replace Registered Trademarks
                          $results = str_replace('#174;', 
   'supreg;/sup', $results);
                          // Trim content:
                          $results = trim($results);
                          return $results;
                  endif;
          }
   }
   ?

   Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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 
   athttp://groups.google.com/group/cake-php?hl=en



Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP

Behavior afterFind not filtering data?

2010-07-22 Thread DragonFlyEye
I'm sure I'm missing something silly, but I cannot get this Behavior
to work. I've got data with a bunch of nasty characters in the
database that I need to avoid or escape before presenting to the
browser. Also, it's got a lot of white space at the end of much of the
data because someone erroneously used the nchar datatype on the MS-SQL
database I'm working off of. So this Behavior is just to be able to
get rid of those problems going forward. Right now, I'm using it on
the afterFind hook, but once I know it works safely I'll apply it to
the beforeSave hook:

?php
App::import('Sanitize');
class TrimAndEscapeBehavior extends ModelBehavior {
var $errors = array();

function afterFind($Model, $results, $primary) {
$results = $this-cleanText($results);
Sanitize::clean($results);
return $results;
}


/*
// cleanText:   Recursive function trims text and 
removes illegal
characters.
// @var mixed $data:The data to inspect and clean.
// @data mixed $data:   The cleaned data.
*/
function cleanText($results) {
// If this is an array, send it back through:
if(is_array($results)) :
foreach($results as $key=$value) :
$results[$key]  = $this-cleanText($value);
endforeach;
// We have a text node. Trim and escape:
else :
// replace Trademarks:
$results = str_replace(chr(8482), 'suptrade;/sup', 
$results);
// Replace Registered Trademarks
$results = str_replace(chr(174), 'supreg;/sup', 
$results);
// replace Trademarks:
$results = str_replace('#8482;', 'suptrade;/sup', 
$results);
// Replace Registered Trademarks
$results = str_replace('#174;', 'supreg;/sup', 
$results);
// Trim content:
$results = trim($results);
return $results;
endif;
}
}
?

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: Behavior afterFind not filtering data?

2010-07-22 Thread cricket
You haven't said what results you're seeing. Anyway, at a glance, I
can see one problem.

Sanitize::clean($results);

should be:

$results = Sanitize::clean($results);

But, wouldn't it be simpler to just write a script that cleans up the
DB once and forget about it?

On Thu, Jul 22, 2010 at 2:06 PM, DragonFlyEye dragonflyey...@gmail.com wrote:
 I'm sure I'm missing something silly, but I cannot get this Behavior
 to work. I've got data with a bunch of nasty characters in the
 database that I need to avoid or escape before presenting to the
 browser. Also, it's got a lot of white space at the end of much of the
 data because someone erroneously used the nchar datatype on the MS-SQL
 database I'm working off of. So this Behavior is just to be able to
 get rid of those problems going forward. Right now, I'm using it on
 the afterFind hook, but once I know it works safely I'll apply it to
 the beforeSave hook:

 ?php
 App::import('Sanitize');
 class TrimAndEscapeBehavior extends ModelBehavior {
        var $errors             = array();

        function afterFind($Model, $results, $primary) {
                $results = $this-cleanText($results);
                Sanitize::clean($results);
                return $results;
        }


        /*
        // cleanText:                   Recursive function trims text and 
 removes illegal
 characters.
        // @var mixed $data:    The data to inspect and clean.
        // @data mixed $data:   The cleaned data.
        */
        function cleanText($results) {
                // If this is an array, send it back through:
                if(is_array($results)) :
                        foreach($results as $key=$value) :
                                $results[$key]  = $this-cleanText($value);
                        endforeach;
                // We have a text node. Trim and escape:
                else :
                        // replace Trademarks:
                        $results = str_replace(chr(8482), 
 'suptrade;/sup', $results);
                        // Replace Registered Trademarks
                        $results = str_replace(chr(174), 'supreg;/sup', 
 $results);
                        // replace Trademarks:
                        $results = str_replace('#8482;', 
 'suptrade;/sup', $results);
                        // Replace Registered Trademarks
                        $results = str_replace('#174;', 'supreg;/sup', 
 $results);
                        // Trim content:
                        $results = trim($results);
                        return $results;
                endif;
        }
 }
 ?

 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


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: Behavior afterFind not filtering data?

2010-07-22 Thread DragonFlyEye
Not really. We're talking about thousands of products for a start. And
I expect to have problems with data entry in the future, like cutting
and pasting from Word. Plus there is some resistence to changing
things around here that I've got to slowly overcome. In the meanwhile,
I have to be able to show progress.

The result I'm getting is exactly the same as the original query. IOW:
as though the filtering isn't happening. I've intentionally put errors
in the code to make sure that the Model that it's being declared in is
correctly identifying the file, which it is. But even if I put in
return 'Bupkis', I still get the same response.

On Jul 22, 2:59 pm, cricket zijn.digi...@gmail.com wrote:
 You haven't said what results you're seeing. Anyway, at a glance, I
 can see one problem.

 Sanitize::clean($results);

 should be:

 $results = Sanitize::clean($results);

 But, wouldn't it be simpler to just write a script that cleans up the
 DB once and forget about it?

 On Thu, Jul 22, 2010 at 2:06 PM, DragonFlyEye dragonflyey...@gmail.com 
 wrote:
  I'm sure I'm missing something silly, but I cannot get this Behavior
  to work. I've got data with a bunch of nasty characters in the
  database that I need to avoid or escape before presenting to the
  browser. Also, it's got a lot of white space at the end of much of the
  data because someone erroneously used the nchar datatype on the MS-SQL
  database I'm working off of. So this Behavior is just to be able to
  get rid of those problems going forward. Right now, I'm using it on
  the afterFind hook, but once I know it works safely I'll apply it to
  the beforeSave hook:

  ?php
  App::import('Sanitize');
  class TrimAndEscapeBehavior extends ModelBehavior {
         var $errors             = array();

         function afterFind($Model, $results, $primary) {
                 $results = $this-cleanText($results);
                 Sanitize::clean($results);
                 return $results;
         }

         /*
         // cleanText:                   Recursive function trims text and 
  removes illegal
  characters.
         // @var mixed $data:    The data to inspect and clean.
         // @data mixed $data:   The cleaned data.
         */
         function cleanText($results) {
                 // If this is an array, send it back through:
                 if(is_array($results)) :
                         foreach($results as $key=$value) :
                                 $results[$key]  = $this-cleanText($value);
                         endforeach;
                 // We have a text node. Trim and escape:
                 else :
                         // replace Trademarks:
                         $results = str_replace(chr(8482), 
  'suptrade;/sup', $results);
                         // Replace Registered Trademarks
                         $results = str_replace(chr(174), 'supreg;/sup', 
  $results);
                         // replace Trademarks:
                         $results = str_replace('#8482;', 
  'suptrade;/sup', $results);
                         // Replace Registered Trademarks
                         $results = str_replace('#174;', 'supreg;/sup', 
  $results);
                         // Trim content:
                         $results = trim($results);
                         return $results;
                 endif;
         }
  }
  ?

  Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
  athttp://groups.google.com/group/cake-php?hl=en



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


filtering

2010-07-08 Thread james
Hi I am also looking for some advice on filtering. Are these the best
tutorials?

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: filtering

2010-07-08 Thread Shaz
What sort of filtering and for what are you after?

On Jul 8, 10:08 am, james jamesliv...@googlemail.com wrote:
 Hi I am also looking for some advice on filtering. Are these the best
 tutorials?

 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: filtering

2010-07-08 Thread james livsey
well for me I'm after they ability for a user to filter the data in an index
view through a couple of drop downs and a button labelled filter? I was
thinking AJAX might be the way to go but I'd be happy to use any method
really.

On Thu, Jul 8, 2010 at 3:25 PM, Shaz shazam...@gmail.com wrote:

 What sort of filtering and for what are you after?

 On Jul 8, 10:08 am, james jamesliv...@googlemail.com wrote:
  Hi I am also looking for some advice on filtering. Are these the best
  tutorials?
 
  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.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


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


Filtering results in a list

2010-06-16 Thread DSG
Hi all

I am a complete newbie on this. I have inherited some code and it now
needs altering. At present the code generates a product list and some
of the items in the list are new products. At the top of the list is
an icon and text that becomes the link that allows you to view just
the new products. I now need to remove this text, which is easy
enough, but make the icon become the link.

Here is the code if anyone can help:

[code]
?php

$logo_size = array(18, 17);
$logo_image = ;

echo $html-image('icons/new.png', array(
'alt'='New Product Icon',
'width'=$logo_size[0],
'height'=$logo_size[1],
'border'='0',
'class'='ProductLogo'));

$queryString_newproducts = str_replace(data[Product][check_1]=,
data[Product][check_1]=1, $queryString);
echo $paginator-sort(' New Product', 'product',
array('url'=array('?'=$queryString_newproducts)));

?

[/code]

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: Filtering results in a list

2010-06-16 Thread Sam
http://book.cakephp.org/view/835/image

Ad the 'url' option to the options array for your image.

echo $html-image('icons/new.png', array(
'alt'='New Product Icon',
'width'=$logo_size[0],
'height'=$logo_size[1],
'border'='0',
'class'='ProductLogo',
'url' = array('?'=$queryString_newproducts)
));


On Jun 15, 8:39 am, DSG darren.creative...@gmail.com wrote:
 Hi all

 I am a complete newbie on this. I have inherited some code and it now
 needs altering. At present the code generates a product list and some
 of the items in the list are new products. At the top of the list is
 an icon and text that becomes the link that allows you to view just
 the new products. I now need to remove this text, which is easy
 enough, but make the icon become the link.

 Here is the code if anyone can help:

 [code]
 ?php

 $logo_size = array(18, 17);
 $logo_image = ;

 echo $html-image('icons/new.png', array(
 'alt'='New Product Icon',
 'width'=$logo_size[0],
 'height'=$logo_size[1],
 'border'='0',
 'class'='ProductLogo'));

 $queryString_newproducts = str_replace(data[Product][check_1]=,
 data[Product][check_1]=1, $queryString);
 echo $paginator-sort(' New Product', 'product',
 array('url'=array('?'=$queryString_newproducts)));

 ?

 [/code]

 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


Filtering queries with hasMany relationships and pagination

2009-09-14 Thread tiberium911

Part of what I need to use CakePHP for is designing a report system
for computer related data. There are filters on the web page that
users can set to limit which computers are returned. Now my problem
with CakePHP lies with the ability to prune results based on
associations. A given computer has mostly hasMany associations and I
need to be able to use filters with those types of associations. The
only examples Ive found of doing this suggest returning the entire
result set then using PHP to do the filtering. This isn't necessarily
a problem if there is a way to do pagination with the resulting data.
I just haven't seen any examples of paginating an array of data that
isn't created using the pagination query system. Is there a way to do
this? or is there a better way of approaching this whole problem using
CakePHP?

--~--~-~--~~~---~--~~
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: Filtering queries with hasMany relationships and pagination

2009-09-14 Thread Teh Treag

Maybe this article will assist you -
http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/

On Sep 14, 8:52 am, tiberium911 tiberium...@gmail.com wrote:
 Part of what I need to use CakePHP for is designing a report system
 for computer related data. There are filters on the web page that
 users can set to limit which computers are returned. Now my problem
 with CakePHP lies with the ability to prune results based on
 associations. A given computer has mostly hasMany associations and I
 need to be able to use filters with those types of associations. The
 only examples Ive found of doing this suggest returning the entire
 result set then using PHP to do the filtering. This isn't necessarily
 a problem if there is a way to do pagination with the resulting data.
 I just haven't seen any examples of paginating an array of data that
 isn't created using the pagination query system. Is there a way to do
 this? or is there a better way of approaching this whole problem using
 CakePHP?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Searching and filtering on id -- problem with form behavior (forms helper)

2009-07-15 Thread geste

Hello!

I have a table where the primary key, id is not autoincremented, but
is in fact a 6-digit real value.  I want to give people the ability
to search and filter by ID and a few other fields like budget_name.
I have implemented a filter component that I found (here:
http://blog.uplevel.pl/index.php/2008/06/cakephp-12-filter-component/)
and it all works well up to a point, but I am encountering problems
with the way forms helper works by default.  I'll give 2 examples:

If I add the following form bits to my index view:

echo $form-create('Budgets',array('url'=array('action'='index')));
echo $form-input('id');
echo $form-input('budget_name');
echo $form-end('Search');

both inputs appear but neither are applied by the filter when I hit
search.  So I got the notion to qualify each input with the model name
like so:

echo $form-create('Budgets',array('url'=array('action'='index')));
echo $form-input('Budget.id');
echo $form-input('Budget.budget_name');
echo $form-end('Search');

Now I get 1 input for budget_name and searching/filtering works, but
the input for id no longer appears.  I looked at the generated HTML
and the input for id is made hidden (as in this example):

!--
 form id=BudgetsAddForm method=post action=/app/budgets/index
fieldset style=display:none;input type=hidden name=_method
value=POST //fieldset
input type=hidden name=data[Budget][id] value= id=BudgetId /
div class=input textlabel for=BudgetBudgetNameBudget Name/
label
input name=data[Budget][budget_name] type=text maxlength=30
value= id=BudgetBudgetName //div
div class=submitinput type=submit value=Search //div/
form
--

So, am I right in assuming that forms helper handles id in this
conventional way (make it hidden) and is there a way to override this
without breaking general behavior of forms helper.  I looked at the
1.2 Cookbook and I only found a hidden method, no unhidden method.

Jim


(apologies for my formatting. I wasn't sure how Google Groups handle
in-line code snippets.  Automagically, I think.)


--~--~-~--~~~---~--~~
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: Searching and filtering on id -- problem with form behavior (forms helper)

2009-07-15 Thread Bernardo Vieira

Hi,

echo $form-input('Budget.id',array('type' = 'text'));

Have you tried something like that?

geste wrote:
 Hello!

 I have a table where the primary key, id is not autoincremented, but
 is in fact a 6-digit real value.  I want to give people the ability
 to search and filter by ID and a few other fields like budget_name.
 I have implemented a filter component that I found (here:
 http://blog.uplevel.pl/index.php/2008/06/cakephp-12-filter-component/)
 and it all works well up to a point, but I am encountering problems
 with the way forms helper works by default.  I'll give 2 examples:

 If I add the following form bits to my index view:

 echo $form-create('Budgets',array('url'=array('action'='index')));
 echo $form-input('id');
 echo $form-input('budget_name');
 echo $form-end('Search');

 both inputs appear but neither are applied by the filter when I hit
 search.  So I got the notion to qualify each input with the model name
 like so:

 echo $form-create('Budgets',array('url'=array('action'='index')));
 echo $form-input('Budget.id');
 echo $form-input('Budget.budget_name');
 echo $form-end('Search');

 Now I get 1 input for budget_name and searching/filtering works, but
 the input for id no longer appears.  I looked at the generated HTML
 and the input for id is made hidden (as in this example):

 !--
  form id=BudgetsAddForm method=post action=/app/budgets/index
 fieldset style=display:none;input type=hidden name=_method
 value=POST //fieldset
 input type=hidden name=data[Budget][id] value= id=BudgetId /
 div class=input textlabel for=BudgetBudgetNameBudget Name/
 label
 input name=data[Budget][budget_name] type=text maxlength=30
 value= id=BudgetBudgetName //div
 div class=submitinput type=submit value=Search //div/
 form
 --

 So, am I right in assuming that forms helper handles id in this
 conventional way (make it hidden) and is there a way to override this
 without breaking general behavior of forms helper.  I looked at the
 1.2 Cookbook and I only found a hidden method, no unhidden method.

 Jim


 (apologies for my formatting. I wasn't sure how Google Groups handle
 in-line code snippets.  Automagically, I think.)


 

   


--~--~-~--~~~---~--~~
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: Searching and filtering on id -- problem with form behavior (forms helper)

2009-07-15 Thread Carlos Gonzalez Lavin
Maybe try
echo $form-input('Budget.id',array('type' = 'text'));

2009/7/15 geste jim.ho...@gmail.com


 Hello!

 I have a table where the primary key, id is not autoincremented, but
 is in fact a 6-digit real value.  I want to give people the ability
 to search and filter by ID and a few other fields like budget_name.
 I have implemented a filter component that I found (here:
 http://blog.uplevel.pl/index.php/2008/06/cakephp-12-filter-component/)
 and it all works well up to a point, but I am encountering problems
 with the way forms helper works by default.  I'll give 2 examples:

 If I add the following form bits to my index view:

 echo $form-create('Budgets',array('url'=array('action'='index')));
 echo $form-input('id');
 echo $form-input('budget_name');
 echo $form-end('Search');

 both inputs appear but neither are applied by the filter when I hit
 search.  So I got the notion to qualify each input with the model name
 like so:

 echo $form-create('Budgets',array('url'=array('action'='index')));
 echo $form-input('Budget.id');
 echo $form-input('Budget.budget_name');
 echo $form-end('Search');

 Now I get 1 input for budget_name and searching/filtering works, but
 the input for id no longer appears.  I looked at the generated HTML
 and the input for id is made hidden (as in this example):

 !--
  form id=BudgetsAddForm method=post action=/app/budgets/index
 fieldset style=display:none;input type=hidden name=_method
 value=POST //fieldset
 input type=hidden name=data[Budget][id] value= id=BudgetId /
 div class=input textlabel for=BudgetBudgetNameBudget Name/
 label
 input name=data[Budget][budget_name] type=text maxlength=30
 value= id=BudgetBudgetName //div
 div class=submitinput type=submit value=Search //div/
 form
 --

 So, am I right in assuming that forms helper handles id in this
 conventional way (make it hidden) and is there a way to override this
 without breaking general behavior of forms helper.  I looked at the
 1.2 Cookbook and I only found a hidden method, no unhidden method.

 Jim


 (apologies for my formatting. I wasn't sure how Google Groups handle
 in-line code snippets.  Automagically, I think.)


 


--~--~-~--~~~---~--~~
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: Searching and filtering on id -- problem with form behavior (forms helper)

2009-07-15 Thread Carlos Gonzalez Lavin
Damn u beat me to it :(

2009/7/15 Carlos Gonzalez Lavin carloslavi...@gmail.com

 Maybe try
 echo $form-input('Budget.id',array('type' = 'text'));

 2009/7/15 geste jim.ho...@gmail.com


 Hello!

 I have a table where the primary key, id is not autoincremented, but
 is in fact a 6-digit real value.  I want to give people the ability
 to search and filter by ID and a few other fields like budget_name.
 I have implemented a filter component that I found (here:
 http://blog.uplevel.pl/index.php/2008/06/cakephp-12-filter-component/)
 and it all works well up to a point, but I am encountering problems
 with the way forms helper works by default.  I'll give 2 examples:

 If I add the following form bits to my index view:

 echo $form-create('Budgets',array('url'=array('action'='index')));
 echo $form-input('id');
 echo $form-input('budget_name');
 echo $form-end('Search');

 both inputs appear but neither are applied by the filter when I hit
 search.  So I got the notion to qualify each input with the model name
 like so:

 echo $form-create('Budgets',array('url'=array('action'='index')));
 echo $form-input('Budget.id');
 echo $form-input('Budget.budget_name');
 echo $form-end('Search');

 Now I get 1 input for budget_name and searching/filtering works, but
 the input for id no longer appears.  I looked at the generated HTML
 and the input for id is made hidden (as in this example):

 !--
  form id=BudgetsAddForm method=post action=/app/budgets/index
 fieldset style=display:none;input type=hidden name=_method
 value=POST //fieldset
 input type=hidden name=data[Budget][id] value= id=BudgetId /
 div class=input textlabel for=BudgetBudgetNameBudget Name/
 label
 input name=data[Budget][budget_name] type=text maxlength=30
 value= id=BudgetBudgetName //div
 div class=submitinput type=submit value=Search //div/
 form
 --

 So, am I right in assuming that forms helper handles id in this
 conventional way (make it hidden) and is there a way to override this
 without breaking general behavior of forms helper.  I looked at the
 1.2 Cookbook and I only found a hidden method, no unhidden method.

 Jim


 (apologies for my formatting. I wasn't sure how Google Groups handle
 in-line code snippets.  Automagically, I think.)


 



--~--~-~--~~~---~--~~
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: Searching and filtering on id -- problem with form behavior (forms helper)

2009-07-15 Thread geste

Carlos, Bernadoi,

Thank you!  I had not tried just expanding the definition of the
input.  Your quick answers mean I can move on...to be confused by
other things! :).

(I am still a CakePHP novice and I still get a bit nervous about
conventions.  Like should I just throw in the toweal and make all of
my primary keys autoincremented.  But I have some pivotal tables where
it just seems wrong to overlook a very logical key like that budget
number.)

Thanks again.  Perhaps this will help some other newbie.

Jim

On Jul 15, 9:14 am, Bernardo Vieira bvieira.li...@gmail.com wrote:
 Hi,

 echo $form-input('Budget.id',array('type' = 'text'));

 Have you tried something like that?

 geste wrote:
  Hello!

  I have a table where the primary key, id is not autoincremented, but
  is in fact a 6-digit real value.  I want to give people the ability
  to search and filter by ID and a few other fields like budget_name.
  I have implemented a filter component that I found (here:
 http://blog.uplevel.pl/index.php/2008/06/cakephp-12-filter-component/)
  and it all works well up to a point, but I am encountering problems
  with the way forms helper works by default.  I'll give 2 examples:

  If I add the following form bits to my index view:

  echo $form-create('Budgets',array('url'=array('action'='index')));
  echo $form-input('id');
  echo $form-input('budget_name');
  echo $form-end('Search');

  both inputs appear but neither are applied by the filter when I hit
  search.  So I got the notion to qualify each input with the model name
  like so:

  echo $form-create('Budgets',array('url'=array('action'='index')));
  echo $form-input('Budget.id');
  echo $form-input('Budget.budget_name');
  echo $form-end('Search');

  Now I get 1 input for budget_name and searching/filtering works, but
  the input for id no longer appears.  I looked at the generated HTML
  and the input for id is made hidden (as in this example):

  !--
   form id=BudgetsAddForm method=post action=/app/budgets/index
  fieldset style=display:none;input type=hidden name=_method
  value=POST //fieldset
  input type=hidden name=data[Budget][id] value= id=BudgetId /
  div class=input textlabel for=BudgetBudgetNameBudget Name/
  label
  input name=data[Budget][budget_name] type=text maxlength=30
  value= id=BudgetBudgetName //div
  div class=submitinput type=submit value=Search //div/
  form
  --

  So, am I right in assuming that forms helper handles id in this
  conventional way (make it hidden) and is there a way to override this
  without breaking general behavior of forms helper.  I looked at the
  1.2 Cookbook and I only found a hidden method, no unhidden method.

  Jim

  (apologies for my formatting. I wasn't sure how Google Groups handle
  in-line code snippets.  Automagically, I think.)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering pagination

2009-07-14 Thread Arnau

Hi!

I need paginated lists, and I see Cake really helps with it.
I use a searcher that filters the list and when I change the page the
filter dissapears.
I see I need to send the conditions of the filter from one page to
another but I think is not a very good idea to pass all the
information using GET.

Does Cake have a cleaner alternative?

Thanks

--~--~-~--~~~---~--~~
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: Filtering pagination

2009-07-14 Thread thatsgreat2345

Just set it in the session

On Jul 14, 3:06 am, Arnau arna...@gmail.com wrote:
 Hi!

 I need paginated lists, and I see Cake really helps with it.
 I use a searcher that filters the list and when I change the page the
 filter dissapears.
 I see I need to send the conditions of the filter from one page to
 another but I think is not a very good idea to pass all the
 information using GET.

 Does Cake have a cleaner alternative?

 Thanks
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



HABTM filtering on find()

2009-07-06 Thread centr0

I have a Book and Author model thats a many to many relationship.  I
was wondering if there was a way in the BooksController that i can
filter out books by author name, and in the AuthorsController filter
out authors by book title.
--~--~-~--~~~---~--~~
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: HABTM filtering on find()

2009-07-06 Thread Teh Treag

centro,

This is covered in the manual.
http://book.cakephp.org/view/78/Associations-Linking-Models-Together#hasAndBelongsToMany-HABTM-83

Good luck.

-teh

On Jul 6, 2:01 am, centr0 centrosc...@gmail.com wrote:
 I have a Book and Author model thats a many to many relationship.  I
 was wondering if there was a way in the BooksController that i can
 filter out books by author name, and in the AuthorsController filter
 out authors by book title.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering results based on ACL

2009-06-10 Thread Saviq

Hi all,

I'm using the Acl component for some of my models to have CRUD
control. Now I need to filter results based on read rights to a model,
I was thinking $model-afterFind() would be a good place, but I can't
access the Acl component from within a model.

What would be a proper way to do that? I'd like to use pagination, too
(though probably rewritten / modified).

Cheers

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering subform values

2009-05-08 Thread Ernesto

Hello.

i have a simple view with a form like this

?php
echo $form-input(Order.Code);
for ($i = 0, $i  10, $i++) {
echo $form-input(Order_Items.. $i ..Code);
echo $form-checkbox(Order_Items.. $i ..Bargain);
}
?

the view returns an array like this

Array = (
[Order] = Array(
[Code] = XXX
)
[Order_Items] = Array(
[0] = Array(
[Code] = Item1
[Bargain] = 1
)
[1] = Array(
[Code] = Item3
[Bargain] = 0
)
[2] = Array(
[Code] = Item3
[Bargain] = 0
)
[3] = Array(
[Code] =
[Bargain] = 0
)
[4] = Array(
[Code] =
[Bargain] = 0
)
[...]
)
)

And so on...

User can input any number of lines. in the above example only the
first 3 lines were filled.

and... here's the problem...

every blank line fails validation (Item.Code has a notEmpty rule)
and stops saving operations

so... is there any smart way to discriminate between blank and user-
input lines?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Smarty not filtering

2009-04-20 Thread timtrice

I've followed any one of the few tutorials in the Bakery on installing
and using Smarty.  However, even though my application's not
generating errors (debug = 3) my variables inside the {} are not
executing.  it's all showing up as text.  Anyone happen to have a
quick solution?  I've Googled smarty not filtering, smarty not
parsing among other things and nothing seems to explain what the deal
is.

Thanks
--~--~-~--~~~---~--~~
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: Smarty not filtering

2009-04-20 Thread blckspder

Can you post some code to give an example of what is happening?

On Apr 20, 3:07 pm, timtrice tim.tr...@gmail.com wrote:
 I've followed any one of the few tutorials in the Bakery on installing
 and using Smarty.  However, even though my application's not
 generating errors (debug = 3) my variables inside the {} are not
 executing.  it's all showing up as text.  Anyone happen to have a
 quick solution?  I've Googled smarty not filtering, smarty not
 parsing among other things and nothing seems to explain what the deal
 is.

 Thanks
--~--~-~--~~~---~--~~
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: Smarty not filtering

2009-04-20 Thread Miles J

Im still baffled why people would use smarty within a framework. Smart
is horrible.
--~--~-~--~~~---~--~~
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: Smarty not filtering

2009-04-20 Thread timtrice

blckspder, I don't think it's code as my application is running fine.
I'm simply using:

{$title_for_layout}

inside my default template.  I was following the tutorial located 
(http://bakery.cakephp.org/articles/view/the-cakephp-blog-tutorial-
with-smarty).  I have the latest version of Smarty with the files that
were in the lib subdirectory copied under vendors/smarty (my
Smarty.class.php file is in this directory).  It seems like there's
something else like a setting or something.

On Apr 20, 4:48 pm, Miles J mileswjohn...@gmail.com wrote:
 Im still baffled why people would use smarty within a framework. Smart
 is horrible.
--~--~-~--~~~---~--~~
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: Smarty not filtering

2009-04-20 Thread timtrice

Miles,

I've avoided using Smarty in Cake for almost a year, now.  But I have
an application that has become rather tiresome to sort thorugh with
all of the programming code (foreach loops, switches, etc.).  While I
would prefer to not have to use another system inside of a system
(because of problems such as theo ne I'm currently experiencing) I am
willing to give it a shot and see if the benefits outweigh the costs.
To simply refuse to do so is quite stubborn, imho.

On Apr 20, 4:48 pm, Miles J mileswjohn...@gmail.com wrote:
 Im still baffled why people would use smarty within a framework. Smart
 is horrible.
--~--~-~--~~~---~--~~
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: Smarty not filtering

2009-04-20 Thread timtrice

I see I have files in my 'tmp/smart/compile' directory.  I don't know
if that helps narrow it down...hopefully

On Apr 20, 5:06 pm, timtrice tim.tr...@gmail.com wrote:
 Miles,

 I've avoided using Smarty in Cake for almost a year, now.  But I have
 an application that has become rather tiresome to sort thorugh with
 all of the programming code (foreach loops, switches, etc.).  While I
 would prefer to not have to use another system inside of a system
 (because of problems such as theo ne I'm currently experiencing) I am
 willing to give it a shot and see if the benefits outweigh the costs.
 To simply refuse to do so is quite stubborn, imho.

 On Apr 20, 4:48 pm, Miles J mileswjohn...@gmail.com wrote:

  Im still baffled why people would use smarty within a framework. Smart
  is horrible.
--~--~-~--~~~---~--~~
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: find('list'): Filtering by a related table's field

2009-04-19 Thread AD7six



On Apr 19, 1:42 am, mattalexx mattal...@gmail.com wrote:
 Okay, thanks.

 By the way, there is nothing about recursion on that page.

That's why it'd be useful if you could add something.

Cheers,

AD
--~--~-~--~~~---~--~~
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: find('list'): Filtering by a related table's field

2009-04-18 Thread mattalexx

Okay, thanks.

By the way, there is nothing about recursion on that page.

On Apr 17, 4:22 pm, AD7six andydawso...@gmail.com wrote:
 On Apr 17, 11:49 pm, mattalexx mattal...@gmail.com wrote:

  'all joins the other table and doesn't give me an error. 'list' on the
  other hand, does not join the table and therefore 'array
  ('Property.mls' = '80578'),' is not available.

 find('list') has a default recrusive value of -1

 Please add to the docs here:http://book.cakephp.org/view/810/find-list

 hth,

 AD
--~--~-~--~~~---~--~~
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: find('list'): Filtering by a related table's field

2009-04-17 Thread John Andersen

How is your PropertyImage model defined?
Does it have a hasMany to the Property model?

I am asking, because your fields definition does not contain the model
name, and the conditions definition contains Property model name, not
PropertyImage model name.
   John

On Apr 17, 6:29 am, mattalexx mattal...@gmail.com wrote:
 PropertyImage hasOne Property.

 Why can't I do this:

 ?php
 // APP/controllers/properties_controllers.php
 $check_property_images = $this-PropertyImage-find('list', array(
         'fields' = array('id'),
         'conditions' = array(
                 array('Property.mls' = '80578'),
                 ),
         ));
 debug($check_property_images);
 ?

 But when I use find('all') it works?
--~--~-~--~~~---~--~~
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: find('list'): Filtering by a related table's field

2009-04-17 Thread mattalexx

?php
class PropertyImage extends AppModel {
var $belongsTo = array(
'Property' = array()
);
}
?

On Apr 17, 12:43 am, John Andersen j.andersen...@gmail.com wrote:
 How is your PropertyImage model defined?
 Does it have a hasMany to the Property model?

 I am asking, because your fields definition does not contain the model
 name, and the conditions definition contains Property model name, not
 PropertyImage model name.
    John

 On Apr 17, 6:29 am, mattalexx mattal...@gmail.com wrote:

  PropertyImage hasOne Property.

  Why can't I do this:

  ?php
  // APP/controllers/properties_controllers.php
  $check_property_images = $this-PropertyImage-find('list', array(
          'fields' = array('id'),
          'conditions' = array(
                  array('Property.mls' = '80578'),
                  ),
          ));
  debug($check_property_images);
  ?

  But when I use find('all') it works?
--~--~-~--~~~---~--~~
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: find('list'): Filtering by a related table's field

2009-04-17 Thread fain182

 PropertyImage hasOne Property.

 Why can't I do this:

 ?php
 // APP/controllers/properties_controllers.php
 $check_property_images = $this-PropertyImage-find('list', array(
        'fields' = array('id'),
        'conditions' = array(
                array('Property.mls' = '80578'),
                ),
        ));
 debug($check_property_images);
 ?

 But when I use find('all') it works?
what you get with 'all' and with 'list' ?
it gives you error ?

--~--~-~--~~~---~--~~
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: find('list'): Filtering by a related table's field

2009-04-17 Thread mattalexx

'all joins the other table and doesn't give me an error. 'list' on the
other hand, does not join the table and therefore 'array
('Property.mls' = '80578'),' is not available.

On Apr 17, 3:41 pm, fain182 fain...@gmail.com wrote:
  PropertyImage hasOne Property.

  Why can't I do this:

  ?php
  // APP/controllers/properties_controllers.php
  $check_property_images = $this-PropertyImage-find('list', array(
         'fields' = array('id'),
         'conditions' = array(
                 array('Property.mls' = '80578'),
                 ),
         ));
  debug($check_property_images);
  ?

  But when I use find('all') it works?

 what you get with 'all' and with 'list' ?
 it gives you error ?
--~--~-~--~~~---~--~~
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: find('list'): Filtering by a related table's field

2009-04-17 Thread AD7six



On Apr 17, 11:49 pm, mattalexx mattal...@gmail.com wrote:
 'all joins the other table and doesn't give me an error. 'list' on the
 other hand, does not join the table and therefore 'array
 ('Property.mls' = '80578'),' is not available.

find('list') has a default recrusive value of -1

Please add to the docs here:
http://book.cakephp.org/view/810/find-list

hth,

AD
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



find('list'): Filtering by a related table's field

2009-04-16 Thread mattalexx

PropertyImage hasOne Property.

Why can't I do this:

?php
// APP/controllers/properties_controllers.php
$check_property_images = $this-PropertyImage-find('list', array(
'fields' = array('id'),
'conditions' = array(
array('Property.mls' = '80578'),
),
));
debug($check_property_images);
?

But when I use find('all') it works?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



filtering with the containable behavior

2009-04-02 Thread RyOnLife


I am trying to filter with the containable behavior:

$favs = $this-VideoItemFavorite-find('all', array(
  'conditions' = array(
'VideoItemFavorite.user_id' = Configure::read('user_id')
  ),
  //'limit' = 3,
  'contain' = array(
'VideoItem.video_list_id = ' . $vl_id,
'VideoItem.Video'
  )
));

The (undesirable) result of this query is to deliver all VideoItemFavorite 
records that match the find condition. For all matches returned, if 
VideoItem.video_list_id = $vl_id, then VideoItem.Video is included in the 
array. If VideoItem.video_list_id != $vl_id, I still get VideoItemFavorite 
(which is not wanted), but no VideoItem.Video.

What I would like to happen:

Deliver VideoItemFavorite records only if the associated 
VideoItem.video_list_id = $vl_id.

It's not valid, but this is how I'd like to write the query:

$favs = $this-VideoItemFavorite-find('all', array(
  'conditions' = array(
'VideoItemFavorite.user_id' = Configure::read('user_id'),
'VideoItemFavorite.VideoItem.video_list_id' = $vl_id
  ),
  //'limit' = 3,
  'contain' = array('VideoItem.Video')
));

Can someone please clue me in on a workable way to get that result?
-- 
View this message in context: 
http://n2.nabble.com/filtering-with-the-containable-behavior-tp2578823p2578823.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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: Querying / filtering an array done by find('threaded')

2009-03-31 Thread toka...@gmail.com

Okay, I got it!! I don't know if there is some Cake's better solution
but this works fine for me
I have made my own function that goes trough the whole threaded array
and extracts childs for top level section specified by ID.

/**
 * Extracts child node(s) for specific top level section id
 *
 * @param $Sections - an array outputed from $this-Section-find
('threaded');  Includes all branches generated with nested arrays.
 * @param $id - id of the top level section whose childs will be
returned
 * @return an array of childs of section specified
 */
function getSectionChilds($Sections, $id){

foreach($Sections as $Section)
{
  if( $Section['Section']['id'] == $id ) return $Section
['children'];
}
return false;
}


On Mar 30, 8:39 pm, toka...@gmail.com toka...@gmail.com wrote:
 I have tried also $this-Section-children($id), that seems to be ok,
 but it doesnt generate such nice nested structure like find
 ('threaded').  Is there any change to filter threaded array similar
 way like getting childs from the tree? Tnkx Tomas
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Querying / filtering an array done by find('threaded')

2009-03-30 Thread Tokasa


Hi, I got a little problem how to get only specific branch of categories in
my threaded array.

Imagine self-joined table with categories  joined by parent ID.

e.g. e-shop sections like Bikes, Electronics, Vines, ... etc..
Each of them have its own categories, who have its own categories, etc...

I would like to use find('threaded'), but just PER one section (e.g. vines)
... Now I get the WHOLE tree! Thats I dont want, I would prefer say in
conditions  Category.name = 'vines' and receive already array just with
wines.. but that seems not working, with conditions I dont get childers!!
becasue they dont match that conditions (of course :))

Any Ideas? Is it better to filter the result or it is possible specify that
when querying database??

I am posting an example array I get now (just with find('threaded')): 

Array
(
[0] = Array
(
[Section] = Array
(
[id] = 1
[parent_id] = 
[name] = Vine
)

[ParentSection] = Array
(
[id] = 
[parent_id] = 
[name] = 
)

[children] = Array
(
[0] = Array
(
[Section] = Array
(
[id] = 4
[parent_id] = 1
[name] = Red
)
   )
)
)

[1] = Array
(
[Section] = Array
(
[id] = 1
[parent_id] = 
[name] = Electronic
)

[ParentSection] = Array
(
[id] = 
[parent_id] = 
[name] = 
)

[children] = Array
(
[0] = Array
(
[Section] = Array
(
[id] = 4
[parent_id] = 1
[name] = Computer
)
   )
)
)
)


Thanks a lot!
Tomas


-- 
View this message in context: 
http://www.nabble.com/Querying---filtering-an-array-done-by-find%28%27threaded%27%29-tp22782400p22782400.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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: Querying / filtering an array done by find('threaded')

2009-03-30 Thread toka...@gmail.com

I have tried also $this-Section-children($id), that seems to be ok,
but it doesnt generate such nice nested structure like find
('threaded').  Is there any change to filter threaded array similar
way like getting childs from the tree? Tnkx Tomas
--~--~-~--~~~---~--~~
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: Filtering by HABTM model count

2009-03-27 Thread grigri

When you use the `bindModel` call, use a different alias.

Example:

$this-bindModel(array('hasOne'=array(
'AlbumsImageBacon'=array(
  'className' = 'AlbumsImage'
),
'ImageBacon'=array(
 'className'='Image',
 'foreignKey'=false,
 'type'='INNER',
 'conditions'=array(
 'ImageBacon.status = 0',
 'ImageBacon.id = 
AlbumsImageBacon.image_id')
 )
)
));

hth
grigri

On Mar 27, 12:31 am, volve bclay...@gmail.com wrote:
 My problem: Show the user 4 Albums where each Album has = 1 Images.

 I started this project in CakePHP 1.1 and realized quickly I couldn't
 create an elegant solution, so I've recently upgraded to 1.2.2 and am
 trying again.

 My code below works correctly and returns a wonderful array with all
 the pieces of data I need. The really odd thing is that after Cake has
 sent the first query, joining all the necessary tables, it then goes
 back to query the Image model 4 times, each time failing because it
 attempts to use the non-joined AlbumsImage HABTM association in the
 where clause.

 Here's the error and offending SQL:

 Warning (512): SQL Error: 1054: Unknown column 'AlbumsImage.image_id'
 in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php,
 line 525]

 SELECT   `image`.`id`,`image`.`title`,`image`.`host`,`image`.`path`
 FROM     `images` AS `image`
 WHERE    `image`.`status` = 0
          AND `image`.`id` = `albumsimage`.`image_id`
 ORDER BY `image`.`created` ASC

 I don't know why this query is even being issued, but as I say it's
 all the more odd because the main query (below) returns successfully.

 SELECT
 `album`.`id`,`album`.`user_id`,`album`.`title`,USER.id,USER.username,`user`.`id`
 FROM     `albums` AS `album`
          LEFT JOIN `users` AS `user`
            ON (`album`.`user_id` = `user`.`id`)
          LEFT JOIN `albums_images` AS `albumsimage`
            ON (`albumsimage`.`album_id` = `album`.`id`)
          INNER JOIN `images` AS `image`
            ON (`image`.`status` = 0
                AND `image`.`id` = `albumsimage`.`image_id`)
 WHERE    `album`.`status` = 0
 GROUP BY `album`.`id`,`album`.`title`
 HAVING   Count(* ) = 1
 ORDER BY `album`.`created` DESC,`image`.`created` ASC
 LIMIT    4

 Here is the method of the Album model I use to query Albums where
 Image count = 1:

   function gimme($num=6) {
     $contain = array(
       'AlbumsImage',
       'Image'=array('ImageSize',
                      'fields'=array
 ('Image.id','Image.title','Image.host','Image.path'),
                      'order' = 'Image.created ASC'
                      ),
       'User'=array('fields'='User.id,User.username'));

     $this-resetAssociations(); // just in case

     $this-bindModel(array('hasOne'=array('AlbumsImage',
                                            'Image'=array(
                                                  'className'='Image',
                                                  'foreignKey'=false,
                                                  'type'='INNER',
                                                  'conditions'=array(
                                                      'Image.status =
 0',
                                                      'Image.id =
 AlbumsImage.image_id')
                                                  )
                                            )
                            ));

     $albums = $this-find('all', array('contain' = $contain,
                                     'conditions' = array
 ('Album.status'='0'),
                                         'fields' = array
 ('Album.id','Album.user_id','Album.title'),
                                          'order' = 'Album.created
 DESC',
                                          'limit' = $num,
                                          'group' = array
 ('Album.id','Album.title HAVING COUNT(*) = 1'))); // we only want
 Albums with 1 or more images
     return $albums;
   }

 I've been trying to figure this out all day so would /really/
 appreciate any insights into this weird SQL error.

 Thanks everyone!
 -volve
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering by HABTM model count

2009-03-26 Thread volve

My problem: Show the user 4 Albums where each Album has = 1 Images.

I started this project in CakePHP 1.1 and realized quickly I couldn't
create an elegant solution, so I've recently upgraded to 1.2.2 and am
trying again.

My code below works correctly and returns a wonderful array with all
the pieces of data I need. The really odd thing is that after Cake has
sent the first query, joining all the necessary tables, it then goes
back to query the Image model 4 times, each time failing because it
attempts to use the non-joined AlbumsImage HABTM association in the
where clause.

Here's the error and offending SQL:

Warning (512): SQL Error: 1054: Unknown column 'AlbumsImage.image_id'
in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php,
line 525]

SELECT   `image`.`id`,`image`.`title`,`image`.`host`,`image`.`path`
FROM `images` AS `image`
WHERE`image`.`status` = 0
 AND `image`.`id` = `albumsimage`.`image_id`
ORDER BY `image`.`created` ASC

I don't know why this query is even being issued, but as I say it's
all the more odd because the main query (below) returns successfully.

SELECT
`album`.`id`,`album`.`user_id`,`album`.`title`,USER.id,USER.username,`user`.`id`
FROM `albums` AS `album`
 LEFT JOIN `users` AS `user`
   ON (`album`.`user_id` = `user`.`id`)
 LEFT JOIN `albums_images` AS `albumsimage`
   ON (`albumsimage`.`album_id` = `album`.`id`)
 INNER JOIN `images` AS `image`
   ON (`image`.`status` = 0
   AND `image`.`id` = `albumsimage`.`image_id`)
WHERE`album`.`status` = 0
GROUP BY `album`.`id`,`album`.`title`
HAVING   Count(* ) = 1
ORDER BY `album`.`created` DESC,`image`.`created` ASC
LIMIT4


Here is the method of the Album model I use to query Albums where
Image count = 1:

  function gimme($num=6) {
$contain = array(
  'AlbumsImage',
  'Image'=array('ImageSize',
 'fields'=array
('Image.id','Image.title','Image.host','Image.path'),
 'order' = 'Image.created ASC'
 ),
  'User'=array('fields'='User.id,User.username'));

$this-resetAssociations(); // just in case

$this-bindModel(array('hasOne'=array('AlbumsImage',
   'Image'=array(
 'className'='Image',
 'foreignKey'=false,
 'type'='INNER',
 'conditions'=array(
 'Image.status =
0',
 'Image.id =
AlbumsImage.image_id')
 )
   )
   ));

$albums = $this-find('all', array('contain' = $contain,
'conditions' = array
('Album.status'='0'),
'fields' = array
('Album.id','Album.user_id','Album.title'),
 'order' = 'Album.created
DESC',
 'limit' = $num,
 'group' = array
('Album.id','Album.title HAVING COUNT(*) = 1'))); // we only want
Albums with 1 or more images
return $albums;
  }

I've been trying to figure this out all day so would /really/
appreciate any insights into this weird SQL error.

Thanks everyone!
-volve
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering by paths.

2009-01-14 Thread atlantageek

Is there a method to filter access to certain web pages in a cake
application using apache.
--~--~-~--~~~---~--~~
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: Pagination Filtering Conditions

2008-12-03 Thread Juan Sierra

I post here the way I solved in case someone found it useful as well.
I was reading several of the solutions available on the group but none
of them was working 100% for me, so I tried to figure it out the best
I could:

in the controller:

class ExpensesController extends AppController
{
...
  var $paginate = array(
 'limit' = 15,
 'order' = array(
 'Expense.stamp' = 'asc'
 )
 );
...
function index ()
{
  //set current month and year by default
  $month = date (m);
  $year = date (Y);

  //do we receive something from the form?
  if (
 !empty ($this-params['data']['filter']['month']['month'])

 !empty ($this-params['data']['filter']['year']['year']))
 {
// yes, we forget about paging stuff
$month = $this-params['data']['filter']['month']
['month'];
$year = $this-params['data']['filter']['year']
['year'];
 }
 else
 {
//no, then maybe we are paging
if (
!empty ($this-params ['named']['filter.month']) 
!empty ($this-params ['named']['filter.year']))
{
   $month = $this-params ['named']['filter.month'];
   $year = $this-params ['named']
['filter.year'];
}
 }

  $this-params['pass']['filter.month'] = $month;
  $this-params['pass']['filter.year'] = $year;

  $data = $this-paginate('Expense', Expense.stamp LIKE '%$year-
$month%');// AND Expense.stamp LIKE '%-$month-%');
  $this-set(compact('data'));
}
...
}

in the view:
!-- this are the filtering combos --
?= $form-create('Expense', array('type' = 'post', 'action' =
'index')); ?
?= $form-month (filter.month, $this-params [pass]
[filter.month], array (), false); ?
?= $form-year (filter.year, 2000, 2020, $this-params [pass]
[filter.year], array (), false); ?
?= $form-end('View'); ?
!-- iterate the data ... --
...
!-- ... and show the go to page 1 | 2 | 3 --
?php unset($this-params['pass']['page']); //read it somewhere in
this group, it was useful ?
Go to Page: ?= $paginator-numbers(array('url' = $this-params
['pass'])); //it's important to pass this params.pass?

If you see something I'm doing badly wrong or unnecesary please
advise. thanks

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Pagination Filtering Conditions

2008-11-27 Thread Juan Sierra

Hi there,

I'm trying to do a very simple thing, I'm sure there is something
important missing - I just started a few days ago with CakePHP.

I want to display an expenses table with pagination and two controls
for filtering the year and month.

The filtering works fine, the pagination as well, but no together.

let's say I apply a date filter in the query, then the view displays
correctly the results, with the correct page numbers (Page 1 | 2) etc.
then I click on Page 2 and the filter is not applied anymore showing
the whole table.

This is my controller:

expenses_controller.php
   function index ()
   {
  $this-pageTitle = 'Your company Expenses';

  $month = $this-data['Expense']['month'];
  $year = $this-data['Expense']['year'];

  $data = $this-paginate('Expense', array (Expense.stamp LIKE '%
$year-$month%'));

  $this-set(compact('data'));
   }

And this is my view:

index.ctp
...
!-- two select boxes to filter by year and month --
?= $form-create('Expense', array('type' = 'post', 'action' =
'index')); ?
?= $form-month (, $this-data [Expense][month], array (),
false); ?
?= $form-year (, 2000, 2020, $this-data [Expense][year],
array (), false); ?
?= $form-end('View'); ?
...
(iterate results)
...
Go to Page: ?= $paginator-numbers(); ?

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



CSS aggregation / asset filtering

2008-11-18 Thread the_woodsman

Hey Bakers,

I came across Asset/filter.css in my core file, and thought I'd try
and get it working - so far no luck!
I'm assuming its supposed to aggregate all my CSS files into one big
one?

I've saved the csspp file in the vendors/csspp/csspp.php

I did find the core setting a bit confusing -

Configure::write('Asset.filter.css', 'css.php'); //is css.php supposed
to point to csspp.php??

But when I load my pages, there's no CSS.
I can see various links have changed to /ccss/myfile.css, but these
requests return empty files, albeit with a 200 OK status code.
I don't have a folder called /ccss in my webroot- I tried creating it
manually, still no luck.

Does anyone have experience with this? Are there any docs/blog posts
I've missed?

Thanks,
Elwood


--~--~-~--~~~---~--~~
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: CSS aggregation / asset filtering

2008-11-18 Thread Dardo Sordi Bogado

Hi,

On Tue, Nov 18, 2008 at 4:00 PM, the_woodsman [EMAIL PROTECTED] wrote:

 Hey Bakers,

 I came across Asset/filter.css in my core file, and thought I'd try
 and get it working - so far no luck!
 I'm assuming its supposed to aggregate all my CSS files into one big
 one?

 I've saved the csspp file in the vendors/csspp/csspp.php

 I did find the core setting a bit confusing -

 Configure::write('Asset.filter.css', 'css.php'); //is css.php supposed
 to point to csspp.php??

No, it points to the name of the file css.php in your webroot,

 But when I load my pages, there's no CSS.
 I can see various links have changed to /ccss/myfile.css, but these
 requests return empty files, albeit with a 200 OK status code.

It's ok, probably there is a problem with your csspp.php

 I don't have a folder called /ccss in my webroot- I tried creating it
 manually, still no luck.

You don't need one, it's handled with mod_rewrite.

 Does anyone have experience with this? Are there any docs/blog posts
 I've missed?

I read the manual, instaled csspp.php and have it working. But it
didn't aggregate all my css into one, and that is what I wanted to do
(aslo corrupted my css files, but that is beacuse of csspp.php) so I
made a patch for css.php (the one in the webroot) to parse all the
@includes in the css and make one big css. I have disabled csspp in
webroot/css.php because it corrupts my css. The patch for the includes
is here: https://trac.cakephp.org/ticket/5234

I use it and YSlow is happy now ;)


HTH,
- Dardo Sordi.

 Thanks,
 Elwood


 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering controller

2008-10-14 Thread machuidel

Hello,

How can I map a controller to an URL like /countries/12/cities/ such
that the index of cities will be filtered by the specified country? I
would like that URL to dispatch the city controller (not the
country controller) with the specified country as its argument.
Something like:

class CityController extends AppController {

  ...

  function index_country ($country_id) {
 // Index of cities filtered by specified country
  }

  ...

}

Could not find any example of someone doing this in Cakephp.

Cheers,
Mike

--~--~-~--~~~---~--~~
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: Filtering controller

2008-10-14 Thread David C. Zentgraf

http://book.cakephp.org/view/542/Defining-Routes

Your route would look something like:

Router::connect('/countries/:country_id/cities/*', array('controller'  
= 'cities', 'action' = 'someCityAction'));

The 'country_id' will be available in $this-params in the controller.

On 15 Oct 2008, at 08:31, machuidel wrote:


 Hello,

 How can I map a controller to an URL like /countries/12/cities/ such
 that the index of cities will be filtered by the specified country? I
 would like that URL to dispatch the city controller (not the
 country controller) with the specified country as its argument.
 Something like:

 class CityController extends AppController {

  ...

  function index_country ($country_id) {
 // Index of cities filtered by specified country
  }

  ...

 }

 Could not find any example of someone doing this in Cakephp.

 Cheers,
 Mike

 


--~--~-~--~~~---~--~~
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: Filtering controller

2008-10-14 Thread machuidel

Hi David,

Thank you. That was very helpful.

I added the following route:

Router::connect('/countries/:country_id/cities/*', array('controller'
= 'cities'));

This route points to the following function inside the cities
controller:

function index() {
$this-City-recursive = 0;
$this-set('cities', $this-paginate());
}

I was thinking about passing the country_id to the paginate()
function as its criteria.
Do you know of a better way to filter the data?

Cheers,
Mike

On Oct 15, 3:07 am, David C. Zentgraf [EMAIL PROTECTED] wrote:
 http://book.cakephp.org/view/542/Defining-Routes

 Your route would look something like:

 Router::connect('/countries/:country_id/cities/*', array('controller'  
 = 'cities', 'action' = 'someCityAction'));

 The 'country_id' will be available in $this-params in the controller.

 On 15 Oct 2008, at 08:31, machuidel wrote:



  Hello,

  How can I map a controller to an URL like /countries/12/cities/ such
  that the index of cities will be filtered by the specified country? I
  would like that URL to dispatch the city controller (not the
  country controller) with the specified country as its argument.
  Something like:

  class CityController extends AppController {

   ...

   function index_country ($country_id) {
      // Index of cities filtered by specified country
   }

   ...

  }

  Could not find any example of someone doing this in Cakephp.

  Cheers,
  Mike
--~--~-~--~~~---~--~~
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: Filtering on sub table

2008-09-29 Thread Mickael Gentil
I think I was not clear and I apologize or i'm not understanding and i
apologize too :)

In my view, i've some input on top of my list to filter datas helped with
Paginator helper and Filter component.

When i want to filter or sort on a field on 2nd model, i've no problems. But
when i want to filter or sort on a field on 3rd or more model, i don't know
how do that, and all my tests were been without success.

Ex. :
$array['Program']['ProgramBroadcaster']['id']; //No problem with it
$array['Program']['ProgramBroadcaster']['Broadcaster']['name']; //Not
working

Thanks.

Yudao.

On Mon, Sep 29, 2008 at 7:43 AM, glenda guo [EMAIL PROTECTED] wrote:

 In this case, you can add filter in models when you  create relation with
 models.

 If you don't know how to use the query result in view, you can use print_r
 function to print the results, then you can know how to use it.
 Also , you can reference this page
 http://book.cakephp.org/view/78/Associations-Linking-Models-Together






 On Sun, Sep 28, 2008 at 4:30 PM, Mickael Gentil [EMAIL PROTECTED]wrote:

 Ok, but the conditions are for the select and not for filtering dataswich is 
 the result from this select, no ?

 And on my view what name for my select i can use ?

 Because $this-ProgramBroadcaster-Program-ProgramFile-ProgramState is a
 very deeper relationship.

 Thanks.

 Yudao.


 On Sun, Sep 28, 2008 at 4:19 AM, glenda guo [EMAIL PROTECTED] wrote:

 $this-set('programStateList', $this-ProgramBroadcaster-
 Program-ProgramFile-ProgramState-find('list'));

 You can add condition  in it.




 On Sat, Sep 27, 2008 at 10:43 PM, Mickael Gentil 
 [EMAIL PROTECTED] wrote:

 Hi all,

 I need some help with a problem.

 This is my controller :

 ?php
 class ProgramBroadcastersController extends AppController {

 var $name = 'ProgramBroadcasters';
 var $components = array('Filter');

 var $paginate = array(
'limit'=20,
'page'=1,
'order'='ProgramBroadcaster.created DESC',

 'fields'=array('id','broadcaster_id','program_id','play_date','delivery_date','case_number','video_tape_number'),
'contain'=array(
'Broadcaster'=array('fields'=array('id','name')),
'Program'=array(
'ProgramFile'=array(

 'fields'=array('id','program_id','program_state_id'),
'ProgramState',

 'User'=array('fields'=array('lastname','firstname'))
 )
 )
)
 );

 public function index()
 {
 $this-set('broadcasterList',
 $this-ProgramBroadcaster-Broadcaster-find('list'));
 $this-set('programStateList',
 $this-ProgramBroadcaster-Program-ProgramFile-ProgramState-find('list'));

 $filter = $this-Filter-process($this);
 $this-set('url',$this-Filter-url);
 $this-set('programs', $this-paginate(null, $filter));

 }
 }

 I need to filter datas on ProgramState.id, and i don't know how.

 Thanks a lot.

 Yudao.










 


--~--~-~--~~~---~--~~
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: Filtering on sub table

2008-09-29 Thread glenda guo
Does the Program  and  Broadcaster relationship type is
hasAndBelongsToMany?

In this case,  you need to create hasAndBelongsToMany relationshipship  in
Program model, when you want to get the Broadcast data, you can use
$array['Program']['Broadcast'][
0- (sizeof9$array['Program']['Broadcast']) -1]['field_name']  to get the
data.


If you don't know how to use data in view, in your corresponding action, as
below, print_r($array), then you can see all the data.


On Mon, Sep 29, 2008 at 2:58 PM, Mickael Gentil [EMAIL PROTECTED]wrote:

 I think I was not clear and I apologize or i'm not understanding and i
 apologize too :)

 In my view, i've some input on top of my list to filter datas helped with
 Paginator helper and Filter component.

 When i want to filter or sort on a field on 2nd model, i've no problems.
 But when i want to filter or sort on a field on 3rd or more model, i don't
 know how do that, and all my tests were been without success.

 Ex. :
 $array['Program']['ProgramBroadcaster']['id']; //No problem with it
 $array['Program']['ProgramBroadcaster']['Broadcaster']['name']; //Not
 working

 Thanks.

 Yudao.

 On Mon, Sep 29, 2008 at 7:43 AM, glenda guo [EMAIL PROTECTED] wrote:

 In this case, you can add filter in models when you  create relation with
 models.

 If you don't know how to use the query result in view, you can use print_r
 function to print the results, then you can know how to use it.
 Also , you can reference this page
 http://book.cakephp.org/view/78/Associations-Linking-Models-Together






 On Sun, Sep 28, 2008 at 4:30 PM, Mickael Gentil [EMAIL PROTECTED]
  wrote:

 Ok, but the conditions are for the select and not for filtering dataswich 
 is the result from this select, no ?

 And on my view what name for my select i can use ?

 Because $this-ProgramBroadcaster-Program-ProgramFile-ProgramState is
 a very deeper relationship.

 Thanks.

 Yudao.


 On Sun, Sep 28, 2008 at 4:19 AM, glenda guo [EMAIL PROTECTED] wrote:

 $this-set('programStateList', $this-ProgramBroadcaster-
 Program-ProgramFile-ProgramState-find('list'));

 You can add condition  in it.




 On Sat, Sep 27, 2008 at 10:43 PM, Mickael Gentil 
 [EMAIL PROTECTED] wrote:

 Hi all,

 I need some help with a problem.

 This is my controller :

 ?php
 class ProgramBroadcastersController extends AppController {

 var $name = 'ProgramBroadcasters';
 var $components = array('Filter');

 var $paginate = array(
'limit'=20,
'page'=1,
'order'='ProgramBroadcaster.created DESC',

 'fields'=array('id','broadcaster_id','program_id','play_date','delivery_date','case_number','video_tape_number'),
'contain'=array(
'Broadcaster'=array('fields'=array('id','name')),
'Program'=array(
'ProgramFile'=array(

 'fields'=array('id','program_id','program_state_id'),
'ProgramState',

 'User'=array('fields'=array('lastname','firstname'))
 )
 )
)
 );

 public function index()
 {
 $this-set('broadcasterList',
 $this-ProgramBroadcaster-Broadcaster-find('list'));
 $this-set('programStateList',
 $this-ProgramBroadcaster-Program-ProgramFile-ProgramState-find('list'));

 $filter = $this-Filter-process($this);
 $this-set('url',$this-Filter-url);
 $this-set('programs', $this-paginate(null, $filter));

 }
 }

 I need to filter datas on ProgramState.id, and i don't know how.

 Thanks a lot.

 Yudao.













 


--~--~-~--~~~---~--~~
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: Filtering on sub table

2008-09-28 Thread Mickael Gentil
Ok, but the conditions are for the select and not for filtering datas wich
is the result from this select, no ?

And on my view what name for my select i can use ?

Because $this-ProgramBroadcaster-Program-ProgramFile-ProgramState is a
very deeper relationship.

Thanks.

Yudao.

On Sun, Sep 28, 2008 at 4:19 AM, glenda guo [EMAIL PROTECTED] wrote:

 $this-set('programStateList', $this-ProgramBroadcaster-
 Program-ProgramFile-ProgramState-find('list'));

 You can add condition  in it.




 On Sat, Sep 27, 2008 at 10:43 PM, Mickael Gentil [EMAIL PROTECTED]
  wrote:

 Hi all,

 I need some help with a problem.

 This is my controller :

 ?php
 class ProgramBroadcastersController extends AppController {

 var $name = 'ProgramBroadcasters';
 var $components = array('Filter');

 var $paginate = array(
'limit'=20,
'page'=1,
'order'='ProgramBroadcaster.created DESC',

 'fields'=array('id','broadcaster_id','program_id','play_date','delivery_date','case_number','video_tape_number'),
'contain'=array(
'Broadcaster'=array('fields'=array('id','name')),
'Program'=array(
'ProgramFile'=array(

 'fields'=array('id','program_id','program_state_id'),
'ProgramState',

 'User'=array('fields'=array('lastname','firstname'))
 )
 )
)
 );

 public function index()
 {
 $this-set('broadcasterList',
 $this-ProgramBroadcaster-Broadcaster-find('list'));
 $this-set('programStateList',
 $this-ProgramBroadcaster-Program-ProgramFile-ProgramState-find('list'));

 $filter = $this-Filter-process($this);
 $this-set('url',$this-Filter-url);
 $this-set('programs', $this-paginate(null, $filter));

 }
 }

 I need to filter datas on ProgramState.id, and i don't know how.

 Thanks a lot.

 Yudao.




 


--~--~-~--~~~---~--~~
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: Filtering on sub table

2008-09-28 Thread glenda guo
In this case, you can add filter in models when you  create relation with
models.

If you don't know how to use the query result in view, you can use print_r
function to print the results, then you can know how to use it.
Also , you can reference this page
http://book.cakephp.org/view/78/Associations-Linking-Models-Together





On Sun, Sep 28, 2008 at 4:30 PM, Mickael Gentil [EMAIL PROTECTED]wrote:

 Ok, but the conditions are for the select and not for filtering datas wich
 is the result from this select, no ?

 And on my view what name for my select i can use ?

 Because $this-ProgramBroadcaster-Program-ProgramFile-ProgramState is a
 very deeper relationship.

 Thanks.

 Yudao.


 On Sun, Sep 28, 2008 at 4:19 AM, glenda guo [EMAIL PROTECTED] wrote:

 $this-set('programStateList', $this-ProgramBroadcaster-
 Program-ProgramFile-ProgramState-find('list'));

 You can add condition  in it.




 On Sat, Sep 27, 2008 at 10:43 PM, Mickael Gentil 
 [EMAIL PROTECTED] wrote:

 Hi all,

 I need some help with a problem.

 This is my controller :

 ?php
 class ProgramBroadcastersController extends AppController {

 var $name = 'ProgramBroadcasters';
 var $components = array('Filter');

 var $paginate = array(
'limit'=20,
'page'=1,
'order'='ProgramBroadcaster.created DESC',

 'fields'=array('id','broadcaster_id','program_id','play_date','delivery_date','case_number','video_tape_number'),
'contain'=array(
'Broadcaster'=array('fields'=array('id','name')),
'Program'=array(
'ProgramFile'=array(

 'fields'=array('id','program_id','program_state_id'),
'ProgramState',

 'User'=array('fields'=array('lastname','firstname'))
 )
 )
)
 );

 public function index()
 {
 $this-set('broadcasterList',
 $this-ProgramBroadcaster-Broadcaster-find('list'));
 $this-set('programStateList',
 $this-ProgramBroadcaster-Program-ProgramFile-ProgramState-find('list'));

 $filter = $this-Filter-process($this);
 $this-set('url',$this-Filter-url);
 $this-set('programs', $this-paginate(null, $filter));

 }
 }

 I need to filter datas on ProgramState.id, and i don't know how.

 Thanks a lot.

 Yudao.







 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering on sub table

2008-09-27 Thread Mickael Gentil
Hi all,

I need some help with a problem.

This is my controller :

?php
class ProgramBroadcastersController extends AppController {

var $name = 'ProgramBroadcasters';
var $components = array('Filter');

var $paginate = array(
   'limit'=20,
   'page'=1,
   'order'='ProgramBroadcaster.created DESC',

'fields'=array('id','broadcaster_id','program_id','play_date','delivery_date','case_number','video_tape_number'),
   'contain'=array(
   'Broadcaster'=array('fields'=array('id','name')),
   'Program'=array(
   'ProgramFile'=array(

'fields'=array('id','program_id','program_state_id'),
   'ProgramState',

'User'=array('fields'=array('lastname','firstname'))
)
)
   )
);

public function index()
{
$this-set('broadcasterList',
$this-ProgramBroadcaster-Broadcaster-find('list'));
$this-set('programStateList',
$this-ProgramBroadcaster-Program-ProgramFile-ProgramState-find('list'));

$filter = $this-Filter-process($this);
$this-set('url',$this-Filter-url);
$this-set('programs', $this-paginate(null, $filter));

}
}

I need to filter datas on ProgramState.id, and i don't know how.

Thanks a lot.

Yudao.

--~--~-~--~~~---~--~~
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: Filtering on sub table

2008-09-27 Thread glenda guo
$this-set('programStateList', $this-ProgramBroadcaster-
Program-ProgramFile-ProgramState-find('list'));

You can add condition  in it.



On Sat, Sep 27, 2008 at 10:43 PM, Mickael Gentil
[EMAIL PROTECTED]wrote:

 Hi all,

 I need some help with a problem.

 This is my controller :

 ?php
 class ProgramBroadcastersController extends AppController {

 var $name = 'ProgramBroadcasters';
 var $components = array('Filter');

 var $paginate = array(
'limit'=20,
'page'=1,
'order'='ProgramBroadcaster.created DESC',

 'fields'=array('id','broadcaster_id','program_id','play_date','delivery_date','case_number','video_tape_number'),
'contain'=array(
'Broadcaster'=array('fields'=array('id','name')),
'Program'=array(
'ProgramFile'=array(

 'fields'=array('id','program_id','program_state_id'),
'ProgramState',

 'User'=array('fields'=array('lastname','firstname'))
 )
 )
)
 );

 public function index()
 {
 $this-set('broadcasterList',
 $this-ProgramBroadcaster-Broadcaster-find('list'));
 $this-set('programStateList',
 $this-ProgramBroadcaster-Program-ProgramFile-ProgramState-find('list'));

 $filter = $this-Filter-process($this);
 $this-set('url',$this-Filter-url);
 $this-set('programs', $this-paginate(null, $filter));

 }
 }

 I need to filter datas on ProgramState.id, and i don't know how.

 Thanks a lot.

 Yudao.

 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Paginator w/ Filtering

2008-09-11 Thread Mark

Hi guys,

I'm trying to get pagination working with filtering/conditions/where-
clause. Here's the solution I've got so far:

?php
class ArticlesController extends AppController {

var $name = 'Articles';
var $scaffold;
var $paginate = array(
'limit' = 2,
'order' = array('Article.created' = 'desc')
);

function index() {
App::import('Sanitize');
if(isset($this-passedArgs['filter'])) 
$this-paginate['conditions']
= Sanitize::clean($this-passedArgs['filter']);
$articles = $this-paginate();
$this-set(compact('articles'));
}
}
?

This lets you add something like /filter:article_category_id=5 to the
URL to filter the results, but when you click next, prev or a column
header, the filter gets removed. Is there anyway I can fix this? And
is this a safe method for production?

Thanks,
Mark

--~--~-~--~~~---~--~~
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: Paginator w/ Filtering

2008-09-11 Thread [EMAIL PROTECTED]

I have no small example for what you are trying to do.

Basically there are two parts to this puzzle. How to get the initial
(posted) search-parameter(s) into paginate. And how to make sure the
pagination links respect your parameters. This last part is done by
setting options for the paginator in your views.
Check out:
http://book.cakephp.org/view/166/Pagination-in-Views

A quick search for paginate search turned up a few things I think
also deal with what you are trying to achieve.

http://groups.google.com/group/cake-php/browse_thread/thread/b78215bd8626e36/6913a6cf3958b4b9?lnk=gstq=paginate+search#6913a6cf3958b4b9

http://groups.google.com/group/cake-php/browse_thread/thread/78633ae512f6e4e1/81a9ce4d83332fb6?lnk=gstq=paginate+search#81a9ce4d83332fb6




On Sep 11, 1:41 pm, Mark [EMAIL PROTECTED] wrote:
 Hi guys,

 I'm trying to get pagination working with filtering/conditions/where-
 clause. Here's the solution I've got so far:

 ?php
 class ArticlesController extends AppController {

         var $name = 'Articles';
         var $scaffold;
         var $paginate = array(
                 'limit' = 2,
                 'order' = array('Article.created' = 'desc')
         );

         function index() {
                 App::import('Sanitize');
                 if(isset($this-passedArgs['filter'])) 
 $this-paginate['conditions']
 = Sanitize::clean($this-passedArgs['filter']);
                 $articles = $this-paginate();
                 $this-set(compact('articles'));
         }}

 ?

 This lets you add something like /filter:article_category_id=5 to the
 URL to filter the results, but when you click next, prev or a column
 header, the filter gets removed. Is there anyway I can fix this? And
 is this a safe method for production?

 Thanks,
 Mark
--~--~-~--~~~---~--~~
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: Paginator w/ Filtering

2008-09-11 Thread Mark

Oh..right under my nose this whole time. I figured that sort of logic
was supposed to go in the controller, so I've been searching this
whole time on how I should do it there..

Anyway, this fixes it and gave me a few more ideas. Thanks!

Mark

On Sep 11, 7:14 am, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 I have no small example for what you are trying to do.

 Basically there are two parts to this puzzle. How to get the initial
 (posted) search-parameter(s) into paginate. And how to make sure the
 pagination links respect your parameters. This last part is done by
 setting options for the paginator in your views.
 Check out:http://book.cakephp.org/view/166/Pagination-in-Views

 A quick search for paginate search turned up a few things I think
 also deal with what you are trying to achieve.

 http://groups.google.com/group/cake-php/browse_thread/thread/b78215bd...

 http://groups.google.com/group/cake-php/browse_thread/thread/78633ae5...

 On Sep 11, 1:41 pm, Mark [EMAIL PROTECTED] wrote:

  Hi guys,

  I'm trying to get pagination working with filtering/conditions/where-
  clause. Here's the solution I've got so far:

  ?php
  class ArticlesController extends AppController {

          var $name = 'Articles';
          var $scaffold;
          var $paginate = array(
                  'limit' = 2,
                  'order' = array('Article.created' = 'desc')
          );

          function index() {
                  App::import('Sanitize');
                  if(isset($this-passedArgs['filter'])) 
  $this-paginate['conditions']
  = Sanitize::clean($this-passedArgs['filter']);
                  $articles = $this-paginate();
                  $this-set(compact('articles'));
          }}

  ?

  This lets you add something like /filter:article_category_id=5 to the
  URL to filter the results, but when you click next, prev or a column
  header, the filter gets removed. Is there anyway I can fix this? And
  is this a safe method for production?

  Thanks,
  Mark


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering hasMany tables

2008-04-18 Thread matw8

G'day all,
I've written a telco billing system using CakePHP (which made life
very easy!  Hooray for Cake!) and I have run into an issue while
writing some reports.

I have customers
A Customer hasMany ServiceNumbers
A ServiceNumber hasMany CallRecords

The problem is that I don't want ALL the CallRecords.  I just want the
records for one month.
How can I find a customer, with associated data, while adding a WHERE
criteria to the CallRecords?

Do I have to use bindModel in the controller (gasp!) and put the
criteria in there?

Any hints would be appreciated
Thanks
Matt Waite

--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Help needed with filtering by (multiple) a HABTM model(s)

2008-02-11 Thread Nasko

grigri,

I've upgraded my CakePHP core to current beta: rev. 6311 and can
verify that what you suggested works just fine!

AD7six, grigri, thank you both for your help!

On Feb 11, 2:24 pm, grigri [EMAIL PROTECTED] wrote:
 What version are you using? I just did a quick test using my
 playground database, and this:

 $this-set('test', $this-Tag-find('count', array('conditions' =
 array('2=2','3=3'),
 'recursive' = 0, 'fields' = array('(COUNT(DISTINCT Tag.parent_id))
 AS
 count';

 Generated this SQL:

 SELECT (COUNT(DISTINCT Tag.parent_id)) AS count FROM `tags` AS `Tag`
 LEFT JOIN `tags` AS `ParentTag` ON (`Tag`.`parent_id` =
 `ParentTag`.`id`) WHERE 2=2 AND 3=3

 As expected, which worked perfectly (rev. 6416).


--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Help needed with filtering by (multiple) a HABTM model(s)

2008-02-11 Thread Nasko

I'm using rev. 5693. Didn't want to upgrade whenever a newer revision
appeared in the branch, and when the pre-beta was released we were
close to finishing the project - I didn't want to take the risk of
missing deadlines by fixing backward inconsistencies, etc.

Your example produced identical errors as the action in my controller.
So I guess it's related to my archaic revision of Cake. I guess I'd
still need to upgrade.

What revision would you recommend me to use - the current beta (rev.
6311) or what's currently in the trunk (branches and trunk both have
rev. 6455 currently)?

Thank you!

On 11 Фев, 14:24, grigri [EMAIL PROTECTED] wrote:
 What version are you using? I just did a quick test using my
 playground database, and this:

 $this-set('test', $this-Tag-find('count', array('conditions' =
 array('2=2','3=3'),
 'recursive' = 0, 'fields' = array('(COUNT(DISTINCT Tag.parent_id))
 AS
 count';

 Generated this SQL:

 SELECT (COUNT(DISTINCT Tag.parent_id)) AS count FROM `tags` AS `Tag`
 LEFT JOIN `tags` AS `ParentTag` ON (`Tag`.`parent_id` =
 `ParentTag`.`id`) WHERE 2=2 AND 3=3

 As expected, which worked perfectly (rev. 6416).


--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Help needed with filtering by (multiple) a HABTM model(s)

2008-02-11 Thread grigri

What version are you using? I just did a quick test using my
playground database, and this:

$this-set('test', $this-Tag-find('count', array('conditions' =
array('2=2','3=3'),
'recursive' = 0, 'fields' = array('(COUNT(DISTINCT Tag.parent_id))
AS
count';

Generated this SQL:

SELECT (COUNT(DISTINCT Tag.parent_id)) AS count FROM `tags` AS `Tag`
LEFT JOIN `tags` AS `ParentTag` ON (`Tag`.`parent_id` =
`ParentTag`.`id`) WHERE 2=2 AND 3=3

As expected, which worked perfectly (rev. 6416).

On Feb 11, 11:17 am, Nasko [EMAIL PROTECTED] wrote:
 grigri,

 I tried this an got this SQL query:

 SELECT Array, 1, COUNT(DISTINCT User.id) AS count, `User`.,
 `User`.`id` FROM `users` AS `User` LEFT JOIN `groups` AS `Group` ON
 (`User`.`group_id` = `Group`.`id`) LEFT JOIN `genders` AS `Gender` ON
 (`User`.`gender_id` = `Gender`.`id`) LEFT JOIN `countries` AS
 `Country` ON (`User`.`country_id` = `Country`.`id`) LEFT JOIN
 `gender_prefferences_users` AS `GenderPrefferenceUser` ON
 (`GenderPrefferenceUser`.`user_id` = `User`.`id`) WHERE count LIMIT 1

 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 ' `User`.`id` FROM `users` AS `User` LEFT JOIN `groups` AS
 `Group` ON (`User`.`gr' at line 1

 In addition the following notices were thrown:

 Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1424]
 Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1426]
 Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1429]
 Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1433]
 Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1436]
 Notice (8): Undefined offset:  1 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1426]
 Notice (8): Undefined offset:  1 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1429]
 Notice (8): Undefined offset:  1 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1433]
 Notice (8): Undefined offset:  1 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1436]
 Notice (8): Undefined offset:  2 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1426]
 Notice (8): Undefined offset:  2 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1429]
 Notice (8): Undefined offset:  2 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1433]
 Notice (8): Undefined offset:  2 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1436]
 Notice (8): Undefined offset:  3 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1426]
 Notice (8): Undefined offset:  3 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1429]
 Notice (8): Undefined offset:  3 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1433]
 Notice (8): Undefined offset:  3 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1436]
 Notice (8): Undefined offset:  4 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1426]
 Notice (8): Undefined offset:  4 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1429]
 Notice (8): Undefined offset:  4 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1433]
 Notice (8): Undefined offset:  4 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1436]
 Notice (8): Undefined offset:  5 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1426]
 Notice (8): Undefined offset:  5 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1429]
 Notice (8): Undefined offset:  5 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1433]
 Notice (8): Undefined offset:  5 [CORE\cake\libs\model\datasources
 \dbo_source.php, line 1436]
 Notice (8): Array to string conversion [CORE\cake\libs\model
 \datasources\dbo_source.php, line 1186]

 On 11 Фев, 12:33, grigri [EMAIL PROTECTED] wrote:

  try implementing User::paginateCount and changing the query:

  class User extends AppModel {
function paginateCount($conditions, $recursive) {
  return $this-find('count', array('conditions' = $conditions,
  'recursive' = $recursive, 'fields' = 'COUNT(DISTINCT User.id) AS
  count'));
}

  }
--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Help needed with filtering by (multiple) a HABTM model(s)

2008-02-11 Thread grigri

try implementing User::paginateCount and changing the query:

class User extends AppModel {
  function paginateCount($conditions, $recursive) {
return $this-find('count', array('conditions' = $conditions,
'recursive' = $recursive, 'fields' = 'COUNT(DISTINCT User.id) AS
count'));
  }
}

On Feb 11, 9:43 am, Nasko [EMAIL PROTECTED] wrote:
 Andy, thank you for your input!

 Okay now I feel like a total **rk for asking something that has been
 a) explained so well in a discussion and b) stuck in the frequent
 discussion page :) The thing is I've actually read that specific
 discussion (plus a bunch of other threads/articles), but because I
 also read that specific thread back half an year ago when searching
 for a solution to a different problem - the trivial filtering of HABTM
 model - I haven't paid attention to the extra info on how to setup
 multiple joins. This time I just browsed the first couple of lines and
 thought that I recalled the discussion and it wouldn't help me as it
 was regarding a different matter :)

 Regarding the DISTINCT operator in fields - I tried setting the fields
 in $paginate as follows:

 $this-paginate['User'] = array(
 'limit' = 3,
 'page' = 1,
 'order' = array('User.id' = 'desc'),
 'fields' = array(
 'DISTINCT User.id',
 'User.*',
 )
 );

 Then, when setting an 'OR' type restriction (HabtmModel.foreign_key_id
 = array(id_1, id_2)), I'm getting the correct records, but wrong data
 in the counter:
 For example if 5 users match the restrictions, and one of them is
 associated with both habtm foreign keys I'm getting 5 records as per
 the DISTINCT operator, but the counter navigation is showing 6
 records:

 View 1 - 3 of 6
 3 records listed

 View 4 - 6 of 6
 2 records listed

 Examining the SQL shows that the DISTINCT operator is not applied the
 COUNT(*) MySQL query:

 SELECT COUNT(*) AS `count` FROM `users` AS `User` LEFT JOIN `groups`
 AS `Group` ON ...
 SELECT DISTINCT `User`.`id`, `User`.*, `User`.`id` FROM `users` AS
 `User` LEFT JOIN `groups` AS `Group` ON...

 Is there a workaround for this inconsistence?

 On 11 Фев, 10:55, AD7six [EMAIL PROTECTED] wrote:

  you can specify fields in var $paginate
 http://groups.google.com/group/cake-php/web/frequent-discussions
  (filtering HABTM data (once more))
--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Help needed with filtering by (multiple) a HABTM model(s)

2008-02-11 Thread Nasko

Andy, thank you for your input!

Okay now I feel like a total **rk for asking something that has been
a) explained so well in a discussion and b) stuck in the frequent
discussion page :) The thing is I've actually read that specific
discussion (plus a bunch of other threads/articles), but because I
also read that specific thread back half an year ago when searching
for a solution to a different problem - the trivial filtering of HABTM
model - I haven't paid attention to the extra info on how to setup
multiple joins. This time I just browsed the first couple of lines and
thought that I recalled the discussion and it wouldn't help me as it
was regarding a different matter :)

Regarding the DISTINCT operator in fields - I tried setting the fields
in $paginate as follows:

$this-paginate['User'] = array(
'limit' = 3,
'page' = 1,
'order' = array('User.id' = 'desc'),
'fields' = array(
'DISTINCT User.id',
'User.*',
)
);

Then, when setting an 'OR' type restriction (HabtmModel.foreign_key_id
= array(id_1, id_2)), I'm getting the correct records, but wrong data
in the counter:
For example if 5 users match the restrictions, and one of them is
associated with both habtm foreign keys I'm getting 5 records as per
the DISTINCT operator, but the counter navigation is showing 6
records:

View 1 - 3 of 6
3 records listed

View 4 - 6 of 6
2 records listed

Examining the SQL shows that the DISTINCT operator is not applied the
COUNT(*) MySQL query:

SELECT COUNT(*) AS `count` FROM `users` AS `User` LEFT JOIN `groups`
AS `Group` ON ...
SELECT DISTINCT `User`.`id`, `User`.*, `User`.`id` FROM `users` AS
`User` LEFT JOIN `groups` AS `Group` ON...

Is there a workaround for this inconsistence?



On 11 Фев, 10:55, AD7six [EMAIL PROTECTED] wrote:

 you can specify fields in var $paginate

 http://groups.google.com/group/cake-php/web/frequent-discussions
 (filtering HABTM data (once more))
--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Help needed with filtering by (multiple) a HABTM model(s)

2008-02-11 Thread AD7six



On Feb 10, 10:57 pm, Nasko [EMAIL PROTECTED] wrote:
 I've been pulling my hair over this puzzle for two days now. I have
 this setup (not actual models - these are changed for clarity):

 Post belongsTo User
 Post hasAndBelongsToMany Category
 Post hasAndBelongsToMany Tag

 I'm doing a search via a filter form and I need a paginated result
 set. I'm familiar with alternative ways of modeling  the Habtm
 associations - a) using a dummy habtm model; b) using an implied
 (auto) or an explicitly designated 'with' association model - that
 could be used to filter by the foreign habtm model, but the problem is
 that all articles or discussions in the groups  I've read are dealing
 with a single HABTM association on which the filtering is done.

 In my case I couldn't paginate or findAll() via the habtm model,
 because I have search conditions in other models associated with
 'Post' - e.g. I need all posts belonging to a specific user,
 associated with a specific category_id and with a specific tag_id.

 I'm not posting all the code in my controller/action - just the
 relevant statements.

 The following works fine:

 $filterConditions = array(
 'Post.active' = 1,
 'Post.user_id' = $user_id,
 'CategoryPost.category_id' = $category_id,
 'PostTag.tag_id' = $tag_id,
 );
 $posts = $this-paginate('Post', $filterConditions);

 Now, I have two valid requirements which are similar to the above and
 which I'm not able to come up with solutions to:

 1) I need the Posts associated to either category_id 'X' or
 category_id 'Y':

 $filterConditions = array(
 'Post.active' = 1,
 'Post.user_id' = $user_id,
 'CategoryPost.category_id' = array($cat1_id, $cat2_id),
 'PostTag.tag_id' = $tag_id,
 );
 $posts = $this-paginate('Post', $filterConditions);

 The issue with this scenario is that I'm getting duplicate records if
 a Post has been associated with both $cat1_id and $cat2_id. I found
 several discussions mentioning a way of passing a $fields array() to
 findAll() and specifying 'DISTINCT PrimaryModel.id' in it. Ok, but I
 have no way of passing a similar $fields array to
 Controller::paginate(). Have I missed anything or is this requirement
 not achievable at all without custom queries.

you can specify fields in var $paginate


 2) To complicate things even further I need to be able to query for
 Posts that are associated to both categories $cat1_id AND $cat2_id. I
 am not even able to come up with the correct syntax for specifying the
 conditions. It just doesn't feel right to use something like:

 $filterConditions = array(
 'Post.active' = 1,
 'Post.user_id' = $user_id,
 'CategoryPost.category_id' = $cat1_id,
 'CategoryPost.category_id' = $cat2_id,
 'PostTag.tag_id' = $tag_id,
 );

 I'd be extremely thankful for any hints on the right solution to these
 issues!

http://groups.google.com/group/cake-php/web/frequent-discussions
(filtering HABTM data (once more))
--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Help needed with filtering by (multiple) a HABTM model(s)

2008-02-11 Thread Nasko

grigri,

I tried this an got this SQL query:

SELECT Array, 1, COUNT(DISTINCT User.id) AS count, `User`.,
`User`.`id` FROM `users` AS `User` LEFT JOIN `groups` AS `Group` ON
(`User`.`group_id` = `Group`.`id`) LEFT JOIN `genders` AS `Gender` ON
(`User`.`gender_id` = `Gender`.`id`) LEFT JOIN `countries` AS
`Country` ON (`User`.`country_id` = `Country`.`id`) LEFT JOIN
`gender_prefferences_users` AS `GenderPrefferenceUser` ON
(`GenderPrefferenceUser`.`user_id` = `User`.`id`) WHERE count LIMIT 1

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 ' `User`.`id` FROM `users` AS `User` LEFT JOIN `groups` AS
`Group` ON (`User`.`gr' at line 1

In addition the following notices were thrown:

Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1424]
Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1426]
Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1429]
Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1433]
Notice (8): Undefined offset:  0 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1436]
Notice (8): Undefined offset:  1 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1426]
Notice (8): Undefined offset:  1 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1429]
Notice (8): Undefined offset:  1 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1433]
Notice (8): Undefined offset:  1 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1436]
Notice (8): Undefined offset:  2 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1426]
Notice (8): Undefined offset:  2 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1429]
Notice (8): Undefined offset:  2 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1433]
Notice (8): Undefined offset:  2 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1436]
Notice (8): Undefined offset:  3 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1426]
Notice (8): Undefined offset:  3 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1429]
Notice (8): Undefined offset:  3 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1433]
Notice (8): Undefined offset:  3 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1436]
Notice (8): Undefined offset:  4 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1426]
Notice (8): Undefined offset:  4 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1429]
Notice (8): Undefined offset:  4 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1433]
Notice (8): Undefined offset:  4 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1436]
Notice (8): Undefined offset:  5 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1426]
Notice (8): Undefined offset:  5 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1429]
Notice (8): Undefined offset:  5 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1433]
Notice (8): Undefined offset:  5 [CORE\cake\libs\model\datasources
\dbo_source.php, line 1436]
Notice (8): Array to string conversion [CORE\cake\libs\model
\datasources\dbo_source.php, line 1186]



On 11 Фев, 12:33, grigri [EMAIL PROTECTED] wrote:
 try implementing User::paginateCount and changing the query:

 class User extends AppModel {
   function paginateCount($conditions, $recursive) {
 return $this-find('count', array('conditions' = $conditions,
 'recursive' = $recursive, 'fields' = 'COUNT(DISTINCT User.id) AS
 count'));
   }

 }


--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Help needed with filtering by (multiple) a HABTM model(s)

2008-02-10 Thread Nasko

I've been pulling my hair over this puzzle for two days now. I have
this setup (not actual models - these are changed for clarity):

Post belongsTo User
Post hasAndBelongsToMany Category
Post hasAndBelongsToMany Tag

I'm doing a search via a filter form and I need a paginated result
set. I'm familiar with alternative ways of modeling  the Habtm
associations - a) using a dummy habtm model; b) using an implied
(auto) or an explicitly designated 'with' association model - that
could be used to filter by the foreign habtm model, but the problem is
that all articles or discussions in the groups  I've read are dealing
with a single HABTM association on which the filtering is done.

In my case I couldn't paginate or findAll() via the habtm model,
because I have search conditions in other models associated with
'Post' - e.g. I need all posts belonging to a specific user,
associated with a specific category_id and with a specific tag_id.

I'm not posting all the code in my controller/action - just the
relevant statements.

The following works fine:

$filterConditions = array(
'Post.active' = 1,
'Post.user_id' = $user_id,
'CategoryPost.category_id' = $category_id,
'PostTag.tag_id' = $tag_id,
);
$posts = $this-paginate('Post', $filterConditions);

Now, I have two valid requirements which are similar to the above and
which I'm not able to come up with solutions to:

1) I need the Posts associated to either category_id 'X' or
category_id 'Y':

$filterConditions = array(
'Post.active' = 1,
'Post.user_id' = $user_id,
'CategoryPost.category_id' = array($cat1_id, $cat2_id),
'PostTag.tag_id' = $tag_id,
);
$posts = $this-paginate('Post', $filterConditions);

The issue with this scenario is that I'm getting duplicate records if
a Post has been associated with both $cat1_id and $cat2_id. I found
several discussions mentioning a way of passing a $fields array() to
findAll() and specifying 'DISTINCT PrimaryModel.id' in it. Ok, but I
have no way of passing a similar $fields array to
Controller::paginate(). Have I missed anything or is this requirement
not achievable at all without custom queries.

2) To complicate things even further I need to be able to query for
Posts that are associated to both categories $cat1_id AND $cat2_id. I
am not even able to come up with the correct syntax for specifying the
conditions. It just doesn't feel right to use something like:

$filterConditions = array(
'Post.active' = 1,
'Post.user_id' = $user_id,
'CategoryPost.category_id' = $cat1_id,
'CategoryPost.category_id' = $cat2_id,
'PostTag.tag_id' = $tag_id,
);

I'd be extremely thankful for any hints on the right solution to these
issues!

Regards,
Nasko
--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



HABTM filtering with indirect model relationship

2008-02-06 Thread patcoll

I have the following model structure set up:

Model1 -hasOne- Model2 -hasAndBelongsToMany- Model3

I'm trying to run a paginate() call on Model1 (in Model1's controller)
while trying to pass custom conditions having to do with Model3. For
example:

$results = $this-paginate('Model1', array('conditions' =
array('Model3.title' = 'LIKE %blah%')));

Of course it complains that Model3.title doesn't exist because the
query's not doing any join between Model2 and Model3. I've read all
the posts and articles about binding dummy hasOne associations before
doing my paginate call.

OK, so I decided to put the dummy bindModel() in the beforeFind()
function in Model2. Then I did my paginate() call on Model2, but of
course now I'm querying the wrong data because I really need
paginate() support for Model1. Arg.

Has anyone had any success solving this problem? I've seen lots of
solutions for filtering between two models that have a HABTM
relationship and the dummy bindModel() calls seem to work for that,
but this problem seems to be a different animal. Any ideas?
--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Filtering views to show selected data

2007-12-05 Thread Gould, Adrian

When retrieving the information for a User, we get associated models, such as 
loans. 

The view is the Users (for a particulat ID), with hasMany Loans, and Equipment 
hasMany Loans.

How can I filter the loans model to give me only those which have been marked 
as L for on loan.

User (id, name, password)
Loan (id, user_id, equipment_id, on_loan)
Equipment (id, name)

[have missed created / modified off]

Thanks for the help

Ady


---
Adrian Gould
Lecturer in IT / Network Engineering / Multimedia
Business Finance  Computing [Midland Campus]
Swan TAFE
PO BOX 1336, Midland WA 6936

Phone: (08) 9267 
eMail: [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Filtering views to show selected data

2007-12-05 Thread Adam Royle

Use bindModel() to define the conditions. Something like this...

$this-User-bindModel(array('hasMany' = array('Loan' =
array('conditions' = array('on_loan' = 'L');
$users = $this-User-findAll();

Adam

On Dec 6, 1:17 pm, Gould, Adrian [EMAIL PROTECTED]
wrote:
 When retrieving the information for a User, we get associated models, such as 
 loans.

 The view is the Users (for a particulat ID), with hasMany Loans, and 
 Equipment hasMany Loans.

 How can I filter the loans model to give me only those which have been marked 
 as L for on loan.

 User (id, name, password)
 Loan (id, user_id, equipment_id, on_loan)
 Equipment (id, name)

 [have missed created / modified off]

 Thanks for the help

 Ady

 ---
 Adrian Gould
 Lecturer in IT / Network Engineering / Multimedia
 Business Finance  Computing [Midland Campus]
 Swan TAFE
 PO BOX 1336, Midland WA 6936

 Phone: (08) 9267 
 eMail: [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Filtering views to show selected data

2007-12-05 Thread Gould, Adrian

Thanks Adam

will give it a go (well, will forward the answer to the person who needed to 
know).

Adrian



-Original Message-
From: cake-php@googlegroups.com on behalf of Adam Royle
Sent: Thu 12/6/2007 12:46
To: Cake PHP
Subject: Re: Filtering views to show selected data
 

Use bindModel() to define the conditions. Something like this...

$this-User-bindModel(array('hasMany' = array('Loan' =
array('conditions' = array('on_loan' = 'L');
$users = $this-User-findAll();

Adam

On Dec 6, 1:17 pm, Gould, Adrian [EMAIL PROTECTED]
wrote:
 When retrieving the information for a User, we get associated models, such as 
 loans.

 The view is the Users (for a particulat ID), with hasMany Loans, and 
 Equipment hasMany Loans.

 How can I filter the loans model to give me only those which have been marked 
 as L for on loan.

 User (id, name, password)
 Loan (id, user_id, equipment_id, on_loan)
 Equipment (id, name)

 [have missed created / modified off]

 Thanks for the help

 Ady

 ---
 Adrian Gould
 Lecturer in IT / Network Engineering / Multimedia
 Business Finance  Computing [Midland Campus]
 Swan TAFE
 PO BOX 1336, Midland WA 6936

 Phone: (08) 9267 
 eMail: [EMAIL PROTECTED]



--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Filtering using manually entered values

2007-08-12 Thread kabturek

On Aug 10, 6:17 pm, mussond [EMAIL PROTECTED] wrote:
 Hey, thanks for the link :)  but I'm not using 1.2 :(

only named params are 1.2 specific there

 The project I'm evolved with uses 1.1, hence my use of query in the
 1st place.

so there wasn't a findAll in 1.1 ? ;)
It's not an excuse:)

 What do you mean a POST action? using php or is it a cake 1.2 function
 HttpSocket::post?

i mean send a http post  - either by submitting a form to your action
with the values so you can filter by them or use ajax

 Is there a way to show my dates and send them back to the controller
 using 1.1?

see above
 Cheers,

 Dave

 On Aug 10, 2:15 am, kabturek [EMAIL PROTECTED] wrote:

  Do a POST to the action when the users clicks submit in the form or
  do this with ajax if you don't want the whole page to be refreshed

  Also why are you using query ? its only for sql that can't be handled
  by cake and your's looks pretty basic. Generally you're doing a search
  box.
  autopromotionhttp://wiki.kabturek.info/paginating_search_results
  /autopromotion
  not all aplies for you cause you want to do it on the same page but
  look at the code and you'll find some usefull snippets

  greets,

  On Aug 10, 4:57 am, mussond [EMAIL PROTECTED] wrote:

   I'd like to filter my view based on the input from the user.  The
   thought is the user will enter a date range using input text boxes.
   These values would be passed to the controller and an query($sql)
   would return values I'll display in a table.

   I can get the query and the table to work no problem but I can't find
   a way to get the date values from the view to the controller and thus
   be used in the query.

   I've got two text inputs that contain the MIN and MAX date values from
   the database.

   labelstart:/labelINPUT TYPE=text NAME=dateMIN VALUE =?php
   echo $min[0][0]['min'];?/

   labelend:/labelINPUT TYPE=text NAME=dateMAX VALUE =?php echo
   $max[0][0]['max'];?/

   Also the user will filter the query by selecting a user id from a
   select box.  In my controller I set this value to the variable
   $id_user, which is then used in the query():

   $id_user = $this-data['ComUser']['id'];

   $this-set('data', $this-DataPoint-query(SELECT w.com_user_id,
   count(p.id) as c FROM data_points p join des_walks w WHERE
   p.des_walk_id = w.id AND w.com_user_id = '$id_user' AND p.date =
   '2006-12-09' AND p.date = '2006-12-10' GROUP BY w.com_user_id));

   So my question is how can I replace the '2006-12-09' and '2006-12-10'
   with whatever is written in the text boxes?


--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Filtering using manually entered values

2007-08-10 Thread mussond

Hey, thanks for the link :)  but I'm not using 1.2 :(

The project I'm evolved with uses 1.1, hence my use of query in the
1st place.

What do you mean a POST action? using php or is it a cake 1.2 function
HttpSocket::post?

Is there a way to show my dates and send them back to the controller
using 1.1?

Cheers,

Dave

On Aug 10, 2:15 am, kabturek [EMAIL PROTECTED] wrote:
 Do a POST to the action when the users clicks submit in the form or
 do this with ajax if you don't want the whole page to be refreshed

 Also why are you using query ? its only for sql that can't be handled
 by cake and your's looks pretty basic. Generally you're doing a search
 box.
 autopromotionhttp://wiki.kabturek.info/paginating_search_results
 /autopromotion
 not all aplies for you cause you want to do it on the same page but
 look at the code and you'll find some usefull snippets

 greets,

 On Aug 10, 4:57 am, mussond [EMAIL PROTECTED] wrote:

  I'd like to filter my view based on the input from the user.  The
  thought is the user will enter a date range using input text boxes.
  These values would be passed to the controller and an query($sql)
  would return values I'll display in a table.

  I can get the query and the table to work no problem but I can't find
  a way to get the date values from the view to the controller and thus
  be used in the query.

  I've got two text inputs that contain the MIN and MAX date values from
  the database.

  labelstart:/labelINPUT TYPE=text NAME=dateMIN VALUE =?php
  echo $min[0][0]['min'];?/

  labelend:/labelINPUT TYPE=text NAME=dateMAX VALUE =?php echo
  $max[0][0]['max'];?/

  Also the user will filter the query by selecting a user id from a
  select box.  In my controller I set this value to the variable
  $id_user, which is then used in the query():

  $id_user = $this-data['ComUser']['id'];

  $this-set('data', $this-DataPoint-query(SELECT w.com_user_id,
  count(p.id) as c FROM data_points p join des_walks w WHERE
  p.des_walk_id = w.id AND w.com_user_id = '$id_user' AND p.date =
  '2006-12-09' AND p.date = '2006-12-10' GROUP BY w.com_user_id));

  So my question is how can I replace the '2006-12-09' and '2006-12-10'
  with whatever is written in the text boxes?


--~--~-~--~~~---~--~~
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 more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



  1   2   >