Skip to content

Commit d6682cd

Browse files
author
Daniel Kinzler
committed
for some odd reason, mysql doesn't like aliases for temp tables in other databases (or something)
git-svn-id: https://svn.toolserver.org/svnroot/daniel/duesenstuff/trunk/gpClient@545 9f2c43bc-b3c0-43f4-b155-41619b16f219
1 parent 36a19c3 commit d6682cd

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

php/gpMediaWiki.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,12 @@ public function retain_source( $src ) { //XXX: must be a 1 column id source...
394394
public function subtract_table( $table, $id_field = null ) {
395395
if ( !$id_field ) $id_field = $table->get_field1();
396396

397-
$sql = "DELETE FROM T ";
398-
$sql .= " USING " . $this->table . " AS T ";
399-
$sql .= " JOIN " . $table->get_name() . " AS R ";
400-
$sql .= " ON T." . $this->id_field . " = R." . $id_field;
397+
$t = $this->table;
398+
$r = $table->get_name();
399+
$sql = "DELETE FROM $t ";
400+
$sql .= " USING $t ";
401+
$sql .= " JOIN $r ";
402+
$sql .= " ON $t." . $this->id_field . " = $r." . $id_field;
401403

402404
$this->query($sql);
403405
return true;
@@ -406,11 +408,20 @@ public function subtract_table( $table, $id_field = null ) {
406408
public function retain_table( $table, $id_field = null ) {
407409
if ( !$id_field ) $id_field = $table->get_field1();
408410

409-
$sql = "DELETE FROM T ";
410-
$sql .= " USING " . $this->table . " AS T ";
411-
$sql .= " LEFT JOIN " . $table->get_name() . " AS R ";
412-
$sql .= " ON T." . $this->id_field . " = R." . $id_field;
413-
$sql .= " WHERE R.$id_field IS NULL";
411+
#$sql = "DELETE FROM T ";
412+
#$sql .= " USING " . $this->table . " AS T ";
413+
#$sql .= " LEFT JOIN " . $table->get_name() . " AS R ";
414+
#$sql .= " ON T." . $this->id_field . " = R." . $id_field;
415+
#$sql .= " WHERE R.$id_field IS NULL";
416+
417+
#NOTE: for some silly reason, mysql doesn't like aliases for temp tables in other databases.
418+
$t = $this->table;
419+
$r = $table->get_name();
420+
$sql = "DELETE FROM $t ";
421+
$sql .= " USING $t ";
422+
$sql .= " LEFT JOIN $r ";
423+
$sql .= " ON $t." . $this->id_field . " = $r." . $id_field;
424+
$sql .= " WHERE $r.$id_field IS NULL";
414425

415426
$this->query($sql);
416427
return true;
@@ -508,8 +519,8 @@ public function strip( $where, $join = null, $inverse = false ) { #TODO: port to
508519
}
509520

510521
if ( $join ) {
511-
$sql = 'DELETE FROM T ';
512-
$sql .= ' USING ' . $this->table . ' AS T ';
522+
$sql = 'DELETE FROM ' . $this->table;
523+
$sql .= ' USING ' . $this->table . ' ';
513524
$sql .= $join;
514525
} else {
515526
$sql = 'DELETE FROM ' . $this->table;

0 commit comments

Comments
 (0)