Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -387,7 +387,7 @@ |
388 | 388 | foreach ( $proptable->objectfields as $fieldname => $typeid ) { // now add select entries for object column(s) |
389 | 389 | if ( $typeid == 'p' ) { // Special case: page id, use smw_id table to insert 4 page-specific values instead of internal id |
390 | 390 | $from .= ' INNER JOIN ' . $db->tableName( 'smw_ids' ) . " AS o$valuecount ON $fieldname=o$valuecount.smw_id"; |
391 | | - $select .= ( ( $select != '' ) ? ',':'' ) . "$fieldname AS id$valuecount"; |
| 391 | + $select .= ( ( $select != '' ) ? ',' : '' ) . "$fieldname AS id$valuecount"; |
392 | 392 | $selectvalues[$valuecount] = "o$valuecount.smw_title"; |
393 | 393 | $selectvalues[$valuecount + 1] = "o$valuecount.smw_namespace"; |
394 | 394 | $selectvalues[$valuecount + 2] = "o$valuecount.smw_iw"; |
— | — | @@ -457,7 +457,7 @@ |
458 | 458 | foreach ( self::getPropertyTables() as $tid => $pt ) { // just read all |
459 | 459 | $newvalue = array_merge( $newvalue, $this->fetchSemanticData( $row->$oidfield, null, $pt ) ); |
460 | 460 | } |
461 | | - } elseif ( ( $iw != '' ) && ( $iw { 0 } == ':' ) ) { // other internal object, maybe a DB inconsistency; ignore row |
| 461 | + } elseif ( ( $iw != '' ) && ( $iw { 0 } == ' : ' ) ) { // other internal object, maybe a DB inconsistency; ignore row |
462 | 462 | $propertyname = ''; |
463 | 463 | } |
464 | 464 | next( $pagevalues ); |
— | — | @@ -520,7 +520,7 @@ |
521 | 521 | } |
522 | 522 | |
523 | 523 | if ( $proptable->fixedproperty == false ) { |
524 | | - $where .= ( $where ? ' AND ':'' ) . "t1.p_id=" . $db->addQuotes( $pid ); |
| 524 | + $where .= ( $where ? ' AND ' : '' ) . "t1.p_id=" . $db->addQuotes( $pid ); |
525 | 525 | } |
526 | 526 | |
527 | 527 | $this->prepareValueQuery( $from, $where, $proptable, $value, 1 ); |
— | — | @@ -587,7 +587,7 @@ |
588 | 588 | } |
589 | 589 | |
590 | 590 | if ( $subproptable->fixedproperty == false ) { // the ID we get should be !=0, so no point in filtering the converse |
591 | | - $where .= ( $where ? ' AND ':'' ) . "t$tableindex.p_id=" . $db->addQuotes( $this->getSMWPropertyID( $subproperty ) ); |
| 591 | + $where .= ( $where ? ' AND ' : '' ) . "t$tableindex.p_id=" . $db->addQuotes( $this->getSMWPropertyID( $subproperty ) ); |
592 | 592 | } |
593 | 593 | |
594 | 594 | $this->prepareValueQuery( $from, $where, $subproptable, $subvalue, $tableindex ); |
— | — | @@ -603,9 +603,9 @@ |
604 | 604 | if ( $typeid == 'p' ) { // Special case: page id, resolve this in advance |
605 | 605 | $oid = $this->getSMWPageID( $dbkeys[$i], $dbkeys[$i + 1], $dbkeys[$i + 2] ); |
606 | 606 | $i += 3; // skip these additional values (sortkey not needed here) |
607 | | - $where .= ( $where ? ' AND ':'' ) . "t$tableindex.$fieldname=" . $db->addQuotes( $oid ); |
| 607 | + $where .= ( $where ? ' AND ' : '' ) . "t$tableindex.$fieldname=" . $db->addQuotes( $oid ); |
608 | 608 | } elseif ( $typeid != 'l' ) { // plain value, but not a text blob |
609 | | - $where .= ( $where ? ' AND ':'' ) . "t$tableindex.$fieldname=" . $db->addQuotes( $dbkeys[$i] ); |
| 609 | + $where .= ( $where ? ' AND ' : '' ) . "t$tableindex.$fieldname=" . $db->addQuotes( $dbkeys[$i] ); |
610 | 610 | } |
611 | 611 | |
612 | 612 | $i++; |
— | — | @@ -1261,16 +1261,18 @@ |
1262 | 1262 | $reportTo = $verbose ? $this:null; // use $this to report back from static SMWSQLHelpers |
1263 | 1263 | |
1264 | 1264 | // repeatedly used DB field types defined here for convenience |
1265 | | - $dbtypes = array( 't' => SMWSQLHelpers::getStandardDBType( 'title' ), |
1266 | | - 'u' => ( $wgDBtype == 'postgres' ? 'TEXT' : 'VARCHAR(63) binary' ), |
1267 | | - 'l' => SMWSQLHelpers::getStandardDBType( 'blob' ), |
1268 | | - 'f' => ( $wgDBtype == 'postgres' ? 'DOUBLE PRECISION' : 'DOUBLE' ), |
1269 | | - 'i' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8)' ), |
1270 | | - 'j' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8) UNSIGNED' ), |
1271 | | - 'p' => SMWSQLHelpers::getStandardDBType( 'id' ), |
1272 | | - 'n' => SMWSQLHelpers::getStandardDBType( 'namespace' ), |
1273 | | - 'w' => SMWSQLHelpers::getStandardDBType( 'iw' ) ); |
1274 | | -//.// |
| 1265 | + $dbtypes = array( |
| 1266 | + 't' => SMWSQLHelpers::getStandardDBType( 'title' ), |
| 1267 | + 'u' => ( $wgDBtype == 'postgres' ? 'TEXT' : 'VARCHAR(63) binary' ), |
| 1268 | + 'l' => SMWSQLHelpers::getStandardDBType( 'blob' ), |
| 1269 | + 'f' => ( $wgDBtype == 'postgres' ? 'DOUBLE PRECISION' : 'DOUBLE' ), |
| 1270 | + 'i' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8)' ), |
| 1271 | + 'j' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8) UNSIGNED' ), |
| 1272 | + 'p' => SMWSQLHelpers::getStandardDBType( 'id' ), |
| 1273 | + 'n' => SMWSQLHelpers::getStandardDBType( 'namespace' ), |
| 1274 | + 'w' => SMWSQLHelpers::getStandardDBType( 'iw' ) |
| 1275 | + ); |
| 1276 | + |
1275 | 1277 | // DB update: field renaming between SMW 1.3 and SMW 1.4 |
1276 | 1278 | if ( ( $db->tableExists( $smw_spec2 ) ) && ( $db->fieldExists( $smw_spec2, 'sp_id', 'SMWSQLStore2::setup' ) ) ) { |
1277 | 1279 | if ( $wgDBtype == 'postgres' ) { |
— | — | @@ -1280,26 +1282,39 @@ |
1281 | 1283 | } |
1282 | 1284 | } |
1283 | 1285 | |
1284 | | - // set up table for internal IDs used in this store: |
1285 | | - SMWSQLHelpers::setupTable( $smw_ids, |
1286 | | - array( 'smw_id' => $dbtypes['p'] . ' NOT NULL' . ( $wgDBtype == 'postgres' ? ' PRIMARY KEY':' KEY AUTO_INCREMENT' ), |
1287 | | - 'smw_namespace' => $dbtypes['n'] . ' NOT NULL', |
1288 | | - 'smw_title' => $dbtypes['t'] . ' NOT NULL', |
1289 | | - 'smw_iw' => $dbtypes['w'], |
1290 | | - 'smw_sortkey' => $dbtypes['t'] . ' NOT NULL' ), $db, $reportTo ); |
| 1286 | + // Set up table for internal IDs used in this store: |
| 1287 | + SMWSQLHelpers::setupTable( |
| 1288 | + $smw_ids, |
| 1289 | + array( |
| 1290 | + 'smw_id' => $dbtypes['p'] . ' NOT NULL' . ( $wgDBtype == 'postgres' ? ' PRIMARY KEY' : ' KEY AUTO_INCREMENT' ), |
| 1291 | + 'smw_namespace' => $dbtypes['n'] . ' NOT NULL', |
| 1292 | + 'smw_title' => $dbtypes['t'] . ' NOT NULL', |
| 1293 | + 'smw_iw' => $dbtypes['w'], |
| 1294 | + 'smw_sortkey' => $dbtypes['t'] . ' NOT NULL' |
| 1295 | + ), |
| 1296 | + $db, |
| 1297 | + $reportTo |
| 1298 | + ); |
| 1299 | + |
1291 | 1300 | SMWSQLHelpers::setupIndex( $smw_ids, array( 'smw_id', 'smw_title,smw_namespace,smw_iw', 'smw_sortkey' ), $db ); |
1292 | 1301 | |
1293 | | - // set up concept cache: member elements (s)->concepts (o) |
1294 | | - SMWSQLHelpers::setupTable( $smw_conccache, |
1295 | | - array( 's_id' => $dbtypes['p'] . ' NOT NULL', |
1296 | | - 'o_id' => $dbtypes['p'] . ' NOT NULL' ), $db, $reportTo ); |
| 1302 | + // Set up concept cache: member elements (s)->concepts (o) |
| 1303 | + SMWSQLHelpers::setupTable( |
| 1304 | + $smw_conccache, |
| 1305 | + array( |
| 1306 | + 's_id' => $dbtypes['p'] . ' NOT NULL', |
| 1307 | + 'o_id' => $dbtypes['p'] . ' NOT NULL' |
| 1308 | + ), |
| 1309 | + $db, |
| 1310 | + $reportTo |
| 1311 | + ); |
1297 | 1312 | |
1298 | 1313 | SMWSQLHelpers::setupIndex( $smw_conccache, array( 'o_id' ), $db ); |
1299 | 1314 | |
1300 | 1315 | // set up concept descriptions |
1301 | 1316 | SMWSQLHelpers::setupTable( $smw_conc2, |
1302 | 1317 | array( 's_id' => $dbtypes['p'] . ' NOT NULL' . |
1303 | | - ( $wgDBtype == 'postgres' ? ' PRIMARY KEY':' KEY' ), |
| 1318 | + ( $wgDBtype == 'postgres' ? ' PRIMARY KEY' : ' KEY' ), |
1304 | 1319 | 'concept_txt' => $dbtypes['l'], |
1305 | 1320 | 'concept_docu' => $dbtypes['l'], |
1306 | 1321 | 'concept_features' => $dbtypes['i'], |
— | — | @@ -1413,7 +1428,7 @@ |
1414 | 1429 | |
1415 | 1430 | foreach ( $tables as $table ) { |
1416 | 1431 | $name = $db->tableName( $table ); |
1417 | | - $db->query( 'DROP TABLE' . ( $wgDBtype == 'postgres' ? '':' IF EXISTS' ) . $name, 'SMWSQLStore2::drop' ); |
| 1432 | + $db->query( 'DROP TABLE' . ( $wgDBtype == 'postgres' ? '' : ' IF EXISTS' ) . $name, 'SMWSQLStore2::drop' ); |
1418 | 1433 | $this->reportProgress( " ... dropped table $name.\n", $verbose ); |
1419 | 1434 | } |
1420 | 1435 | |
— | — | @@ -1634,13 +1649,14 @@ |
1635 | 1650 | if ( $labelcol != '' ) { // Apply string conditions. |
1636 | 1651 | foreach ( $requestoptions->getStringConditions() as $strcond ) { |
1637 | 1652 | $string = str_replace( '_', '\_', $strcond->string ); |
| 1653 | + |
1638 | 1654 | switch ( $strcond->condition ) { |
1639 | 1655 | case SMWStringCondition::STRCOND_PRE: $string .= '%'; break; |
1640 | 1656 | case SMWStringCondition::STRCOND_POST: $string = '%' . $string; break; |
1641 | 1657 | case SMWStringCondition::STRCOND_MID: $string = '%' . $string . '%'; break; |
1642 | 1658 | } |
1643 | 1659 | |
1644 | | - $sql_conds .= ( ( $addand || ( $sql_conds != '' ) ) ? ' AND ':'' ) . $labelcol . ' LIKE ' . $db->addQuotes( $string ); |
| 1660 | + $sql_conds .= ( ( $addand || ( $sql_conds != '' ) ) ? ' AND ' : '' ) . $labelcol . ' LIKE ' . $db->addQuotes( $string ); |
1645 | 1661 | } |
1646 | 1662 | } |
1647 | 1663 | } |