On 9/25/06, Stuardo -StR- Rodríguez <[EMAIL PROTECTED]> wrote:


Inside a static method in a Zend_Db_Table object, how should I retrieve the
default DB connection?

public static someAction () {
        $sql ="select something";
        // this option
        $db = self::$_defaultDb;
        // or this option
        $db = self::_getDefaultAdapter();
}

The _getDefaultApdater returns me an error because it is not a static method,

   public static function someAction()
   {
       $sql = '...';
       $table = new self();
       $db = $table->getAdapter();
   }

You could also define a static method for just getting the adapter:

   public static function getDefaultAdapter()
   {
       $table = new self();
       return $table->getAdapter();
   }

   public static function someAction()
   {
       $sql = '...';
       $db  = self::getDefaultAdapter();
   }

--
Matthew Weier O'Phinney
PHP Developer           | [EMAIL PROTECTED]
Zend Technologies       | http://www.zend.com/

Reply via email to