findAll

Navigation:  Development > Function Reference > Model >

findAll

Previous pageReturn to chapter overviewNext page

This function fetch a multiple row from a table. See below format
 

App::Model(MODEL)->findAll(CONDITION);
 

We can pass condition of WHERE clause as parameter of the function.

 

For example: 
$list = App::Model('Page')->findAll("id=1"); 
$list = App::Model('Page')->findAll("1 ORDER BY id ASC"); 
 
// Return value 
/*Array

(

    [data] => Array

        (

            [0] => Array

                (

                    [id] => 1

                    [fkey] => 0

                    [page_title] => About appRain:  PHP Content  Management Framework | Content Management System | 

                    [meta_keywords] => About Content Management System, PHP Framework

                    [meta_description] => A PHP Content Management Framework

                    [name] => aboutus

                    [title] => About Us

                    [content] => appRain is one of the first officially released Open Source Content Management Framework (CMF).

                    [hook] => sitemenu,quicklinks

                    [userdefinehook] => 

                    [richtexteditor] => Yes

                    [rendertype] => smart_h_link

                    [contenttype] => Content

                )

 

            [1] => Array

                (

                    [id] => 2

                    [fkey] => 0

                    [page_title] => Terms of Use: appRain Content Management Framework

                    [meta_keywords] => Terms, Condition, Copy Right

                    [meta_description] => 

                    [name] => terms-of-use

                    [title] => Terms of Use

                    [content] => Copyright (c) appRain CMF (http://www.apprain.com)

                    [hook] => quicklinks,template_footer_B

                    [userdefinehook] => 

                    [richtexteditor] => Yes

                    [rendertype] => smart_h_link

                    [contenttype] => Content

                )

        )

)

*/

 

Note: In present appRain version 3.1.0 and 3.1.2 by default this function return all data in a single but we can customize it to fetch value of particular column. 
 
$list = App::Model('Page')->findAll("1 ORDER BY id ASC",NULL,"id,name"); // Return id and name of each row