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 8156251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:53:35+00:00 2026-06-06T16:53:35+00:00

I am trying to store a db connection from a crontoller and trying to

  • 0

I am trying to store a db connection from a crontoller and trying to use it in a different mapper class using zend registry. I cannot figure out how and I am running into problems.

indexcontroller.php

public function indexAction()
{
    // action body


    $request = $this->getRequest();
    $form    = new Application_Form_Project();

    if ($this->getRequest()->isPost()) {
        if ($form->isValid($request->getPost())) {
            $x = $form->getValues();                
            //return $this->_helper->redirector('index');
            $dbAdapter = Zend_Db::factory("pdo_sqlite", array("dbname"=>"/../data/db/".$x["username"].".db"));
            Zend_Db_Table::setDefaultAdapter($dbAdapter);

            //print_r($dbAdapter);
            Zend_Registry::set('index', $dbAdapter);

            $this->_redirect('/line');


        }
    }

    $this->view->form = $form;

}

PgeLine2DMapper.php

<?php

class Application_Model_PgeLine2DMapper
{
protected $_dbTable;

public function setDbTable($dbTable)
{
    $multidb = Zend_Registry::get("multidb");


    $registry = Zend_Registry::getInstance();
    //print_r($registry);

    /*
    try {
        //$db = Zend_Db::factory('Pdo_sqlite', $registry['multidb']);
        //$db->getConnection();

        //Zend_Db::factory("pdo_sqlite", array("dbname"=>"/../data/db/".$x["username"].".db"));
    } catch (Zend_Db_Adapter_Exception $e) {
        // perhaps a failed login credential, or perhaps the RDBMS is not running
    } catch (Zend_Exception $e) {
        // perhaps factory() failed to load the specified Adapter class
    }
    */

    foreach ($registry as $index => $value) {
        echo "Registry index $index contains: ";
        //var_dump($value);
        echo  "<br>";
    }

    if (is_string($dbTable)) {
        $dbTable = new $dbTable();
    }
    if (!$dbTable instanceof Zend_Db_Table_Abstract) {
        throw new Exception('Invalid table data gateway provided');
    }
    $this->_dbTable = $dbTable;
    return $this;
}

public function getDbTable()
{
    if (null === $this->_dbTable) {
        $this->setDbTable('Application_Model_DbTable_PgeLine2D');
    }
    return $this->_dbTable;
}

public function save(Application_Model_PgeLine2D $pgeLine2D)
{
    $data = array(
            'PGA_Name'   => $pgeLine2D->getPGA_Name()
    );

    if( null === ($id = $pgeLine2D->getPGA_Id()) ) {
        unset($data['id']);
        $this->getDbTable()->insert($data);
    } else {
        $this->getDbTable()->update($data, array('PGA_Id = ?' => $id));
    }
}

public function find($id, Application_Model_PgeLine2D $pgeLine2D)
{
    $result = $this->getDbTable()->find($id);
    if (0 == count($result)) {
        return;
    }
    $row = $result->current();
    $pgeLine2D->setPGA_Id($row->PGA_Id)
        ->setPGA_Name($row->PGA_Name);
}

public function fetchAll()
{
    $registry = Zend_Registry::getInstance();
    $resultSet = $registry['index']->getDbTable()->fetchAll();
    $entries   = array();
    foreach ($resultSet as $row) {
        $entry = new Application_Model_PgeLine2D();
        $entry->setPGA_Id($row->PGA_Id)
            ->setPGA_Name($row->PGA_Name);
        $entries[] = $entry;
    }
    return $entries;
}

}

error message

Fatal error: Call to undefined method Zend_Application_Resource_Multidb::getDbTable() in /opt/eposdatatransfer/application/models/PgeLine2DMapper.php on line 80 
  • 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-06-06T16:53:37+00:00Added an answer on June 6, 2026 at 4:53 pm
    $resultSet = $registry['index']->getDbTable()->fetchAll();
    

    is this line 80 of /opt/eposdatatransfer/application/models/PgeLine2DMapper.php?

    I guess it should be:

    $resultSet = $this->getDbTable()->fetchAll();
    

    Application_Model_PgeLine2DMapper is used in the line controller?

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

Sidebar

Related Questions

I'm trying to store an image into an SQL database without using temporary files.
I'm trying to store BitmapData from a MovieClip that is a PNG with transparency.
I have discovered an issue when trying to store a lot of keys using
I am simply trying to call a store procedure (SQL Server 2008) using C#
I am trying to download file using FTP, and in between if connection terminates
I'm trying to store three images from a form (PictureBox's) into a SQL Database
I am currently trying to use JavaMail to get emails from IMAP servers (Gmail
I am trying to use ParallelCurl with a callback when cURL receives data from
I'm trying to select some fields from my database and store them as a
I am trying to download an HTML file from the internet and store it

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.