DatabaseNo.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <?php
  2. /**
  3. * Copyright (C) 2008, 2009 Michael Nowak
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. **/
  20. class DatabaseNo extends Database
  21. {
  22. static $instance;
  23. static function getInstance() {
  24. if ( !isset( self::$instance ) ) {
  25. self::$instance = new self();
  26. }
  27. return self::$instance;
  28. }
  29. #------------------------------------------------------------------------------
  30. # Accessors
  31. #------------------------------------------------------------------------------
  32. function failFunction( $function = NULL ) {
  33. return null;
  34. }
  35. function setOutputPage( $out ) {
  36. return null;
  37. }
  38. function debug( $debug = NULL ) {
  39. return null;
  40. }
  41. function bufferResults( $buffer = NULL ) {
  42. return null;
  43. }
  44. function ignoreErrors( $ignoreErrors = NULL ) {
  45. return true;
  46. }
  47. function trxLevel( $level = NULL ) {
  48. return 0;
  49. }
  50. function errorCount( $count = NULL ) {
  51. return 0;
  52. }
  53. function getLBInfo( $name = NULL ) {
  54. return true;
  55. }
  56. function setLBInfo( $name, $value = NULL ) {
  57. return true;
  58. }
  59. function cascadingDeletes() {
  60. return false;
  61. }
  62. function cleanupTriggers() {
  63. return false;
  64. }
  65. function strictIPs() {
  66. return false;
  67. }
  68. function realTimestamps() {
  69. return false;
  70. }
  71. function implicitGroupby() {
  72. return true;
  73. }
  74. function implicitOrderby() {
  75. return true;
  76. }
  77. function searchableIPs() {
  78. return false;
  79. }
  80. function functionalIndexes() {
  81. return false;
  82. }
  83. function lastQuery() {
  84. return true;
  85. }
  86. function isOpen() {
  87. return true;
  88. }
  89. function setFlag( $flag ) {
  90. return true;
  91. }
  92. function clearFlag( $flag ) {
  93. return true;
  94. }
  95. function getFlag( $flag ) {
  96. return true;
  97. }
  98. function getProperty( $name ) {
  99. return true;
  100. }
  101. function __construct( $server = false, $user = false, $password = false, $dbName = false,
  102. $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) {
  103. null;
  104. }
  105. static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 ) {
  106. return new Database( $server, $user, $password, $dbName, $failFunction, $flags );
  107. }
  108. function open( $server, $user, $password, $dbName ) {
  109. return true;
  110. }
  111. function close() {
  112. return true;
  113. }
  114. function reportConnectionError( $error = 'Unknown error' ) {
  115. return null;
  116. }
  117. public function query( $sql, $fname = '', $tempIgnore = false ) {
  118. return null;
  119. }
  120. function doQuery( $sql ) {
  121. return true;
  122. }
  123. function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
  124. return null;
  125. }
  126. function prepare( $sql, $func = 'Database::prepare' ) {
  127. return null;
  128. }
  129. function freePrepared( $prepared ) {
  130. return null;
  131. }
  132. function execute( $prepared, $args = null ) {
  133. return true;
  134. }
  135. function safeQuery( $query, $args = null ) {
  136. return true;
  137. }
  138. function fillPrepared( $preparedQuery, $args ) {
  139. return true;
  140. }
  141. function fillPreparedArg( $matches ) {
  142. return true;
  143. }
  144. function freeResult( $res ) {
  145. return null;
  146. }
  147. function fetchObject( $res ) {
  148. return null;
  149. }
  150. function fetchRow( $res ) {
  151. return null;
  152. }
  153. function numRows( $res ) {
  154. return 0;
  155. }
  156. function numFields( $res ) {
  157. return 0;
  158. }
  159. function fieldName( $res, $n ) {
  160. return true;
  161. }
  162. function insertId() {
  163. return null;
  164. }
  165. function dataSeek( $res, $row ) {
  166. return true;
  167. }
  168. function lastErrno() {
  169. return null;
  170. }
  171. function lastError() {
  172. return null;
  173. }
  174. function affectedRows() {
  175. return 0;
  176. }
  177. function set( $table, $var, $value, $cond, $fname = 'Database::set' ) {
  178. return null;
  179. }
  180. function selectField( $table, $var, $cond='', $fname = 'Database::selectField', $options = array() ) {
  181. return null;
  182. }
  183. function makeSelectOptions( $options ) {
  184. return null;
  185. }
  186. /*
  187. function select( $table, $vars, $conds='', $fname = 'Database::select', $options = array() ) {
  188. if ( $this->isWriteQuery( $sql ) ) {
  189. return null;
  190. } else {
  191. return new ResultWrapper ( $this , null );
  192. }
  193. }
  194. */
  195. function selectRow( $table, $vars, $conds, $fname = 'Database::selectRow', $options = array() ) {
  196. return null;
  197. }
  198. function estimateRowCount( $table, $vars='*', $conds='', $fname = 'Database::estimateRowCount', $options = array() ) {
  199. return 0;
  200. }
  201. static function generalizeSQL( $sql ) {
  202. return null;
  203. }
  204. function fieldExists( $table, $field, $fname = 'Database::fieldExists' ) {
  205. return null;
  206. }
  207. function indexExists( $table, $index, $fname = 'Database::indexExists' ) {
  208. return null;
  209. }
  210. function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) {
  211. return null;
  212. }
  213. function tableExists( $table ) {
  214. return null;
  215. }
  216. function fieldInfo( $table, $field ) {
  217. return null;
  218. }
  219. function fieldType( $res, $index ) {
  220. return null;
  221. }
  222. function indexUnique( $table, $index ) {
  223. return null;
  224. }
  225. function insert( $table, $a, $fname = 'Database::insert', $options = array() ) {
  226. return null;
  227. }
  228. function makeUpdateOptions( $options ) {
  229. return null;
  230. }
  231. function update( $table, $values, $conds, $fname = 'Database::update', $options = array() ) {
  232. return null;
  233. }
  234. function makeList( $a, $mode = LIST_COMMA ) {
  235. return null;
  236. }
  237. function selectDB( $db ) {
  238. return null;
  239. }
  240. function tableName( $name ) {
  241. return null;
  242. }
  243. public function tableNames() {
  244. return null;
  245. }
  246. public function tableNamesN() {
  247. return null;
  248. }
  249. function tableNamesWithUseIndex( $tables, $use_index ) {
  250. return null;
  251. }
  252. function strencode( $s ) {
  253. return true;
  254. }
  255. function addQuotes( $s ) {
  256. return true;
  257. }
  258. function escapeLike( $s ) {
  259. return true;
  260. }
  261. function nextSequenceValue( $seqName ) {
  262. return null;
  263. }
  264. function useIndexClause( $index ) {
  265. return true;
  266. }
  267. function replace( $table, $uniqueIndexes, $rows, $fname = 'Database::replace' ) {
  268. return null;
  269. }
  270. function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = 'Database::deleteJoin' ) {
  271. return null;
  272. }
  273. function textFieldSize( $table, $field ) {
  274. return null;
  275. }
  276. function lowPriorityOption() {
  277. }
  278. function delete( $table, $conds, $fname = 'Database::delete' ) {
  279. return true;
  280. }
  281. function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect',
  282. $insertOptions = array(), $selectOptions = array() )
  283. {
  284. return null;
  285. }
  286. function limitResult($sql, $limit, $offset=false) {
  287. return null;
  288. }
  289. function limitResultForUpdate($sql, $num) {
  290. return null;
  291. }
  292. function conditional( $cond, $trueVal, $falseVal ) {
  293. return null;
  294. }
  295. function wasDeadlock() {
  296. return null;
  297. }
  298. function deadlockLoop() {
  299. return null;
  300. }
  301. function masterPosWait( $file, $pos, $timeout ) {
  302. return null;
  303. }
  304. function getSlavePos() {
  305. return null;
  306. }
  307. function getMasterPos() {
  308. return null;
  309. }
  310. function begin( $fname = 'Database::begin' ) {
  311. }
  312. function commit( $fname = 'Database::commit' ) {
  313. }
  314. function rollback( $fname = 'Database::rollback' ) {
  315. }
  316. function immediateBegin( $fname = 'Database::immediateBegin' ) {
  317. }
  318. function immediateCommit( $fname = 'Database::immediateCommit' ) {
  319. }
  320. function timestamp( $ts=0 ) {
  321. }
  322. function timestampOrNull( $ts = null ) {
  323. }
  324. function resultObject( $result ) {
  325. }
  326. function aggregateValue ($valuedata,$valuename='value') {
  327. }
  328. function getSoftwareLink() {
  329. return "[http://www.mysql.com/ MySQL]";
  330. }
  331. function getServerVersion() {
  332. }
  333. function ping() {
  334. return true;
  335. }
  336. function getLag() {
  337. return 0;
  338. }
  339. function getStatus($which="%") {
  340. return true;
  341. }
  342. function maxListLen() {
  343. return 0;
  344. }
  345. function encodeBlob($b) {
  346. return $b;
  347. }
  348. function decodeBlob($b) {
  349. return $b;
  350. }
  351. public function setTimeout( $timeout ) {
  352. }
  353. function sourceFile( $filename, $lineCallback = false, $resultCallback = false ) {
  354. return null;
  355. }
  356. function sourceStream( $fp, $lineCallback = false, $resultCallback = false ) {
  357. return true;
  358. }
  359. protected function replaceVars( $ins ) {
  360. return true;
  361. }
  362. protected function tableNameCallback( $matches ) {
  363. }
  364. /*
  365. * Build a concatenation list to feed into a SQL query
  366. */
  367. function buildConcat( $stringList ) {
  368. return true;
  369. }
  370. }
  371. /**
  372. * Disable all types of databases (excluding Mysql) by replacing they classes with this one
  373. **/
  374. class DatabaseIbm_db2 extends DatabaseNo
  375. {}
  376. class DatabaseOracle extends DatabaseNo
  377. {}
  378. class DatabasePostgres extends DatabaseNo
  379. {}
  380. class DatabaseMssql extends DatabaseNo
  381. {}
  382. class DatabaseSqlite extends DatabaseNo
  383. {}