View Single Post
  #1 (permalink)  
Old 04-18-2008, 10:09 AM
madmaxious madmaxious is offline
Junior Member
 
Join Date: Apr 2008
Posts: 7
Default One function for all Actions and Controllers

Hello,

Im sure this is a popular question so I appologise in advance. I can resolve it by creating my own class and then calling that statically in each action and this seems to work OK but I was wondering is there a way to incororate it within the framework.

This is the function I want to run.

PHP Code:
function getPages($section$page)
{
          
$db Zend_Registry::get('db');
       
        try 
        {                                             
            
$sql "SELECT * FROM MainContent WHERE SectionName = '".$section."' AND SubSectionName = '".$page."'";
            
$result $db->fetchAll($sql);
            
$this->view->result $result;
        } 
        catch (
Zend_Exception $e
        {    
            echo 
"Caught exception: " get_class($e) . "<br>";    
            echo 
"Message: " $e->getMessage() . "\n";    
    }

Where do I need to put this and what do I need to extend (if anything) so it is availble for all actions and controllers. Also some advise on how to write and call the custom class and function would be appreciated.

Many thanks in advance.

Madmaxious

Last edited by madmaxious : 04-18-2008 at 10:09 AM. Reason: Canged CODE to PHP
Reply With Quote