1

When i try to call out my block with data from my custom database, i get an error

a:5:{i:0;s:229:"Error in file: "/var/www/ifp.dk/public_html/app/code/local/Puk/EmailOrder/sql/emailorder_setup/mysql4-install-0.1.0.php" - SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'emailorders_id' doesn't exist in table";i:1;s:972:"#0 /var/www/ifp.dk/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')

I have just change my database from 'emailorders' to 'emailorder' but nowhere is the menthed emailorders_id eny more.

Here is the Installfile it says there a error in

<?php
$installer = $this;
$installer->startSetup();
$sql=<<<SQLTEXT
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)

);


SQLTEXT;

$installer->run($sql);
//demo 
//Mage::getModel('core/url_rewrite')->setId(null);
//demo 
$installer->endSetup();
4

The primary key might be missing/wrong at resource Model. Check once in /var/www/ifp.dk/public_html/app/code/local/Puk/EmailOrder/Model/Resources/EmailOrder.php (or something like file). In constructor it should be ** emailorder_id** instead of emailorders_id

protected function _construct()
{
    $this->_init('puk_emailorder/emailorder', 'emailorder_id');
}
  • my constructor is like yours. in here app/code/local/Puk/EmailOrder/Model/Mysql4 <?php class Puk_EmailOrder_Model_Mysql4_EmailOrder extends Mage_Core_Model_Mysql4_Abstract { public function _construct() { $this->_init('emailorder/emailorder', 'emailorder_id'); } } – Patrick Knudsen Feb 1 '16 at 10:25
  • None of the 3 files i have in model folder have emailorders_id. What can it be then? – Patrick Knudsen Feb 1 '16 at 10:40
  • can you please flush the cache? check if compilation is on. Also can you please write the name of your above sql file? – Prakash Thapa Feb 1 '16 at 10:42
  • Cache is flushed, and the compliation is off. the sql file is located here app/code/local/Puk/EmailOrder/sql/emailorder_setup/mysql4-install-0.1.0.php – Patrick Knudsen Feb 1 '16 at 10:52
  • apparently the cahce was extra brutal this time. Have to manuel delete cahce. – Patrick Knudsen Feb 1 '16 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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