dolibarr-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dolibarr-dev] SQL comment in SQL module dev / Int égration des commenta


From: Florian HENRY
Subject: [Dolibarr-dev] SQL comment in SQL module dev / Int égration des commentaires SQL dans le dev des mos ules
Date: Thu, 9 Jun 2011 11:35:07 -0400

Bonjour,

J'ai pu remarquer que dans le developement d'un nouveau module, et que l'on a besion de crée des tables, il n'est pas possible de faire fichier de cette forme :

create table llx_table
(
  rowid             integer AUTO_INCREMENT PRIMARY KEY,
  label          varchar(128) NOT NULL,  -- comment 1

  datec          datetime,             -- comment 2
  tms            timestamp,            -- comment 3
  fk_user_author integer,              -- comment 4
 }

les commentaires sont intégré dans le buffer d'execution et il sont refuser.

Je propose d'intégré cette modification dans htdocs/lib/admin.lib.php

Dans le function run_sql juste aprés le test qui valide que la ligne ne commence pas par un commentaire :

// Add line buf to buffer if not a comment
            if (! preg_match('/^--/',$buf))
            {
                //remove comment from a line that not start with --    before add it to the buffer
                 if (preg_match('/--/',$buf))
                {
                    $buf = substr($buf,0,strpos($buf, '-'));
                }

                $buffer .= trim($buf);
            }

Dites moi ce que vous en pensez ?

Cordialement

Henry Florian

----------------------------

Hello

I notice during the new module devloepement and if we need to create table, it's not possible to write the SQL file like that

create table llx_table
(
  rowid             integer AUTO_INCREMENT PRIMARY KEY,
  label          varchar(128) NOT NULL,  -- comment 1

  datec          datetime,             -- comment 2
  tms            timestamp,            -- comment 3
  fk_user_author integer,              -- comment 4
 }

Comment at the end of the line are integrated into the execution buffer and they are interpreted as invalid instructions

I suggest a modification in htdocs/lib/admin.lib.php

In function run_sql juste just after the test "Add line buf to buffer if not a comment" :

// Add line buf to buffer if not a comment
            if (! preg_match('/^--/',$buf))
            {
                //remove comment from a line that not start with --    before add it to the buffer
                 if (preg_match('/--/',$buf))
                {
                    $buf = substr($buf,0,strpos($buf, '-'));
                }
                $buffer .= trim($buf);
            }
What do you think about ?

Kind regards

Henry Florian


reply via email to

[Prev in Thread] Current Thread [Next in Thread]