It seams I can't get the table from my custom database.

My module should list all data from the database frontend(and backend later) But I get this error

a:5:{i:0;s:93:"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ifp.mage_emailorder' doesn't exist";i:1;s:4318:"#0 /var/www/ifp.dk/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

What I can read on the net. Eather its the database setup, or the block I use to call it out.

Database setup


$installer = $this;
create table emailorder(
    emailorder_id int not null auto_increment, 
    order_date varchar(255) not null,
    product_name varchar(255) not null,
    location varchar(255) not null,
    date_for varchar(255) not null,
    name_title varchar(100) not null,
    email varchar(255) not null,
    company varchar(255) not null,
    adress varchar(255) not null,
    zipcode varchar(255) not null,
    city varchar(255) not null,
    phone varchar(255) not null,
    comment text not null,
    order_done int not null default 0,
    primary key(emailorder_id)




The block


class Puk_EmailOrder_Block_Monblock extends Mage_Core_Block_Template
     public function methodblock()

     $collection = Mage::getModel('emailorder/emailorder')->getCollection()

        foreach($collection as $data)
             $retour .= $data->getData('product_name').' '.$data->getData('location')
                     .' '.$data->getData('date_for').'<br />';

         return $retour;

Can someone help? :)

  • Please update the contents of your config.xml file in question. Can you see the table created in DB directly ?
    – Prateek
    Feb 1, 2016 at 11:56
  • The config.xml file says "emailorder" and in the db it is also "emailorder" Feb 1, 2016 at 12:16

1 Answer 1


You have table prefixes setup in your Magento installation and you created table with SQL as emailorder. When you are calling code Mage::getModel('emailorder/emailorder'), Magento is searching for the table named 'mage_emailorder' because of the prefixes.

Drop your table and re-run the code for setup either via Magento way, or add the prefix so that table name becomes mage_emailorder in your SQL query. As a dirty work-around, you can directly modify the table in DB, just rename it to mage_emailorder.

  • Nice! now i dont get the error. But it still dont write the data from the database. Can you tell me why?? Feb 1, 2016 at 12:39
  • Dont bother, it was a typo. :) Feb 1, 2016 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.