Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.43k stars 2.78k forks source link

Table names in object.class.php #31056

Open dolibarr95 opened 1 month ago

dolibarr95 commented 1 month ago

Feature Request

Hello

Just a question or a misunderstanding : Why in object classes we declare the name of the table. For example:

/**
 * @var string Name of table without prefix where object is stored
 */
public $table_element = 'commande';

But in the queries we write the name of the table

$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1';
$sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > '.self::STATUS_DRAFT;

and not:

$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element .' SET facture = 1';
$sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > '.self::STATUS_DRAFT;

Tks for reading.

Use case

No response

Suggested implementation

No response

Suggested steps

No response

zephyriony commented 1 month ago

Probably because it was done after the fact, or because the developer wasn't aware that this property existed, you can make a pull request. In my opinion, you should actually do this