Jump to content

[solved] inserting new table in a module install function


banditbirds

Recommended Posts

Hi guys!

 

I am trying to create a table in my prestashop database using the install function of a module.

 

It creates the table, but not the fields.

 

Could anyone give us any advice on what I'm doing wrong??

 

Many thanks in advance!!

 

Simon

public function install()
   {
    if (Shop::isFeatureActive())
     Shop::setContext(Shop::CONTEXT_ALL);
    
$sql = "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."custom_order`(
`id_custom_order` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`request_details` VARCHAR(256) )";

   if(!$result=Db::getInstance()->Execute($sql))
   return false;

    return parent::install() &&
     $this->registerHook('leftColumn') &&
     $this->registerHook('header') &&
     Configuration::updateValue('MYMODULE_NAME', 'my friend');

   }

 

Edited by banditbirds (see edit history)
Link to comment
Share on other sites

hi,

 

database creation.

 

The module installs fine. And the table ps_custom_order is created ok in my database.

 

But there are no columns/fields = id_custom_order, request_details (pic attached).

 

 

Maybe these only appear when I input data in the fields??

post-770181-0-65746800-1396602268_thumb.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...