Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -548,7 +548,8 @@ |
549 | 549 | $this->m_sortkey = $query->sortkey; |
550 | 550 | $this->m_sortfield = false; |
551 | 551 | |
552 | | - $from = $db->tableName('page'); |
| 552 | + $pagetable = $db->tableName('page'); |
| 553 | + $from = $pagetable; |
553 | 554 | $where = ''; |
554 | 555 | $curtables = array('PAGE' => $from); |
555 | 556 | $this->createSQLQuery($query->getDescription(), $from, $where, $db, $curtables); |
— | — | @@ -562,7 +563,7 @@ |
563 | 564 | if ( $smwgIQSortingEnabled ) { |
564 | 565 | $order = $query->ascending ? 'ASC' : 'DESC'; |
565 | 566 | if ( ($this->m_sortfield == false) && ($this->m_sortkey == false) ) { |
566 | | - $sql_options['ORDER BY'] = "page.page_title $order "; // default |
| 567 | + $sql_options['ORDER BY'] = "$pagetable.page_title $order "; // default |
567 | 568 | } elseif ($this->m_sortfield != false) { |
568 | 569 | $sql_options['ORDER BY'] = $this->m_sortfield . " $order "; |
569 | 570 | } // else: sortkey given but not found: do not sort |
— | — | @@ -571,7 +572,7 @@ |
572 | 573 | // Execute query and format result as array |
573 | 574 | if ($query->querymode == SMWQuery::MODE_COUNT) { |
574 | 575 | $res = $db->select($from, |
575 | | - 'COUNT(DISTINCT page.page_id) AS count', |
| 576 | + "COUNT(DISTINCT $pagetable.page_id) AS count", |
576 | 577 | $where, |
577 | 578 | 'SMW::getQueryResult', |
578 | 579 | $sql_options ); |
— | — | @@ -581,7 +582,7 @@ |
582 | 583 | list( $startOpts, $useIndex, $tailOpts ) = $db->makeSelectOptions( $sql_options ); |
583 | 584 | $result = '<div style="border: 1px dotted black; background: #A1FB00; padding: 20px; ">' . |
584 | 585 | '<b>SQL-Query</b><br />' . |
585 | | - 'SELECT DISTINCT page.page_title as title, page.page_namespace as namespace' . |
| 586 | + "SELECT DISTINCT $pagetable.page_title as title, $pagetable.page_namespace as namespace" . |
586 | 587 | ' FROM ' . $from . ' WHERE ' . $where . $tailOpts . '<br />' . |
587 | 588 | '<b>SQL-Query options</b><br />'; |
588 | 589 | foreach ($sql_options as $key => $value) { |
— | — | @@ -592,7 +593,7 @@ |
593 | 594 | } // else: continue |
594 | 595 | |
595 | 596 | $res = $db->select($from, |
596 | | - 'DISTINCT page.page_title as title, page.page_namespace as namespace', |
| 597 | + "DISTINCT $pagetable.page_title as title, $pagetable.page_namespace as namespace", |
597 | 598 | $where, |
598 | 599 | 'SMW::getQueryResult', |
599 | 600 | $sql_options ); |