Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php |
— | — | @@ -142,6 +142,18 @@ |
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
| 146 | + /** |
| 147 | + * TODO |
| 148 | + * |
| 149 | + * @param string $tableName |
| 150 | + * @param array $fieldNames |
| 151 | + * @param DatabaseBase $dbs |
| 152 | + * |
| 153 | + * @return false |
| 154 | + */ |
| 155 | + public function getSQLCondition( $tableName, array $fieldNames, DatabaseBase $dbs ) { |
| 156 | + return false; |
| 157 | + } |
146 | 158 | } |
147 | 159 | |
148 | 160 | /** |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php |
— | — | @@ -629,23 +629,32 @@ |
630 | 630 | |
631 | 631 | // Do not support smw_id joined data for now. |
632 | 632 | if ( $fieldNames && !$smwidjoinfield ) { |
633 | | - $comp = ''; |
| 633 | + $comparator = false; |
| 634 | + $customSQL = false; |
634 | 635 | |
635 | | - // TODO: refactor this hook away by using a method in the description classes |
636 | | - |
637 | 636 | switch ( $description->getComparator() ) { |
638 | | - case SMW_CMP_EQ: $comp = '='; break; |
639 | | - case SMW_CMP_LEQ: $comp = '<='; break; |
640 | | - case SMW_CMP_GEQ: $comp = '>='; break; |
641 | | - case SMW_CMP_NEQ: $comp = '!='; break; |
| 637 | + case SMW_CMP_EQ: $comparator = '='; break; |
| 638 | + case SMW_CMP_LEQ: $comparator = '<='; break; |
| 639 | + case SMW_CMP_GEQ: $comparator = '>='; break; |
| 640 | + case SMW_CMP_NEQ: $comparator = '!='; break; |
642 | 641 | } |
643 | 642 | |
644 | | - wfRunHooks( 'smwGetSQLConditionForValue', array( &$where, $description, $query->alias, $fieldNames, $this->m_dbs ) ); |
645 | | - |
646 | | - if ( $where == '' ) { |
647 | | - $value = $keys[$valueIndexes[0]]; // TODO //.// |
648 | | - $where = "{$query->alias}.{$fieldNames[0]}{$comp}" . $this->m_dbs->addQuotes( $value ); |
649 | | - } |
| 643 | + if ( !$comparator ) { |
| 644 | + $customSQL = $description->getSQLCondition( $query->alias, $fieldNames, $this->m_dbs ); |
| 645 | + } |
| 646 | + |
| 647 | + if ( $customSQL ) { |
| 648 | + $where = $customSQL; |
| 649 | + } |
| 650 | + else { |
| 651 | + $contitions = array(); |
| 652 | + |
| 653 | + for( $i = 0, $n = count( $fieldNames ); $i < $n; $i++ ) { |
| 654 | + $contitions[] = "$query->alias.{$fieldNames[$i]}{$comparator}" . $this->m_dbs->addQuotes( $keys[$valueIndexes[$i]] ); |
| 655 | + } |
| 656 | + |
| 657 | + $where = implode( ' && ', $contitions ); |
| 658 | + } |
650 | 659 | } |
651 | 660 | } |
652 | 661 | |