Re: Use of $conditions

2007-05-08 Thread NOSLOW

Just wanted to point out a few things I noticed:

- know your parameters: findAll($conditions=null, $fields=null,
$order=null, $limit=null, $page=1, $recursive=null)
- the conditions parameter for functions such as findAll is for, well,
conditions (the "where" clause in SQL)... not sorting. Use the $order
parameter for sorting.
- defining the var $conditions outside the function index definition
as a class property will require you to us it with this syntax: $this-
>conditions.

I guess this is what you were aiming for:

class ProgramsController extends AppController {

var $name = 'Programs';
var $sort = "p_date DESC, p_time ASC";
var $title_for_layout = 'Lake-Sumter Computer Society';
var $helpers = array('Html', 'Form' );

function index() {
$this->Program->recursive = 0;
$this->set('programs', $this->Program->findAll(null,
null, $this->sort));
}

This link should be helpful for you on seeing function parameters:
http://docs.cakephp.nu/classes/show/AppModel

Good luck! Cake rocks!


--~--~-~--~~~---~--~~
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: Use of $conditions

2007-05-06 Thread k4mg

Thanks a lot, worked perfectly.
Barry

On Apr 30, 6:26 pm, rtconner <[EMAIL PROTECTED]> wrote:
> I always thought the docs were a little shady on this. To do what you
> want to do...
>
> $this->Program->findAll(null, null, 'p_date DESC, p_time ASC')
>
> On Apr 30, 3:01 pm, k4mg <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have made a simple (my first!) application using CakePHP and Bake.
> > It works fine, but I am unable to figure out how to add two more
> > capabilities.  I would like to have my List view in order, and
> > paginated so that the headers are always available.  For the first,
> > reading the documentation, it seems I should use $conditions as I did
> > below.  Of course, the list is still in as entered order, not sorted.
> > Any help/examples for this and the pagination would be appreciated.
>
> > class ProgramsController extends AppController {
>
> > var $name = 'Programs';
> > var $conditions = "ORDER BY p_date, p_time";
> > var $title_for_layout = 'Lake-Sumter Computer Society';
> > var $helpers = array('Html', 'Form' );
>
> > function index() {
> > $this->Program->recursive = 0;
> > $this->set('programs', 
> > $this->Program->findAll($conditions));
> > }
> > Barry- Hide quoted text -
>
> - Show quoted text -


--~--~-~--~~~---~--~~
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: Use of $conditions

2007-04-30 Thread rtconner

I always thought the docs were a little shady on this. To do what you
want to do...

$this->Program->findAll(null, null, 'p_date DESC, p_time ASC')

On Apr 30, 3:01 pm, k4mg <[EMAIL PROTECTED]> wrote:
> I have made a simple (my first!) application using CakePHP and Bake.
> It works fine, but I am unable to figure out how to add two more
> capabilities.  I would like to have my List view in order, and
> paginated so that the headers are always available.  For the first,
> reading the documentation, it seems I should use $conditions as I did
> below.  Of course, the list is still in as entered order, not sorted.
> Any help/examples for this and the pagination would be appreciated.
>
> class ProgramsController extends AppController {
>
> var $name = 'Programs';
> var $conditions = "ORDER BY p_date, p_time";
> var $title_for_layout = 'Lake-Sumter Computer Society';
> var $helpers = array('Html', 'Form' );
>
> function index() {
> $this->Program->recursive = 0;
> $this->set('programs', $this->Program->findAll($conditions));
> }
> Barry


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



Use of $conditions

2007-04-30 Thread k4mg

I have made a simple (my first!) application using CakePHP and Bake.
It works fine, but I am unable to figure out how to add two more
capabilities.  I would like to have my List view in order, and
paginated so that the headers are always available.  For the first,
reading the documentation, it seems I should use $conditions as I did
below.  Of course, the list is still in as entered order, not sorted.
Any help/examples for this and the pagination would be appreciated.


class ProgramsController extends AppController {

var $name = 'Programs';
var $conditions = "ORDER BY p_date, p_time";
var $title_for_layout = 'Lake-Sumter Computer Society';
var $helpers = array('Html', 'Form' );

function index() {
$this->Program->recursive = 0;
$this->set('programs', $this->Program->findAll($conditions));
}
Barry


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