PageRenderTime 51ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/MDB2/Driver/Manager/sqlite.php

https://github.com/chregu/fluxcms
PHP | 727 lines | 338 code | 62 blank | 327 comment | 59 complexity | 1656e64a5c9f32aaa9a1dca44772cdd7 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, Apache-2.0, LGPL-2.1
  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP versions 4 and 5 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox, |
  6. // | Stig. S. Bakken, Lukas Smith |
  7. // | All rights reserved. |
  8. // +----------------------------------------------------------------------+
  9. // | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
  10. // | API as well as database abstraction for PHP applications. |
  11. // | This LICENSE is in the BSD license style. |
  12. // | |
  13. // | Redistribution and use in source and binary forms, with or without |
  14. // | modification, are permitted provided that the following conditions |
  15. // | are met: |
  16. // | |
  17. // | Redistributions of source code must retain the above copyright |
  18. // | notice, this list of conditions and the following disclaimer. |
  19. // | |
  20. // | Redistributions in binary form must reproduce the above copyright |
  21. // | notice, this list of conditions and the following disclaimer in the |
  22. // | documentation and/or other materials provided with the distribution. |
  23. // | |
  24. // | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
  25. // | Lukas Smith nor the names of his contributors may be used to endorse |
  26. // | or promote products derived from this software without specific prior|
  27. // | written permission. |
  28. // | |
  29. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
  30. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
  31. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
  32. // | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
  33. // | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
  34. // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  35. // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
  36. // | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
  37. // | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
  38. // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
  39. // | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
  40. // | POSSIBILITY OF SUCH DAMAGE. |
  41. // +----------------------------------------------------------------------+
  42. // | Author: Lukas Smith <smith@pooteeweet.org> |
  43. // +----------------------------------------------------------------------+
  44. //
  45. // $Id$
  46. //
  47. require_once 'MDB2/Driver/Manager/Common.php';
  48. /**
  49. * MDB2 SQLite driver for the management modules
  50. *
  51. * @package MDB2
  52. * @category Database
  53. * @author Lukas Smith <smith@pooteeweet.org>
  54. */
  55. class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
  56. {
  57. // {{{ createDatabase()
  58. /**
  59. * create a new database
  60. *
  61. * @param string $name name of the database that should be created
  62. * @return mixed MDB2_OK on success, a MDB2 error on failure
  63. * @access public
  64. */
  65. function createDatabase($name)
  66. {
  67. $db =& $this->getDBInstance();
  68. if (PEAR::isError($db)) {
  69. return $db;
  70. }
  71. $database_file = $db->_getDatabaseFile($name);
  72. if (file_exists($database_file)) {
  73. return $db->raiseError(MDB2_ERROR_ALREADY_EXISTS, null, null,
  74. 'createDatabase: database already exists');
  75. }
  76. $php_errormsg = '';
  77. $handle = @sqlite_open($database_file, $db->dsn['mode'], $php_errormsg);
  78. if (!$handle) {
  79. return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null,
  80. 'createDatabase: '.(isset($php_errormsg) ? $php_errormsg : 'could not create the database file'));
  81. }
  82. @sqlite_close($handle);
  83. return MDB2_OK;
  84. }
  85. // }}}
  86. // {{{ dropDatabase()
  87. /**
  88. * drop an existing database
  89. *
  90. * @param string $name name of the database that should be dropped
  91. * @return mixed MDB2_OK on success, a MDB2 error on failure
  92. * @access public
  93. */
  94. function dropDatabase($name)
  95. {
  96. $db =& $this->getDBInstance();
  97. if (PEAR::isError($db)) {
  98. return $db;
  99. }
  100. $database_file = $db->_getDatabaseFile($name);
  101. if (!@file_exists($database_file)) {
  102. return $db->raiseError(MDB2_ERROR_CANNOT_DROP, null, null,
  103. 'dropDatabase: database does not exist');
  104. }
  105. $result = @unlink($database_file);
  106. if (!$result) {
  107. return $db->raiseError(MDB2_ERROR_CANNOT_DROP, null, null,
  108. 'dropDatabase: '.(isset($php_errormsg) ? $php_errormsg : 'could not remove the database file'));
  109. }
  110. return MDB2_OK;
  111. }
  112. // }}}
  113. // {{{ alterTable()
  114. /**
  115. * alter an existing table
  116. *
  117. * @param string $name name of the table that is intended to be changed.
  118. * @param array $changes associative array that contains the details of each type
  119. * of change that is intended to be performed. The types of
  120. * changes that are currently supported are defined as follows:
  121. *
  122. * name
  123. *
  124. * New name for the table.
  125. *
  126. * add
  127. *
  128. * Associative array with the names of fields to be added as
  129. * indexes of the array. The value of each entry of the array
  130. * should be set to another associative array with the properties
  131. * of the fields to be added. The properties of the fields should
  132. * be the same as defined by the Metabase parser.
  133. *
  134. *
  135. * remove
  136. *
  137. * Associative array with the names of fields to be removed as indexes
  138. * of the array. Currently the values assigned to each entry are ignored.
  139. * An empty array should be used for future compatibility.
  140. *
  141. * rename
  142. *
  143. * Associative array with the names of fields to be renamed as indexes
  144. * of the array. The value of each entry of the array should be set to
  145. * another associative array with the entry named name with the new
  146. * field name and the entry named Declaration that is expected to contain
  147. * the portion of the field declaration already in DBMS specific SQL code
  148. * as it is used in the CREATE TABLE statement.
  149. *
  150. * change
  151. *
  152. * Associative array with the names of the fields to be changed as indexes
  153. * of the array. Keep in mind that if it is intended to change either the
  154. * name of a field and any other properties, the change array entries
  155. * should have the new names of the fields as array indexes.
  156. *
  157. * The value of each entry of the array should be set to another associative
  158. * array with the properties of the fields to that are meant to be changed as
  159. * array entries. These entries should be assigned to the new values of the
  160. * respective properties. The properties of the fields should be the same
  161. * as defined by the Metabase parser.
  162. *
  163. * Example
  164. * array(
  165. * 'name' => 'userlist',
  166. * 'add' => array(
  167. * 'quota' => array(
  168. * 'type' => 'integer',
  169. * 'unsigned' => 1
  170. * )
  171. * ),
  172. * 'remove' => array(
  173. * 'file_limit' => array(),
  174. * 'time_limit' => array()
  175. * ),
  176. * 'change' => array(
  177. * 'name' => array(
  178. * 'length' => '20',
  179. * 'definition' => array(
  180. * 'type' => 'text',
  181. * 'length' => 20,
  182. * ),
  183. * )
  184. * ),
  185. * 'rename' => array(
  186. * 'sex' => array(
  187. * 'name' => 'gender',
  188. * 'definition' => array(
  189. * 'type' => 'text',
  190. * 'length' => 1,
  191. * 'default' => 'M',
  192. * ),
  193. * )
  194. * )
  195. * )
  196. *
  197. * @param boolean $check indicates whether the function should just check if the DBMS driver
  198. * can perform the requested table alterations if the value is true or
  199. * actually perform them otherwise.
  200. * @access public
  201. *
  202. * @return mixed MDB2_OK on success, a MDB2 error on failure
  203. */
  204. function alterTable($name, $changes, $check)
  205. {
  206. $db =& $this->getDBInstance();
  207. if (PEAR::isError($db)) {
  208. return $db;
  209. }
  210. // actually sqlite 2.x supports no ALTER TABLE at all ..
  211. // so the only solution is:
  212. // - reverse engineer table schema
  213. // - alter table schema in memory
  214. // - read all data into memory (or file?)
  215. // - drop table
  216. // - create table
  217. // - import data
  218. $version = $db->getServerVersion();
  219. foreach ($changes as $change_name => $change) {
  220. switch ($change_name) {
  221. case 'add':
  222. if ($version['major'] >= 3 && $version['minor'] >= 1) {
  223. break;
  224. }
  225. case 'name':
  226. if ($version['major'] >= 3 && $version['minor'] >= 1) {
  227. break;
  228. }
  229. case 'remove':
  230. case 'change':
  231. case 'rename':
  232. default:
  233. return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null,
  234. 'alterTable: change type "'.$change_name.'" not yet supported');
  235. }
  236. }
  237. if ($check) {
  238. return MDB2_OK;
  239. }
  240. $query = '';
  241. if (array_key_exists('name', $changes)) {
  242. $change_name = $db->quoteIdentifier($changes['name'], true);
  243. $query .= 'RENAME TO ' . $change_name;
  244. }
  245. if (array_key_exists('add', $changes)) {
  246. foreach ($changes['add'] as $field_name => $field) {
  247. if ($query) {
  248. $query.= ', ';
  249. }
  250. $query.= 'ADD COLUMN ' . $db->getDeclaration($field['type'], $field_name, $field);
  251. }
  252. }
  253. if (!$query) {
  254. return MDB2_OK;
  255. }
  256. $name = $db->quoteIdentifier($name, true);
  257. return $db->exec("ALTER TABLE $name $query");
  258. }
  259. // }}}
  260. // {{{ listDatabases()
  261. /**
  262. * list all databases
  263. *
  264. * @return mixed data array on success, a MDB2 error on failure
  265. * @access public
  266. */
  267. function listDatabases()
  268. {
  269. $db =& $this->getDBInstance();
  270. if (PEAR::isError($db)) {
  271. return $db;
  272. }
  273. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  274. 'listDatabases: list databases is not supported');
  275. }
  276. // }}}
  277. // {{{ listUsers()
  278. /**
  279. * list all users
  280. *
  281. * @return mixed data array on success, a MDB2 error on failure
  282. * @access public
  283. */
  284. function listUsers()
  285. {
  286. $db =& $this->getDBInstance();
  287. if (PEAR::isError($db)) {
  288. return $db;
  289. }
  290. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  291. 'listDatabases: list databases is not supported');
  292. }
  293. // }}}
  294. // {{{ listTables()
  295. /**
  296. * list all tables in the current database
  297. *
  298. * @return mixed data array on success, a MDB2 error on failure
  299. * @access public
  300. */
  301. function listTables()
  302. {
  303. $db =& $this->getDBInstance();
  304. if (PEAR::isError($db)) {
  305. return $db;
  306. }
  307. $query = "SELECT name FROM sqlite_master WHERE type='table' AND sql NOT NULL ORDER BY name";
  308. $table_names = $db->queryCol($query);
  309. if (PEAR::isError($table_names)) {
  310. return $table_names;
  311. }
  312. $result = array();
  313. foreach ($table_names as $table_name) {
  314. if (!$this->_fixSequenceName($table_name, true)) {
  315. $result[] = $table_name;
  316. }
  317. }
  318. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  319. $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
  320. }
  321. return $result;
  322. }
  323. // }}}
  324. // {{{ listTableFields()
  325. /**
  326. * list all fields in a tables in the current database
  327. *
  328. * @param string $table name of table that should be used in method
  329. * @return mixed data array on success, a MDB2 error on failure
  330. * @access public
  331. */
  332. function listTableFields($table)
  333. {
  334. $db =& $this->getDBInstance();
  335. if (PEAR::isError($db)) {
  336. return $db;
  337. }
  338. $table = $db->quoteIdentifier($table, true);
  339. $query = "SELECT * FROM $table";
  340. $db->setLimit(1);
  341. $result2 = $db->query($query);
  342. if (PEAR::isError($result2)) {
  343. return $result2;
  344. }
  345. $result = $result2->getColumnNames();
  346. $result2->free();
  347. if (PEAR::isError($result)) {
  348. return $result;
  349. }
  350. return array_flip($result);
  351. }
  352. // }}}
  353. // {{{ createIndex()
  354. /**
  355. * get the stucture of a field into an array
  356. *
  357. * @param string $table name of the table on which the index is to be created
  358. * @param string $name name of the index to be created
  359. * @param array $definition associative array that defines properties of the index to be created.
  360. * Currently, only one property named FIELDS is supported. This property
  361. * is also an associative with the names of the index fields as array
  362. * indexes. Each entry of this array is set to another type of associative
  363. * array that specifies properties of the index that are specific to
  364. * each field.
  365. *
  366. * Currently, only the sorting property is supported. It should be used
  367. * to define the sorting direction of the index. It may be set to either
  368. * ascending or descending.
  369. *
  370. * Not all DBMS support index sorting direction configuration. The DBMS
  371. * drivers of those that do not support it ignore this property. Use the
  372. * function support() to determine whether the DBMS driver can manage indexes.
  373. * Example
  374. * array(
  375. * 'fields' => array(
  376. * 'user_name' => array(
  377. * 'sorting' => 'ascending'
  378. * ),
  379. * 'last_login' => array()
  380. * )
  381. * )
  382. * @return mixed MDB2_OK on success, a MDB2 error on failure
  383. * @access public
  384. */
  385. function createIndex($table, $name, $definition)
  386. {
  387. $db =& $this->getDBInstance();
  388. if (PEAR::isError($db)) {
  389. return $db;
  390. }
  391. $table = $db->quoteIdentifier($table, true);
  392. $name = $db->getIndexName($name);
  393. $query = "CREATE INDEX $name ON $table";
  394. $fields = array();
  395. foreach ($definition['fields'] as $field_name => $field) {
  396. $field_string = $field_name;
  397. if (array_key_exists('sorting', $field)) {
  398. switch ($field['sorting']) {
  399. case 'ascending':
  400. $field_string.= ' ASC';
  401. break;
  402. case 'descending':
  403. $field_string.= ' DESC';
  404. break;
  405. }
  406. }
  407. $fields[] = $field_string;
  408. }
  409. $query .= ' ('.implode(', ', $fields) . ')';
  410. return $db->exec($query);
  411. }
  412. // }}}
  413. // {{{ dropIndex()
  414. /**
  415. * drop existing index
  416. *
  417. * @param string $table name of table that should be used in method
  418. * @param string $name name of the index to be dropped
  419. * @return mixed MDB2_OK on success, a MDB2 error on failure
  420. * @access public
  421. */
  422. function dropIndex($table, $name)
  423. {
  424. $db =& $this->getDBInstance();
  425. if (PEAR::isError($db)) {
  426. return $db;
  427. }
  428. $name = $db->getIndexName($name);
  429. return $db->exec("DROP INDEX $name");
  430. }
  431. // }}}
  432. // {{{ listTableIndexes()
  433. /**
  434. * list all indexes in a table
  435. *
  436. * @param string $table name of table that should be used in method
  437. * @return mixed data array on success, a MDB2 error on failure
  438. * @access public
  439. */
  440. function listTableIndexes($table)
  441. {
  442. $db =& $this->getDBInstance();
  443. if (PEAR::isError($db)) {
  444. return $db;
  445. }
  446. $query = "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name='$table' AND sql NOT NULL ORDER BY name";
  447. $indexes = $db->queryCol($query, 'text');
  448. if (PEAR::isError($indexes)) {
  449. return $indexes;
  450. }
  451. $result = array();
  452. foreach ($indexes as $sql) {
  453. $sql = strtolower($sql);
  454. if (preg_match("/^create index ([^ ]*) on /", $sql, $tmp)) {
  455. $result[$this->_fixIndexName($tmp[1])] = true;
  456. }
  457. }
  458. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  459. $result = array_change_key_case($result, $db->options['field_case']);
  460. }
  461. return array_keys($result);
  462. }
  463. // }}}
  464. // {{{ createConstraint()
  465. /**
  466. * create a constraint on a table
  467. *
  468. * @param string $table name of the table on which the constraint is to be created
  469. * @param string $name name of the constraint to be created
  470. * @param array $definition associative array that defines properties of the constraint to be created.
  471. * Currently, only one property named FIELDS is supported. This property
  472. * is also an associative with the names of the constraint fields as array
  473. * constraints. Each entry of this array is set to another type of associative
  474. * array that specifies properties of the constraint that are specific to
  475. * each field.
  476. *
  477. * Example
  478. * array(
  479. * 'fields' => array(
  480. * 'user_name' => array(),
  481. * 'last_login' => array()
  482. * )
  483. * )
  484. * @return mixed MDB2_OK on success, a MDB2 error on failure
  485. * @access public
  486. */
  487. function createConstraint($table, $name, $definition)
  488. {
  489. $db =& $this->getDBInstance();
  490. if (PEAR::isError($db)) {
  491. return $db;
  492. }
  493. if (array_key_exists('primary', $definition) && $definition['primary']) {
  494. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  495. 'createConstraint: Creating Primary Constraints is not supported');
  496. }
  497. $table = $db->quoteIdentifier($table, true);
  498. $name = $db->getIndexName($name);
  499. $query = "CREATE UNIQUE INDEX $name ON $table";
  500. $fields = array();
  501. foreach ($definition['fields'] as $field_name => $field) {
  502. $field_string = $field_name;
  503. if (array_key_exists('sorting', $field)) {
  504. switch ($field['sorting']) {
  505. case 'ascending':
  506. $field_string.= ' ASC';
  507. break;
  508. case 'descending':
  509. $field_string.= ' DESC';
  510. break;
  511. }
  512. }
  513. $fields[] = $field_string;
  514. }
  515. $query .= ' ('.implode(', ', $fields) . ')';
  516. return $db->exec($query);
  517. }
  518. // }}}
  519. // {{{ dropConstraint()
  520. /**
  521. * drop existing constraint
  522. *
  523. * @param string $table name of table that should be used in method
  524. * @param string $name name of the constraint to be dropped
  525. * @return mixed MDB2_OK on success, a MDB2 error on failure
  526. * @access public
  527. */
  528. function dropConstraint($table, $name)
  529. {
  530. $db =& $this->getDBInstance();
  531. if (PEAR::isError($db)) {
  532. return $db;
  533. }
  534. if ($name == 'PRIMARY') {
  535. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  536. 'dropConstraints: Dropping Primary Constraints is not supported');
  537. }
  538. $name = $db->getIndexName($name);
  539. return $db->exec("DROP INDEX $name");
  540. }
  541. // }}}
  542. // {{{ listTableConstraints()
  543. /**
  544. * list all sonstraints in a table
  545. *
  546. * @param string $table name of table that should be used in method
  547. * @return mixed data array on success, a MDB2 error on failure
  548. * @access public
  549. */
  550. function listTableConstraints($table)
  551. {
  552. $db =& $this->getDBInstance();
  553. if (PEAR::isError($db)) {
  554. return $db;
  555. }
  556. $query = "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name='$table' AND sql NOT NULL ORDER BY name";
  557. $indexes = $db->queryCol($query, 'text');
  558. if (PEAR::isError($indexes)) {
  559. return $indexes;
  560. }
  561. $result = array();
  562. foreach ($indexes as $sql) {
  563. $sql = strtolower($sql);
  564. if (preg_match("/^create unique index ([^ ]*) on /", $sql, $tmp)) {
  565. $result[$this->_fixIndexName($tmp[1])] = true;
  566. }
  567. }
  568. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  569. $result = array_change_key_case($result, $db->options['field_case']);
  570. }
  571. return array_keys($result);
  572. }
  573. // }}}
  574. // {{{ createSequence()
  575. /**
  576. * create sequence
  577. *
  578. * @param string $seq_name name of the sequence to be created
  579. * @param string $start start value of the sequence; default is 1
  580. * @return mixed MDB2_OK on success, a MDB2 error on failure
  581. * @access public
  582. */
  583. function createSequence($seq_name, $start = 1)
  584. {
  585. $db =& $this->getDBInstance();
  586. if (PEAR::isError($db)) {
  587. return $db;
  588. }
  589. $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
  590. $seqcol_name = $db->quoteIdentifier($db->options['seqcol_name'], true);
  591. $query = "CREATE TABLE $sequence_name ($seqcol_name INTEGER PRIMARY KEY DEFAULT 0 NOT NULL)";
  592. $res = $db->exec($query);
  593. if (PEAR::isError($res)) {
  594. return $res;
  595. }
  596. if ($start == 1) {
  597. return MDB2_OK;
  598. }
  599. $res = $db->exec("INSERT INTO $sequence_name ($seqcol_name) VALUES (".($start-1).')');
  600. if (!PEAR::isError($res)) {
  601. return MDB2_OK;
  602. }
  603. // Handle error
  604. $result = $db->exec("DROP TABLE $sequence_name");
  605. if (PEAR::isError($result)) {
  606. return $db->raiseError(MDB2_ERROR, null, null,
  607. 'createSequence: could not drop inconsistent sequence table ('.
  608. $result->getMessage().' ('.$result->getUserinfo().'))');
  609. }
  610. return $db->raiseError(MDB2_ERROR, null, null,
  611. 'createSequence: could not create sequence table ('.
  612. $res->getMessage().' ('.$res->getUserinfo().'))');
  613. }
  614. // }}}
  615. // {{{ dropSequence()
  616. /**
  617. * drop existing sequence
  618. *
  619. * @param string $seq_name name of the sequence to be dropped
  620. * @return mixed MDB2_OK on success, a MDB2 error on failure
  621. * @access public
  622. */
  623. function dropSequence($seq_name)
  624. {
  625. $db =& $this->getDBInstance();
  626. if (PEAR::isError($db)) {
  627. return $db;
  628. }
  629. $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
  630. return $db->exec("DROP TABLE $sequence_name");
  631. }
  632. // }}}
  633. // {{{ listSequences()
  634. /**
  635. * list all sequences in the current database
  636. *
  637. * @return mixed data array on success, a MDB2 error on failure
  638. * @access public
  639. */
  640. function listSequences()
  641. {
  642. $db =& $this->getDBInstance();
  643. if (PEAR::isError($db)) {
  644. return $db;
  645. }
  646. $query = "SELECT name FROM sqlite_master WHERE type='table' AND sql NOT NULL ORDER BY name";
  647. $table_names = $db->queryCol($query);
  648. if (PEAR::isError($table_names)) {
  649. return $table_names;
  650. }
  651. $result = array();
  652. foreach ($table_names as $table_name) {
  653. if ($sqn = $this->_fixSequenceName($table_name, true)) {
  654. $result[] = $sqn;
  655. }
  656. }
  657. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  658. $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
  659. }
  660. return $result;
  661. }
  662. // }}}
  663. }
  664. ?>