Jump to content
Orthofoods

[RESOLU] Installation Module : Création table

Recommended Posts

Bonjour,

J'essaie de développer un module pour le back-office. Même s'il n'est pas destiné à être diffusé, je voudrais l'écrire selon les règles.

Je voudrais donc créer les tables dont j'ai besoin depuis la fonction install : voici le code :

<?php
/**
 * 2007-2019 PrestaShop SA and Contributors
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/AFL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <contact@prestashop.com>
 * @copyright 2007-2019 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/AFL-3.0  Academic Free License (AFL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 */

if (!defined('_PS_VERSION_'))
{
    exit;
}

class prescript extends Module
{

    public function __construct()
    {

        $this->name = 'prescript';
        $this->tab = 'AdminParentOrders';
        $this->author = 'Philippe';
        $this->version = '.0.1.0';
        $this->need_instance = 0;
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('Prescripteurs');
        $this->description = $this->l('Gestion des prescripteurs');
        $this->confirmUninstall = $this->l('Are you sure you want to uninstall my module?');

        $this->ps_versions_compliancy = array('min' => '1.7.1', 'max' => _PS_VERSION_);


    }


    /**
     * Installation du module
     * @return boolean
     */
    public function install()
    {

        return parent::install() && $this->installTables();
    }


   public function installTables()
    {
        /*
        * ajout de la table Catégories
        */
        $tableprsgroup = 'CREATE TABLE `'._DB_PREFIX_.'`prs_group` (`id_prs_group` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `medecin` TINYINT NOT NULL DEFAULT 0 )';

        try {
            Db::getInstance()->execute($tableprsgroup);
        } catch (Exception $e) {
            echo 'exception reçue :', $e->getMessage(), "/n";
        }

    }


}

Je n'ai pas d'erreur d'execution, je n'ai pas d'exception, ma requete de création fonctionne dans phpMyAdmin et pourtant la table n'est pas créée.

Quelqu'un pourrait il me dire ce que j'ai oublié dans le code ?

Merci d'avance.

Share this post


Link to post
Share on other sites

J'ai fini par trouver. Il a fallu que je coche GRANT dans les parametres de l'utilisateur de la BDD dans phpMyAdmin.

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More