Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow use of prepared SQL statements in {{#get_db_data:}}
Allow use of prepared SQL statements in {{#get_db_data:}} for ODBC connections and mySQL. Define prepared SQL statements in LocalSettings.php per database connection. Examples: One statement per connection: In LocalSettings.php: $edgDBServer ['rfam'] = 'mysql-rfam-public.ebi.ac.uk:4497'; $edgDBServerType['rfam'] = 'mysql'; $edgDBName ['rfam'] = 'Rfam'; $edgDBUser ['rfam'] = 'rfamro'; $edgDBPass ['rfam'] = ''; $edgDBPrepared ['rfam'] = <<<'SQL' SELECT fr.rfam_acc, fr.rfamseq_acc, fr.seq_start, fr.seq_end FROM full_region fr, rfamseq rf, taxonomy tx WHERE rf.ncbi_id = tx.ncbi_id AND fr.rfamseq_acc = rf.rfamseq_acc AND tx.ncbi_id = ? AND is_significant = 1 -- exclude low-scoring matches from the same clan SQL; $edgDBTypes ['rfam'] = 's'; // optional. In wikitext: {{#get_db_data: db = rfam | parameters=10116 <!-- substitutes ?'s in prepared statement --> | data=account=rfam_acc,sec=rfamseq_acc,start=seq_start,end=seq_end }} Several statements per connection: In LocalSettings.php: $edgDBServer ['rfam'] = 'mysql-rfam-public.ebi.ac.uk:4497'; $edgDBServerType['rfam'] = 'mysql'; $edgDBName ['rfam'] = 'Rfam'; $edgDBUser ['rfam'] = 'rfamro'; $edgDBPass ['rfam'] = ''; $edgDBPrepared ['rfam'] = [ 'sequences' => <<<'SEQ' SELECT fr.rfam_acc, fr.rfamseq_acc, fr.seq_start, fr.seq_end FROM full_region fr, rfamseq rf, taxonomy tx WHERE rf.ncbi_id = tx.ncbi_id AND fr.rfamseq_acc = rf.rfamseq_acc AND tx.ncbi_id = ? AND is_significant = 1 -- exclude low-scoring matches from the same clan SEQ, 'sno' => <<<'SNO' SELECT fr.rfam_acc, fr.rfamseq_acc, fr.seq_start, fr.seq_end, f.type FROM full_region fr, rfamseq rf, taxonomy tx, family f WHERE rf.ncbi_id = tx.ncbi_id AND f.rfam_acc = fr.rfam_acc AND fr.rfamseq_acc = rf.rfamseq_acc AND tx.tax_string LIKE ? AND f.type LIKE '%snoRNA%' AND is_significant = 1 -- exclude low-scoring matches from the same clan SNO]; In wikitext: {{#get_db_data: db = rfam | query=sequences <!-- which prepared statement? --> | parameters=10116 <!-- substitutes ?'s in prepared statement --> | data=account=rfam_acc,sec=rfamseq_acc,start=seq_start,end=seq_end }} If prepared SQL statements are defined for a database connection, arbitrary SQL queries are effectively disallowed. Changes to the class hierarchy: * EDConnectorBase ... ** EDConnectorDb ... *** EDConnectorComposed (new, abstract) **** EDConnectorRelational (abstract) ***** EDConnectorRdbms (new, for DBs handled by Wikimedia\Rdbms\Database) ... **** EDConnectorMongoDb ... *** EDConnectorPrepared (new, abstract) **** EDConnectorPreparedMysql (new) The new classes EDConnectorComposed and EDConnectorPrepared are contraposed. In addition, some property names are brought to camelCase, some methods are renamed and some unnecessary contructors are removed; the class ParsesParams now handles warning suppression. Bug: T287328 Change-Id: Ibf7593eff63074bda86cdaf3b0a6e7a2fc2708bd
- Loading branch information
1 parent
13497b7
commit d17b824
Showing
41 changed files
with
826 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.