Language and development rules: Difference between revisions

Jump to navigation Jump to search
Line 235: Line 235:
Only Mysql SQL files must be maintained.
Only Mysql SQL files must be maintained.
Those files are converted "on the fly" by the database Dolibarr driver.
Those files are converted "on the fly" by the database Dolibarr driver.
There is an exception
The SQL "UPDATE FROM" :
Syntax MySQL :
<source lang="sql">
UPDATE table_taget as target, table_source as source SET fieldtarget=source.fieldsource
WHERE source.rowid=target.rowid;
</source>
Syntax PgSQL:
<source lang="sql">
UPDATE table_taget as target SET fieldtarget=source.fieldsource
FROM table_source as source WHERE source.rowid=target.rowid;
</source>
There is no native SQL request "update from" in dolibarr core. But in your module you should do :
<source lang="php">
if ($this->db->type=='pgsql') {
$sql="UPDATE table_taget as target SET fieldtarget=source.fieldsource
FROM table_source as source WHERE source.rowid=target.rowid";
} else {
$sql= "UPDATE table_taget as target, table_source as source SET fieldtarget=source.fieldsource
WHERE source.rowid=target.rowid";
}
</source>


= HTML norms =
= HTML norms =
Bureaucrats, emailconfirmed, Administrators
825

edits

Navigation menu