public static function fetch($section_id = null, $order = 'ASC', $sortfield = 'name')
    {
        $returnSingle = false;
        $section_ids = array();

        if (!is_null($section_id)) {
            if (!is_array($section_id)) {
                $returnSingle = true;
                $section_ids = array($section_id);
            } else {
                $section_ids = $section_id;
            }
        }

        if ($returnSingle && isset(self::$_pool[$section_id])) {
            return self::$_pool[$section_id];
        }

        // Ensure they are always an ID
        $section_ids = array_map('intval', $section_ids);
        $sql = sprintf(
            "SELECT `s`.*
            FROM `tbl_sections` AS `s`
            %s
            %s",
            !empty($section_id) ? " WHERE `s`.`id` IN (" . implode(',', $section_ids) . ") " : "",
            empty($section_id) ? " ORDER BY `s`.`$sortfield` $order" : ""
        );

        if (!$sections = Symphony::Database()->fetch($sql)) {
            return ($returnSingle ? false : array());
        }

        $ret = array();

        foreach ($sections as $s) {
            $obj = self::create();

            foreach ($s as $name => $value) {
                $obj->set($name, $value);
            }

            $obj->set('creation_date', DateTimeObj::get('c', $obj->get('creation_date')));

            $modDate = $obj->get('modification_date');
            if (!empty($modDate)) {
                $obj->set('modification_date', DateTimeObj::get('c', $obj->get('modification_date')));
            } else {
                $obj->set('modification_date', $obj->get('creation_date'));
            }

            self::$_pool[$obj->get('id')] = $obj;

            $ret[] = $obj;
        }

        return (count($ret) == 1 && $returnSingle ? $ret[0] : $ret);
    }
public static function fetch($section_id = null, $order = 'ASC', $sortfield = 'name')
    {
        $returnSingle = false;
        $section_ids = array();

        if (!is_null($section_id)) {
            if (!is_array($section_id)) {
                $returnSingle = true;
                $section_ids = array($section_id);
            } else {
                $section_ids = $section_id;
            }
        }

        if ($returnSingle && isset(self::$_pool[$section_id])) {
            return self::$_pool[$section_id];
        }

        // Ensure they are always an ID
        $section_ids = array_map('intval', $section_ids);
        $sql = sprintf(
            "SELECT `s`.*
            FROM `tbl_sections` AS `s`
            %s
            %s",
            !empty($section_id) ? " WHERE `s`.`id` IN (" . implode(',', $section_ids) . ") " : "",
            empty($section_id) ? " ORDER BY `s`.`$sortfield` $order" : ""
        );

        if (!$sections = Symphony::Database()->fetch($sql)) {
            return ($returnSingle ? false : array());
        }

        $ret = array();

        foreach ($sections as $s) {
            $obj = self::create();

            foreach ($s as $name => $value) {
                $obj->set($name, $value);
            }

            $obj->set('creation_date', DateTimeObj::get('c', $obj->get('creation_date')));

            $modDate = $obj->get('modification_date');
            if (!empty($modDate)) {
                $obj->set('modification_date', DateTimeObj::get('c', $obj->get('modification_date')));
            } else {
                $obj->set('modification_date', $obj->get('creation_date'));
            }

            self::$_pool[$obj->get('id')] = $obj;

            $ret[] = $obj;
        }

        return (count($ret) == 1 && $returnSingle ? $ret[0] : $ret);
    }
public static function fetch ( $ section_id = null , $ order = 'ASC' , $ sortfield = 'name' ) { $ returnSingle = false ; $ section_ids = array ( ) ; if ( ! is_null ( $ section_id ) ) { if ( ! is_array ( $ section_id ) ) { $ returnSingle = true ; $ section_ids = array ( $ section_id ) ; } else { $ section_ids = $ section_id ; } } if ( $ returnSingle && isset ( self :: $ _pool [ $ section_id ] ) ) { return self :: $ _pool [ $ section_id ] ; } // Ensure they are always an ID $ section_ids = array_map ( 'intval' , $ section_ids ) ; $ sql = sprintf ( "SELECT `s`.*
            FROM `tbl_sections` AS `s`
            %s
            %s" , ! empty ( $ section_id ) ? " WHERE `s`.`id` IN (" . implode ( ',' , $ section_ids ) . ") " : "" , empty ( $ section_id ) ? " ORDER BY `s`.`$sortfield` $order" : "" ) ; if ( ! $ sections = Symphony :: Database ( ) -> fetch ( $ sql ) ) { return ( $ returnSingle ? false : array ( ) ) ; } $ ret = array ( ) ; foreach ( $ sections as $ s ) { $ obj = self :: create ( ) ; foreach ( $ s as $ name => $ value ) { $ obj -> set ( $ name , $ value ) ; } $ obj -> set ( 'creation_date' , DateTimeObj :: get ( 'c' , $ obj -> get ( 'creation_date' ) ) ) ; $ modDate = $ obj -> get ( 'modification_date' ) ; if ( ! empty ( $ modDate ) ) { $ obj -> set ( 'modification_date' , DateTimeObj :: get ( 'c' , $ obj -> get ( 'modification_date' ) ) ) ; } else { $ obj -> set ( 'modification_date' , $ obj -> get ( 'creation_date' ) ) ; } self :: $ _pool [ $ obj -> get ( 'id' ) ] = $ obj ; $ ret [ ] = $ obj ; } return ( count ( $ ret ) == 1 && $ returnSingle ? $ ret [ 0 ] : $ ret ) ; }
Returns a Section object by ID, or returns an array of Sections
if the Section ID was omitted. If the Section ID is omitted, it is
possible to sort the Sections by providing a sort order and sort
field. By default, Sections will be order in ascending order by
their name

@param integer|array $section_id
The ID of the section to return, or an array of ID's. Defaults to null
@param string $order
If `$section_id` is omitted, this is the sortorder of the returned
objects. Defaults to ASC, other options id DESC
@param string $sortfield
The name of the column in the `tbl_sections` table to sort
on. Defaults to name
@throws DatabaseException
@return Section|array
A Section object or an array of Section objects
Returns a Section object by ID or returns an array of Sections if the Section ID was omitted . If the Section ID is omitted it is possible to sort the Sections by providing a sort order and sort field . By default Sections will be order in ascending order by their name