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.3k stars 2.74k forks source link

Table names in object.class.php #31056

Open dolibarr95 opened 1 week ago

dolibarr95 commented 1 week 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 2 days 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