posted 03/7/2008 by Chris

For such an important function, there seem to be very few examples out there...

 

$search_where = array('category'=>'misc');

$return_these_db_columns = 'id,title,content,publish_date';

$order_by = 'publish_date DESC';

$show_this_page = 2; //this is only static for testing - would be dynamic for pagination

$show_this_many_per_page = 15; //number of blog posts to show per page

/*

* only Blogs with thier "category" column matching "misc" are returned

* this will return an array of Blog objects with variables id, title, content, and publish_date

* the array will be ordered by publish_date from biggest to smallest

* only results 16-30 from the database will be returned

*/

$blogs =

$this->Blog->findAll(

    $search_where,

    $return_these_database_columns,

    $order_by,

    $show_this_many_per_page,

    $show_this_page

);

Tags: findall / cakephp / code
Share:
facebook myspace digg del.icio.us fark stumbleupon live spurl furl reddit yahoo

COMMENTS (displaying 0 comments)

POST (leave a comment)

Name:
Email:
Message:
Verify:
CAPTCHA Image