2

I will like a module that create a database, and i got it to work with this code

<?php
$installer = $this;
$installer->startSetup();
$sql=<<<SQLTEXT
create table emailorder(emailorders_id int not null auto_increment, name varchar(100), primary key(emailorder_id));
    insert into emailorder values(1,'emailorder1');
    insert into emailorder values(2,'emailorder2');

SQLTEXT;

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

Then i wanted more cells in my table so i deleted it and tried this code

<?php
$installer = $this;
$installer->startSetup();
$sql=<<<SQLTEXT
create table emailorders(
    emailorders_id int not null auto_increment, 
    primary key(emailorders_id),
    order_date datetime NOT NULL,
    location varchar NOT NULL,
    date_for varchar NOT NULL,
    name_title varchar(100) NOT NULL,
    email varchar NOT NULL,
    company varchar NOT NULL,
    address varchar NOT NULL,
    zipcode varchar NOT NULL,
    city varchar NOT NULL,
    phone varchar NOT NULL,
    comment text NOT NULL default,
    order_executed boolean NOT NULL default



);
    insert into emailorders values(1,'emailorders1');
    insert into emailorders values(2,'emailorders2');

SQLTEXT;

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

It does not work and now the first code don't work either :(

What am i doing wrong?

2

For run the same installer file,you need to delete it's setup record from core_resource Table

Magento save,every module's installer version at database ,so you need to resolved this record.

Else create an installer upgrade script file .

See details at

http://inchoo.net/magento/magento-install-install-upgrade-data-and-data-upgrade-scripts/

How to use setup scripts for your module?

  • How do i delete the setup record? – Patrick Knudsen Jan 28 '16 at 8:31
  • Can u please show config.xml code of Ur module – Amit Bera Jan 28 '16 at 8:41
  • If i go ind and delete the setup from core_resource i can make the database table THANKS! – Patrick Knudsen Jan 28 '16 at 8:45

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.