Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6042519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:47:58+00:00 2026-05-23T06:47:58+00:00

I created my own library with path: library/Mylib . I have a class in

  • 0

I created my own library with path: library/Mylib. I have a class in library/Mylib/ named Acl.php :

    class Mylib_Acl extends Zend_Acl{
        public $_db;

        public function init(){
            $this->_db = new Zend_Db_Adapter_Pdo_Mysql(
                array(
                    'host' => 'localhost',
                    'username' => 'username',
                    'password' => 'password',
                    'dbname' => 'mydb'
                )
            );
            Zend_Db_Table_Abstract::setDefaultAdapter($this->_db);
        }

public function __construct(){
        self::initRole();

    }

        public function initRole(){
            Zend_Debug::dump($this->_db);
            Zend_Debug::dump(Zend_Registry::get('db'));
            die;
            $sql = 'SELECT * FROM some_table';
                $result = $this->_db->query($sql)->fetchAll();

        }

Zend_Debug::dump($this->_db) give me : NULL

Zend_Debug::dump(Zend_Registry::get('db')) give me this error :

Fatal error: Uncaught exception 'Zend_Exception' with message 'No entry is registered for key 'db'' in /home/truong/public_html/test2/library/Zend/Registry.php:147 Stack trace: #0 /home/truong/public_html/test2/library/Fxml/Acl.php(19): Zend_Registry::get('db') #1 /home/truong/public_html/test2/library/Fxml/Acl.php(62): Fxml_Acl->initRole() #2 /home/truong/public_html/test2/application/Bootstrap.php(25): Fxml_Acl->__construct() #3 /home/truong/public_html/test2/library/Zend/Application/Bootstrap/BootstrapAbstract.php(666): Bootstrap->_initAutoload() #4 /home/truong/public_html/test2/library/Zend/Application/Bootstrap/BootstrapAbstract.php(619): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('autoload') #5 /home/truong/public_html/test2/library/Zend/Application/Bootstrap/BootstrapAbstract.php(583): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL) #6 /home/truong/public_html/test2/library/Zend/Application.php(355): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap(NULL) #7 /home/truong/pu in /home/truong/public_html/test2/library/Zend/Registry.php on line 147

I did register ‘db’ key in my application/Bootstrap.php :

public function _initDb(){
         $db = new Zend_Db_Adapter_Pdo_Mysql(
            array(
                'host' => 'localhost',
                'username' => 'username',
                'password' => 'password',
                'dbname' => 'mydb'
            )
        );
        Zend_Db_Table_Abstract::setDefaultAdapter($db);

        Zend_Registry::set('db', $db);
    }

And I did have : autoloaderNamespaces.Mylib = "Mylib_" in application.ini

What did I wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:47:58+00:00Added an answer on May 23, 2026 at 6:47 am

    There are a few issues here:

    • The init() method in your Acl class is never called (at least not in your example)
    • The init() method is creating another database connection – best to reuse the one you created in the bootstrap
    • You are calling initRole() statically when it is not a static method

    You’ve not included the part of your app where you call the Acl class, which may be the cause of the error. E.g. if you were instantiating the class in your bootstrap before the database resource was setup, this would explain the error you are seeing.

    You could greatly simplify your class by changing it to something like this:

    class Mylib_Acl extends Zend_Acl{
        public $_db;
    
        public function __construct(){
            $this->init();
            $this->initRole();
        }
    
        public function init(){
            $this->_db = Zend_Registry::get('db');
        }
    
        [etc.]
    }
    

    as long as the _initDb() method in the bootstrap is run before you use the Acl class this should then be fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created my own Attached Property like this: public static class LabelExtension {
I created my own behavior as follows: public class BoundaryExceptionHandlingBehavior : IInterceptionBehavior { public
I have a - maybe very simple - problem: I created my own library
I'm using Zend, a PHP library, to work with Amazon EC2. I have created
I created my own class but when I try to instantiate it I run
I've created my own signup form and creating the user using the Membership class.
I have created my own customized lots of architecture including n-tier layers for different
I have created my own debugger application. It attaches to a process and creates
i just created my own library on this folder (application/library) and following all steps
I have a C# .NET class library which I have exposed in COM by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.