return "REPLACE({$orig}, {$old}, {$new})";
}
+ /**
+ * Convert a field to an unix timestamp
+ *
+ * @param $field String: field name
+ * @return String: SQL statement
+ */
+ public function unixTimestamp( $field ) {
+ return "EXTRACT(epoch FROM $field)";
+ }
+
/**
* Determines if the last failure was due to a deadlock
* STUB
return false;
}
+ public function unixTimestamp( $field ) {
+ return "DATEDIFF(s,CONVERT(datetime,'1/1/1970'),$field)";
+ }
+
/**
* Begin a transaction, committing any previously open transaction
*/
$this->query( "SET sql_big_selects=$encValue", __METHOD__ );
}
+ public function unixTimestamp( $field ) {
+ return "UNIX_TIMESTAMP($field)";
+ }
/**
* Determines if the last failure was due to a deadlock
return 'SELECT * ' . ( $all ? '':'/* UNION_UNIQUE */ ' ) . 'FROM (' . implode( $glue, $sqls ) . ')' ;
}
+ public function unixTimestamp( $field ) {
+ return "((trunc($field) - to_date('19700101','YYYYMMDD')) * 86400)";
+ }
+
function wasDeadlock() {
return $this->lastErrno() == 'OCI-00060';
}
return implode( $glue, $sqls );
}
+ public function unixTimestamp( $field ) {
+ return $field;
+ }
+
function wasDeadlock() {
return $this->lastErrno() == 5; // SQLITE_BUSY
}
function isSyndicated() { return false; }
function getSQL() {
- global $wgDBtype;
$db = wfGetDB( DB_SLAVE );
$page = $db->tableName( 'page' );
$revision = $db->tableName( 'revision' );
-
- switch ($wgDBtype) {
- case 'mysql':
- $epoch = 'UNIX_TIMESTAMP(rev_timestamp)';
- break;
- case 'ibm_db2':
- // TODO implement proper conversion to a Unix epoch
- $epoch = 'rev_timestamp';
- break;
- case 'oracle':
- $epoch = '((trunc(rev_timestamp) - to_date(\'19700101\',\'YYYYMMDD\')) * 86400)';
- break;
- case 'sqlite':
- $epoch = 'rev_timestamp';
- break;
- case 'mssql':
- $epoch = 'DATEDIFF(s,CONVERT(datetime,\'1/1/1970\'),rev_timestamp)';
- break;
- default:
- $epoch = 'EXTRACT(epoch FROM rev_timestamp)';
- }
+ $epoch = $db->unixTimestamp( 'rev_timestamp' );
return
"SELECT 'Ancientpages' as type,
function isSyndicated() { return false; }
function getSQL() {
- global $wgCountCategorizedImagesAsUsed, $wgDBtype;
+ global $wgCountCategorizedImagesAsUsed;
+
$dbr = wfGetDB( DB_SLAVE );
- switch ($wgDBtype) {
- case 'mysql':
- $epoch = 'UNIX_TIMESTAMP(img_timestamp)';
- break;
- case 'oracle':
- $epoch = '((trunc(img_timestamp) - to_date(\'19700101\',\'YYYYMMDD\')) * 86400)';
- break;
- case 'sqlite':
- $epoch = 'img_timestamp';
- break;
- case 'mssql':
- $epoch = 'DATEDIFF(s,CONVERT(datetime,\'1/1/1970\'),img_timestamp)';
- break;
- default:
- $epoch = 'EXTRACT(epoch FROM img_timestamp)';
- }
+ $epoch = $db->unixTimestamp( 'rev_timestamp' );
if ( $wgCountCategorizedImagesAsUsed ) {
list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' );