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

  • Home
  • SEARCH
  • 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 7564157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:50:45+00:00 2026-05-30T13:50:45+00:00

I am running php 5.2.12 and Zend Framework 5.0.2 In my Bootstrap.php, I initialize

  • 0

I am running php 5.2.12 and Zend Framework 5.0.2

In my Bootstrap.php, I initialize our database connection, and initialize our logger… placing both in the registry.

However, when I try to log info in the IndexController.php, it gives the following message:
“*Fatal error: Call to undefined method Zend_Config::insert() in /usr/local/zendsvr/share/ZendFramework/library/Zend/Log/Writer/Db.php on line 137*”

At the bottom of this post, you will find the Zend Framework’s class file, db.php , and the _write function being called.

I believe the problem is that I am getting the database connection options from my application.ini… and there is no insert() function defined in my application.ini for the database. But I dont really know how to add one to the config, or how I should be doing this.

Bootstrap.php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

    protected function _initConfig()
    {
        Zend_Registry::set('config', new Zend_Config($this->getOptions()));
    }

    protected function _initDatabases()
    {    
        $this->bootstrap('multidb');
        $resource = $this->getPluginResource('multidb');

        $databases = Zend_Registry::get('config')->resources->multidb;

        foreach ($databases as $name => $adapter)
        {
            $db_adapter = $resource->getDb($name);

            Zend_Registry::set($name, $db_adapter);
        }

    }

    protected function _initLog()
    {
        $db             = Zend_Registry::get('config')->resources->multidb->as400;

        $columnMapping  = array('ILGID'     => 'id',        //1 numeric
                                'ILGLVL'    => 'priority',  //2 numeric
                                'ILGDTE'    => 'date',      //yymmdd
                                'ILGTME'    => 'time',      //hhmmss
                                'ILGPGM'    => 'program',   //40 alnum
                                'ILGURL'    => 'url',       //2100
                                'ILGUSR'    => 'user',      //30
                                'ILGMSG'    => 'message');  //1000

        $writer         = new Zend_Log_Writer_Db($db, 'dwhlib.intralog', $columnMapping);
        $logger         = new Zend_Log($writer);


        $date = new Zend_Date();
        date_default_timezone_set('America/Chicago');


        $logger->setEventItem('id'      , 1);
        $logger->setEventItem('date'    , $date->get('Ymd'));
        $logger->setEventItem('time'    , $date->get('Hms'));
        $logger->setEventItem('program' , 'testProgramName');                   $logger->setEventItem('url'     , $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
        $logger->setEventItem('user'    , gethostbyaddr($_SERVER['REMOTE_ADDR']));


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

}

application.ini

resources.multidb.as400.adapter = "db2"
resources.multidb.as400.host = "i5"
resources.multidb.as400.username = "removedUsername"
resources.multidb.as400.password = "removedPassword"
resources.multidb.as400.dbname = "*LOCAL"
resources.multidb.as400.default = true

IndexController.php

include("/www/zendserver/htdocs/development/application/models/as400.php");
class IndexController extends Zend_Controller_Action
{
    public function init()
    {       
        Zend_Registry::get('logger')->info("this is a test message");
    }

    public function indexAction()
    {
        // action body
    }
}

as400.php

Class default_Model_As400 extends Zend_Db {


    public static function ExecuteSelect($sql, $mode = Zend_Db::FETCH_ASSOC, $log = false)
    {
        $stmt = self::getStmt($sql);
        $stmt->setFetchMode($mode);
        $stmt->execute();

        if($log === true) {
            Zend_Registry::get('logger')->info($sql);
        }

        $rows = $stmt->fetchAll();

        return $rows;
    }

    private static function getStmt($sql){
        $db = Zend_Registry::get('config')->resources->multidb->as400;

        $abstractAdapter = new Zend_Db_Adapter_Db2($db);

        return new Zend_Db_Statement_DB2($abstractAdapter, $sql);
    }

    public function insert($libAndFile, $arrData){
        echo "this was hit!!";
    }
}

db.php

class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
{
    public function __construct($db, $table, $columnMap = null)
        {
            $this->_db    = $db;
            $this->_table = $table;
            $this->_columnMap = $columnMap;
        }


    protected function _write($event)
    {
        if ($this->_db === null) {
            require_once 'Zend/Log/Exception.php';
            throw new Zend_Log_Exception('Database adapter is null');
        }

        if ($this->_columnMap === null) {
            $dataToInsert = $event;
        } else {
            $dataToInsert = array();
            foreach ($this->_columnMap as $columnName => $fieldKey) {
                $dataToInsert[$columnName] = $event[$fieldKey];
            }
        }

        $this->_db->insert($this->_table, $dataToInsert);
    }
}
  • 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-30T13:50:47+00:00Added an answer on May 30, 2026 at 1:50 pm
    • What is happening: you are calling a method called insert() on a Zend_Config instance.
    • What you want: call a method insert() through a Zend_Db_Adapter.

    There is something wrong in your _initLog() bootstrap method:

    $db = Zend_Registry::get('config')->resources->multidb->as400;
    $writer = new Zend_Log_Writer_Db($db, 'dwhlib.intralog', $columnMapping);
    

    Zend_Log_Writer_Db expects a Zend_Db adapter as a first constructor parameter. To fix this, since you already registered your database adapter in the registry, you should do something like this :

    $dbName = Zend_Registry::get('config')->resources->multidb->as400;
    $db = Zend_Registry::get($dbName);
    $writer = new Zend_Log_Writer_Db($db, 'dwhlib.intralog', $columnMapping);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are running a PHP (zend framework) app that creates a database per user
Background, I'm running a Zend Framework application. Trying to squeeze the most performance out
I've just installed Zend Framework and am running through a tutorial, but have hit
I am trying to get Zend Framework's quickstart tutorial up and running, but i
I want to upload an image in Zend-framework. In Application_Form_Test.php I write following code....
I would like to print PHP, Apache and Zend server version by running a
I have a website running using Zend Framework and am trying to setup Zend
I was following example 2 in Running a Zend Framework action from command line
I am trying to store custom routes for the Zend Framework inside the database.
Running PHP under IIS on my Win XP Pro system. I cannot debug my

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.