Go to the documentation of this file.
26 $this->assertEquals( $sqlText, $db->
getLastSqls() );
44 isset( $sql[
'conds'] ) ? $sql[
'conds'] : [],
46 isset( $sql[
'options'] ) ? $sql[
'options'] : [],
47 isset( $sql[
'join_conds'] ) ? $sql[
'join_conds'] : []
57 'fields' => [
'field',
'alias' =>
'field2' ],
58 'conds' => [
'alias' =>
'text' ],
60 "SELECT field,field2 AS alias " .
62 "WHERE alias = 'text'"
67 'tables' =>
' table LEFT JOIN table2',
68 'fields' => [
'field' ],
69 'conds' => [
'field' =>
'text' ],
71 "SELECT field FROM table LEFT JOIN table2 WHERE field = 'text'"
77 'fields' => [
'SPECIAL_QUERY()' ],
79 "SELECT SPECIAL_QUERY()"
84 'fields' => [
'field',
'alias' =>
'field2' ],
85 'conds' => [
'alias' =>
'text' ],
86 'options' => [
'LIMIT' => 1,
'ORDER BY' =>
'field' ],
88 "SELECT field,field2 AS alias " .
90 "WHERE alias = 'text' " .
96 'tables' => [
'table',
't2' =>
'table2' ],
97 'fields' => [
'tid',
'field',
'alias' =>
'field2',
't2.id' ],
98 'conds' => [
'alias' =>
'text' ],
99 'options' => [
'LIMIT' => 1,
'ORDER BY' =>
'field' ],
100 'join_conds' => [
't2' => [
101 'LEFT JOIN',
'tid = t2.id'
104 "SELECT tid,field,field2 AS alias,t2.id " .
105 "FROM table LEFT JOIN table2 t2 ON ((tid = t2.id)) " .
106 "WHERE alias = 'text' " .
112 'tables' => [
'table',
't2' =>
'table2' ],
113 'fields' => [
'tid',
'field',
'alias' =>
'field2',
't2.id' ],
114 'conds' => [
'alias' =>
'text' ],
115 'options' => [
'LIMIT' => 1,
'GROUP BY' =>
'field',
'HAVING' =>
'COUNT(*) > 1' ],
116 'join_conds' => [
't2' => [
117 'LEFT JOIN',
'tid = t2.id'
120 "SELECT tid,field,field2 AS alias,t2.id " .
121 "FROM table LEFT JOIN table2 t2 ON ((tid = t2.id)) " .
122 "WHERE alias = 'text' " .
123 "GROUP BY field HAVING COUNT(*) > 1 " .
128 'tables' => [
'table',
't2' =>
'table2' ],
129 'fields' => [
'tid',
'field',
'alias' =>
'field2',
't2.id' ],
130 'conds' => [
'alias' =>
'text' ],
133 'GROUP BY' => [
'field',
'field2' ],
134 'HAVING' => [
'COUNT(*) > 1',
'field' => 1 ]
136 'join_conds' => [
't2' => [
137 'LEFT JOIN',
'tid = t2.id'
140 "SELECT tid,field,field2 AS alias,t2.id " .
141 "FROM table LEFT JOIN table2 t2 ON ((tid = t2.id)) " .
142 "WHERE alias = 'text' " .
143 "GROUP BY field,field2 HAVING (COUNT(*) > 1) AND field = '1' " .
148 'tables' => [
'table' ],
149 'fields' => [
'alias' =>
'field' ],
150 'conds' => [
'alias' => [ 1, 2, 3, 4 ] ],
152 "SELECT field AS alias " .
154 "WHERE alias IN ('1','2','3','4')"
159 'fields' => [
'field' ],
160 'options' => [
'USE INDEX' => [
'table' =>
'X' ] ],
163 "SELECT field FROM table"
168 'fields' => [
'field' ],
169 'options' => [
'IGNORE INDEX' => [
'table' =>
'X' ] ],
172 "SELECT field FROM table"
177 'fields' => [
'field' ],
178 'options' => [
'DISTINCT',
'LOCK IN SHARE MODE' ],
180 "SELECT DISTINCT field FROM table LOCK IN SHARE MODE"
185 'fields' => [
'field' ],
186 'options' => [
'EXPLAIN' =>
true ],
188 'EXPLAIN SELECT field FROM table'
193 'fields' => [
'field' ],
194 'options' => [
'FOR UPDATE' ],
196 "SELECT field FROM table FOR UPDATE"
213 isset( $sql[
'options'] ) ? $sql[
'options'] : []
223 'values' => [
'field' =>
'text',
'field2' =>
'text2' ],
224 'conds' => [
'alias' =>
'text' ],
227 "SET field = 'text'" .
228 ",field2 = 'text2' " .
229 "WHERE alias = 'text'"
234 'values' => [
'field = other',
'field2' =>
'text2' ],
235 'conds' => [
'id' =>
'1' ],
238 "SET field = other" .
239 ",field2 = 'text2' " .
245 'values' => [
'field = other',
'field2' =>
'text2' ],
249 "SET field = other" .
273 'conds' => [
'alias' =>
'text' ],
275 "DELETE FROM table " .
276 "WHERE alias = 'text'"
296 $sql[
'uniqueIndexes'],
307 'table' =>
'upsert_table',
308 'rows' => [
'field' =>
'text',
'field2' =>
'text2' ],
309 'uniqueIndexes' => [
'field' ],
310 'set' => [
'field' =>
'set' ],
313 "UPDATE upsert_table " .
314 "SET field = 'set' " .
315 "WHERE ((field = 'text')); " .
316 "INSERT IGNORE INTO upsert_table " .
318 "VALUES ('text','text2'); " .
344 'delTable' =>
'table',
345 'joinTable' =>
'table_join',
347 'joinVar' =>
'field_join',
348 'conds' => [
'alias' =>
'text' ],
350 "DELETE FROM table " .
352 "SELECT field_join FROM table_join WHERE alias = 'text'" .
357 'delTable' =>
'table',
358 'joinTable' =>
'table_join',
360 'joinVar' =>
'field_join',
363 "DELETE FROM table " .
365 "SELECT field_join FROM table_join " .
381 isset( $sql[
'options'] ) ? $sql[
'options'] : []
391 'rows' => [
'field' =>
'text',
'field2' => 2 ],
393 "INSERT INTO table " .
395 "VALUES ('text','2')"
400 'rows' => [
'field' =>
'text',
'field2' => 2 ],
401 'options' =>
'IGNORE',
403 "INSERT IGNORE INTO table " .
405 "VALUES ('text','2')"
411 [
'field' =>
'text',
'field2' => 2 ],
412 [
'field' =>
'multi',
'field2' => 3 ],
414 'options' =>
'IGNORE',
416 "INSERT IGNORE INTO table " .
437 isset( $sql[
'insertOptions'] ) ? $sql[
'insertOptions'] : [],
438 isset( $sql[
'selectOptions'] ) ? $sql[
'selectOptions'] : [],
439 isset( $sql[
'selectJoinConds'] ) ? $sql[
'selectJoinConds'] : []
444 $dbWeb->forceNextResult( [
445 array_flip( array_keys( $sql[
'varMap'] ) )
447 $dbWeb->insertSelect(
453 isset( $sql[
'insertOptions'] ) ? $sql[
'insertOptions'] : [],
454 isset( $sql[
'selectOptions'] ) ? $sql[
'selectOptions'] : [],
455 isset( $sql[
'selectJoinConds'] ) ? $sql[
'selectJoinConds'] : []
457 $this->
assertLastSqlDb( implode(
'; ', [ $sqlSelect, $sqlInsert ] ), $dbWeb );
464 'destTable' =>
'insert_table',
465 'srcTable' =>
'select_table',
466 'varMap' => [
'field_insert' =>
'field_select',
'field' =>
'field2' ],
469 "INSERT INTO insert_table " .
470 "(field_insert,field) " .
471 "SELECT field_select,field2 " .
472 "FROM select_table WHERE *",
473 "SELECT field_select AS field_insert,field2 AS field " .
474 "FROM select_table WHERE * FOR UPDATE",
475 "INSERT INTO insert_table (field_insert,field) VALUES ('0','1')"
479 'destTable' =>
'insert_table',
480 'srcTable' =>
'select_table',
481 'varMap' => [
'field_insert' =>
'field_select',
'field' =>
'field2' ],
482 'conds' => [
'field' => 2 ],
484 "INSERT INTO insert_table " .
485 "(field_insert,field) " .
486 "SELECT field_select,field2 " .
487 "FROM select_table " .
489 "SELECT field_select AS field_insert,field2 AS field FROM " .
490 "select_table WHERE field = '2' FOR UPDATE",
491 "INSERT INTO insert_table (field_insert,field) VALUES ('0','1')"
495 'destTable' =>
'insert_table',
496 'srcTable' =>
'select_table',
497 'varMap' => [
'field_insert' =>
'field_select',
'field' =>
'field2' ],
498 'conds' => [
'field' => 2 ],
499 'insertOptions' =>
'IGNORE',
500 'selectOptions' => [
'ORDER BY' =>
'field' ],
502 "INSERT IGNORE INTO insert_table " .
503 "(field_insert,field) " .
504 "SELECT field_select,field2 " .
505 "FROM select_table " .
506 "WHERE field = '2' " .
508 "SELECT field_select AS field_insert,field2 AS field " .
509 "FROM select_table WHERE field = '2' ORDER BY field FOR UPDATE",
510 "INSERT IGNORE INTO insert_table (field_insert,field) VALUES ('0','1')"
514 'destTable' =>
'insert_table',
515 'srcTable' => [
'select_table1',
'select_table2' ],
516 'varMap' => [
'field_insert' =>
'field_select',
'field' =>
'field2' ],
517 'conds' => [
'field' => 2 ],
518 'selectOptions' => [
'ORDER BY' =>
'field',
'FORCE INDEX' => [
'select_table1' =>
'index1' ] ],
519 'selectJoinConds' => [
520 'select_table2' => [
'LEFT JOIN', [
'select_table1.foo = select_table2.bar' ] ],
523 "INSERT INTO insert_table " .
524 "(field_insert,field) " .
525 "SELECT field_select,field2 " .
526 "FROM select_table1 LEFT JOIN select_table2 ON ((select_table1.foo = select_table2.bar)) " .
527 "WHERE field = '2' " .
529 "SELECT field_select AS field_insert,field2 AS field " .
530 "FROM select_table1 LEFT JOIN select_table2 ON ((select_table1.foo = select_table2.bar)) " .
531 "WHERE field = '2' ORDER BY field FOR UPDATE",
532 "INSERT INTO insert_table (field_insert,field) VALUES ('0','1')"
544 $sql[
'uniqueIndexes'],
555 'table' =>
'replace_table',
556 'uniqueIndexes' => [
'field' ],
557 'rows' => [
'field' =>
'text',
'field2' =>
'text2' ],
559 "DELETE FROM replace_table " .
560 "WHERE ( field='text' ); " .
561 "INSERT INTO replace_table " .
563 "VALUES ('text','text2')"
567 'table' =>
'module_deps',
568 'uniqueIndexes' => [ [
'md_module',
'md_skin' ] ],
570 'md_module' =>
'module',
575 "DELETE FROM module_deps " .
576 "WHERE ( md_module='module' AND md_skin='skin' ); " .
577 "INSERT INTO module_deps " .
578 "(md_module,md_skin,md_deps) " .
579 "VALUES ('module','skin','deps')"
583 'table' =>
'module_deps',
584 'uniqueIndexes' => [ [
'md_module',
'md_skin' ] ],
587 'md_module' =>
'module',
591 'md_module' =>
'module2',
592 'md_skin' =>
'skin2',
593 'md_deps' =>
'deps2',
597 "DELETE FROM module_deps " .
598 "WHERE ( md_module='module' AND md_skin='skin' ); " .
599 "INSERT INTO module_deps " .
600 "(md_module,md_skin,md_deps) " .
601 "VALUES ('module','skin','deps'); " .
602 "DELETE FROM module_deps " .
603 "WHERE ( md_module='module2' AND md_skin='skin2' ); " .
604 "INSERT INTO module_deps " .
605 "(md_module,md_skin,md_deps) " .
606 "VALUES ('module2','skin2','deps2')"
610 'table' =>
'module_deps',
611 'uniqueIndexes' => [
'md_module',
'md_skin' ],
614 'md_module' =>
'module',
618 'md_module' =>
'module2',
619 'md_skin' =>
'skin2',
620 'md_deps' =>
'deps2',
624 "DELETE FROM module_deps " .
625 "WHERE ( md_module='module' ) OR ( md_skin='skin' ); " .
626 "INSERT INTO module_deps " .
627 "(md_module,md_skin,md_deps) " .
628 "VALUES ('module','skin','deps'); " .
629 "DELETE FROM module_deps " .
630 "WHERE ( md_module='module2' ) OR ( md_skin='skin2' ); " .
631 "INSERT INTO module_deps " .
632 "(md_module,md_skin,md_deps) " .
633 "VALUES ('module2','skin2','deps2')"
637 'table' =>
'module_deps',
638 'uniqueIndexes' => [],
640 'md_module' =>
'module',
645 "INSERT INTO module_deps " .
646 "(md_module,md_skin,md_deps) " .
647 "VALUES ('module','skin','deps')"
669 'table' =>
'replace_table',
670 'rows' => [
'field' =>
'text',
'field2' =>
'text2' ],
672 "REPLACE INTO replace_table " .
674 "VALUES ('text','text2')"
684 $this->assertEquals( trim( $this->
database->conditional(
695 'conds' => [
'field' =>
'text' ],
699 "(CASE WHEN field = 'text' THEN 1 ELSE NULL END)"
703 'conds' => [
'field' =>
'text',
'field2' =>
'anothertext' ],
707 "(CASE WHEN field = 'text' AND field2 = 'anothertext' THEN 1 ELSE NULL END)"
711 'conds' =>
'field=1',
715 "(CASE WHEN field=1 THEN 1 ELSE NULL END)"
725 $this->assertEquals( trim( $this->
database->buildConcat(
733 [
'field',
'field2' ],
734 "CONCAT(field,field2)"
737 [
"'test'",
'field2' ],
738 "CONCAT('test',field2)"
749 $this->assertEquals( trim( $this->
database->buildLike(
758 "LIKE 'text' ESCAPE '`'"
762 "LIKE 'text%' ESCAPE '`'"
765 [
'text',
new LikeMatch(
'%' ),
'text2' ],
766 "LIKE 'text%text2' ESCAPE '`'"
770 "LIKE 'text_' ESCAPE '`'"
774 "LIKE 'more`_text' ESCAPE '`'"
777 [
'C:\\Windows\\',
new LikeMatch(
'%' ) ],
778 "LIKE 'C:\\Windows\\%' ESCAPE '`'"
781 [
'accent`_test`',
new LikeMatch(
'%' ) ],
782 "LIKE 'accent```_test``%' ESCAPE '`'"
792 $this->assertEquals( trim( $this->
database->unionQueries(
802 'sqls' => [
'RAW SQL',
'RAW2SQL' ],
805 "(RAW SQL) UNION ALL (RAW2SQL)"
809 'sqls' => [
'RAW SQL',
'RAW2SQL' ],
812 "(RAW SQL) UNION (RAW2SQL)"
816 'sqls' => [
'RAW SQL',
'RAW2SQL',
'RAW3SQL' ],
819 "(RAW SQL) UNION (RAW2SQL) UNION (RAW3SQL)"
829 if ( isset(
$params[
'unionSupportsOrderAndLimit'] ) ) {
830 $this->
database->setUnionSupportsOrderAndLimit(
$params[
'unionSupportsOrderAndLimit'] );
833 $sql = trim( $this->
database->unionConditionPermutations(
842 $this->assertEquals( $expect, $sql );
850 'table' => [
'table1',
'table2' ],
851 'vars' => [
'field1',
'alias' =>
'field2' ],
853 'field3' => [ 1, 2, 3 ],
854 'duplicates' => [ 4, 5, 4 ],
858 'extra_conds' =>
'table2.bar > 23',
860 'ORDER BY' => [
'field1',
'alias' ],
861 'INNER ORDER BY' => [
'field1',
'field2' ],
865 'table2' => [
'JOIN',
'table1.foo_id = table2.foo_id' ],
868 "(SELECT field1,field2 AS alias FROM table1 JOIN table2 ON ((table1.foo_id = table2.foo_id)) WHERE field3 = '1' AND duplicates = '4' AND single = '0' AND (table2.bar > 23) ORDER BY field1,field2 LIMIT 100 ) UNION ALL " .
869 "(SELECT field1,field2 AS alias FROM table1 JOIN table2 ON ((table1.foo_id = table2.foo_id)) WHERE field3 = '1' AND duplicates = '5' AND single = '0' AND (table2.bar > 23) ORDER BY field1,field2 LIMIT 100 ) UNION ALL " .
870 "(SELECT field1,field2 AS alias FROM table1 JOIN table2 ON ((table1.foo_id = table2.foo_id)) WHERE field3 = '2' AND duplicates = '4' AND single = '0' AND (table2.bar > 23) ORDER BY field1,field2 LIMIT 100 ) UNION ALL " .
871 "(SELECT field1,field2 AS alias FROM table1 JOIN table2 ON ((table1.foo_id = table2.foo_id)) WHERE field3 = '2' AND duplicates = '5' AND single = '0' AND (table2.bar > 23) ORDER BY field1,field2 LIMIT 100 ) UNION ALL " .
872 "(SELECT field1,field2 AS alias FROM table1 JOIN table2 ON ((table1.foo_id = table2.foo_id)) WHERE field3 = '3' AND duplicates = '4' AND single = '0' AND (table2.bar > 23) ORDER BY field1,field2 LIMIT 100 ) UNION ALL " .
873 "(SELECT field1,field2 AS alias FROM table1 JOIN table2 ON ((table1.foo_id = table2.foo_id)) WHERE field3 = '3' AND duplicates = '5' AND single = '0' AND (table2.bar > 23) ORDER BY field1,field2 LIMIT 100 ) " .
874 "ORDER BY field1,alias LIMIT 100"
879 'vars' => [
'foo_id' ],
881 'bar' => [ 1, 2, 3 ],
883 'extra_conds' => [
'baz' => null ],
886 'ORDER BY' => [
'foo_id' ],
890 "(SELECT foo_id FROM foo WHERE bar = '1' AND baz IS NULL ORDER BY foo_id LIMIT 25 ) UNION " .
891 "(SELECT foo_id FROM foo WHERE bar = '2' AND baz IS NULL ORDER BY foo_id LIMIT 25 ) UNION " .
892 "(SELECT foo_id FROM foo WHERE bar = '3' AND baz IS NULL ORDER BY foo_id LIMIT 25 ) " .
893 "ORDER BY foo_id LIMIT 25"
898 'vars' => [
'foo_id' ],
900 'bar' => [ 1, 2, 3 ],
902 'extra_conds' => [
'baz' => null ],
905 'ORDER BY' => [
'foo_id' ],
908 'unionSupportsOrderAndLimit' =>
false,
910 "(SELECT foo_id FROM foo WHERE bar = '1' AND baz IS NULL ) UNION " .
911 "(SELECT foo_id FROM foo WHERE bar = '2' AND baz IS NULL ) UNION " .
912 "(SELECT foo_id FROM foo WHERE bar = '3' AND baz IS NULL ) " .
913 "ORDER BY foo_id LIMIT 25"
918 'vars' => [
'foo_id' ],
919 'permute_conds' => [],
920 'extra_conds' => [
'baz' => null ],
922 'ORDER BY' => [
'foo_id' ],
926 "SELECT foo_id FROM foo WHERE baz IS NULL ORDER BY foo_id LIMIT 25"
931 'vars' => [
'foo_id' ],
935 'extra_conds' => [
'baz' => null ],
937 'ORDER BY' => [
'foo_id' ],
941 "SELECT foo_id FROM foo WHERE baz IS NULL ORDER BY foo_id LIMIT 25"
946 'vars' => [
'foo_id' ],
951 'ORDER BY' => [
'foo_id' ],
956 "SELECT foo_id FROM foo WHERE bar = '1' ORDER BY foo_id LIMIT 150,25"
961 'vars' => [
'foo_id' ],
962 'permute_conds' => [],
963 'extra_conds' => [
'baz' => null ],
965 'ORDER BY' => [
'foo_id' ],
968 'INNER ORDER BY' => [
'bar_id' ],
971 "(SELECT foo_id FROM foo WHERE baz IS NULL ORDER BY bar_id LIMIT 175 ) ORDER BY foo_id LIMIT 150,25"
976 'vars' => [
'foo_id' ],
977 'permute_conds' => [],
978 'extra_conds' => [
'baz' => null ],
980 'ORDER BY' => [
'foo_id' ],
983 'INNER ORDER BY' => [
'bar_id' ],
985 'unionSupportsOrderAndLimit' =>
false,
987 "SELECT foo_id FROM foo WHERE baz IS NULL ORDER BY foo_id LIMIT 150,25"
998 $this->
database->begin( __METHOD__ );
999 $this->
database->commit( __METHOD__ );
1008 $this->
database->begin( __METHOD__ );
1009 $this->
database->rollback( __METHOD__ );
1017 $this->
database->setExistingTables( [
'table' ] );
1018 $this->
database->dropTable(
'table', __METHOD__ );
1027 $this->
database->dropTable(
'non_existing', __METHOD__ )
1036 $this->assertEquals( trim( $this->
database->makeList(
1044 [
'value',
'value2' ],
1049 [
'field',
'field2' ],
1054 [
'field' =>
'value',
'field2' =>
'value2' ],
1056 "field = 'value' AND field2 = 'value2'"
1059 [
'field' =>
null,
"field2 != 'value2'" ],
1061 "field IS NULL AND (field2 != 'value2')"
1064 [
'field' => [
'value',
null,
'value2' ],
'field2' =>
'value2' ],
1066 "(field IN ('value','value2') OR field IS NULL) AND field2 = 'value2'"
1069 [
'field' => [ null ],
'field2' => null ],
1071 "field IS NULL AND field2 IS NULL"
1074 [
'field' =>
'value',
'field2' =>
'value2' ],
1076 "field = 'value' OR field2 = 'value2'"
1079 [
'field' =>
'value',
'field2' => null ],
1081 "field = 'value' OR field2 IS NULL"
1084 [
'field' => [
'value',
'value2' ],
'field2' => [
'value' ] ],
1086 "field IN ('value','value2') OR field2 = 'value'"
1089 [
'field' => [
null,
'value',
null,
'value2' ],
"field2 != 'value2'" ],
1091 "(field IN ('value','value2') OR field IS NULL) OR (field2 != 'value2')"
1094 [
'field' =>
'value',
'field2' =>
'value2' ],
1096 "field = 'value',field2 = 'value2'"
1099 [
'field' =>
'value',
'field2' => null ],
1101 "field = 'value',field2 = NULL"
1104 [
'field' =>
'value',
"field2 != 'value2'" ],
1106 "field = 'value',field2 != 'value2'"
1115 $temp1 = $this->
database->tableName(
'tmp_table_1' );
1116 $temp2 = $this->
database->tableName(
'tmp_table_2' );
1117 $temp3 = $this->
database->tableName(
'tmp_table_3' );
1119 $this->
database->query(
"CREATE TEMPORARY TABLE $temp1 LIKE orig_tbl", __METHOD__ );
1120 $this->
database->query(
"CREATE TEMPORARY TABLE $temp2 LIKE orig_tbl", __METHOD__ );
1121 $this->
database->query(
"CREATE TEMPORARY TABLE $temp3 LIKE orig_tbl", __METHOD__ );
1123 $this->assertTrue( $this->
database->tableExists(
"tmp_table_1", __METHOD__ ) );
1124 $this->assertTrue( $this->
database->tableExists(
"tmp_table_2", __METHOD__ ) );
1125 $this->assertTrue( $this->
database->tableExists(
"tmp_table_3", __METHOD__ ) );
1127 $this->
database->dropTable(
'tmp_table_1', __METHOD__ );
1128 $this->
database->dropTable(
'tmp_table_2', __METHOD__ );
1129 $this->
database->dropTable(
'tmp_table_3', __METHOD__ );
1131 $this->assertFalse( $this->
database->tableExists(
"tmp_table_1", __METHOD__ ) );
1132 $this->assertFalse( $this->
database->tableExists(
"tmp_table_2", __METHOD__ ) );
1133 $this->assertFalse( $this->
database->tableExists(
"tmp_table_3", __METHOD__ ) );
1135 $this->
database->query(
"CREATE TEMPORARY TABLE tmp_table_1 LIKE orig_tbl", __METHOD__ );
1136 $this->
database->query(
"CREATE TEMPORARY TABLE 'tmp_table_2' LIKE orig_tbl", __METHOD__ );
1137 $this->
database->query(
"CREATE TEMPORARY TABLE `tmp_table_3` LIKE orig_tbl", __METHOD__ );
1139 $this->assertTrue( $this->
database->tableExists(
"tmp_table_1", __METHOD__ ) );
1140 $this->assertTrue( $this->
database->tableExists(
"tmp_table_2", __METHOD__ ) );
1141 $this->assertTrue( $this->
database->tableExists(
"tmp_table_3", __METHOD__ ) );
1143 $this->
database->query(
"DROP TEMPORARY TABLE tmp_table_1 LIKE orig_tbl", __METHOD__ );
1144 $this->
database->query(
"DROP TEMPORARY TABLE 'tmp_table_2' LIKE orig_tbl", __METHOD__ );
1145 $this->
database->query(
"DROP TABLE `tmp_table_3` LIKE orig_tbl", __METHOD__ );
1147 $this->assertFalse( $this->
database->tableExists(
"tmp_table_1", __METHOD__ ) );
1148 $this->assertFalse( $this->
database->tableExists(
"tmp_table_2", __METHOD__ ) );
1149 $this->assertFalse( $this->
database->tableExists(
"tmp_table_3", __METHOD__ ) );
static provideUnionQueries()
assertLastSqlDb( $sqlText, DatabaseTestHelper $db)
static provideNativeReplace()
testBuildConcat( $stringList, $sqlText)
provideBuildConcat Wikimedia\Rdbms\Database::buildConcat
DatabaseTestHelper $database
static provideDeleteJoin()
testUnionConditionPermutations( $params, $expect)
provideUnionConditionPermutations Wikimedia\Rdbms\Database::unionConditionPermutations
testDropTable()
Wikimedia\Rdbms\Database::dropTable.
getLastSqls()
Returns SQL queries grouped by '; ' Clear the list of queries that have been done so far.
testMakeList( $list, $mode, $sqlText)
provideMakeList Wikimedia\Rdbms\Database::makeList
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
testSessionTempTables()
Wikimedia\Rdbms\Database::registerTempTableOperation.
static provideBuildConcat()
testUnionQueries( $sql, $sqlText)
provideUnionQueries Wikimedia\Rdbms\Database::unionQueries
testTransactionCommit()
Wikimedia\Rdbms\Database::commit Wikimedia\Rdbms\Database::doCommit.
testDeleteJoin( $sql, $sqlText)
provideDeleteJoin Wikimedia\Rdbms\Database::deleteJoin
testUpsert( $sql, $sqlText)
provideUpsert Wikimedia\Rdbms\Database::upsert
testConditional( $sql, $sqlText)
provideConditional Wikimedia\Rdbms\Database::conditional
static provideUnionConditionPermutations()
testDropNonExistingTable()
Wikimedia\Rdbms\Database::dropTable.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the database
testInsert( $sql, $sqlText)
provideInsert Wikimedia\Rdbms\Database::insert Wikimedia\Rdbms\Database::makeInsertOptions
testInsertSelect( $sql, $sqlTextNative, $sqlSelect, $sqlInsert)
provideInsertSelect Wikimedia\Rdbms\Database::insertSelect Wikimedia\Rdbms\Database::nativeInsertSele...
testUpdate( $sql, $sqlText)
provideUpdate Wikimedia\Rdbms\Database::update Wikimedia\Rdbms\Database::makeUpdateOptions Wikimedia\...
testDelete( $sql, $sqlText)
provideDelete Wikimedia\Rdbms\Database::delete
testTransactionRollback()
Wikimedia\Rdbms\Database::rollback Wikimedia\Rdbms\Database::doRollback.
Helper for testing the methods from the Database class.
testReplace( $sql, $sqlText)
provideReplace Wikimedia\Rdbms\Database::replace
testNativeReplace( $sql, $sqlText)
provideNativeReplace Wikimedia\Rdbms\Database::nativeReplace
Test the parts of the Database abstract class that deal with creating SQL text.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
static provideConditional()
testBuildLike( $array, $sqlText)
provideBuildLike Wikimedia\Rdbms\Database::buildLike Wikimedia\Rdbms\Database::escapeLikeInternal
testSelect( $sql, $sqlText)
provideSelect Wikimedia\Rdbms\Database::select Wikimedia\Rdbms\Database::selectSQLText Wikimedia\Rdbm...
static provideInsertSelect()
static provideBuildLike()