PageRenderTime 58ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/pear/MDB2/Driver/Reverse/mysqli.php

https://bitbucket.org/Yason/armory
PHP | 600 lines | 421 code | 33 blank | 146 comment | 101 complexity | 1a93d3c16c6c035089d174f1e274919e MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP versions 4 and 5 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2007 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: mysqli.php,v 1.70 2008/03/26 21:15:37 quipo Exp $
  46. //
  47. require_once 'MDB2/Driver/Reverse/Common.php';
  48. /**
  49. * MDB2 MySQLi driver for the schema reverse engineering module
  50. *
  51. * @package MDB2
  52. * @category Database
  53. * @author Lukas Smith <smith@pooteeweet.org>
  54. * @author Lorenzo Alberton <l.alberton@quipo.it>
  55. */
  56. class MDB2_Driver_Reverse_mysqli extends MDB2_Driver_Reverse_Common
  57. {
  58. /**
  59. * Array for converting MYSQLI_*_FLAG constants to text values
  60. * @var array
  61. * @access public
  62. */
  63. var $flags = array(
  64. MYSQLI_NOT_NULL_FLAG => 'not_null',
  65. MYSQLI_PRI_KEY_FLAG => 'primary_key',
  66. MYSQLI_UNIQUE_KEY_FLAG => 'unique_key',
  67. MYSQLI_MULTIPLE_KEY_FLAG => 'multiple_key',
  68. MYSQLI_BLOB_FLAG => 'blob',
  69. MYSQLI_UNSIGNED_FLAG => 'unsigned',
  70. MYSQLI_ZEROFILL_FLAG => 'zerofill',
  71. MYSQLI_AUTO_INCREMENT_FLAG => 'auto_increment',
  72. MYSQLI_TIMESTAMP_FLAG => 'timestamp',
  73. MYSQLI_SET_FLAG => 'set',
  74. // MYSQLI_NUM_FLAG => 'numeric', // unnecessary
  75. // MYSQLI_PART_KEY_FLAG => 'multiple_key', // duplicatvie
  76. MYSQLI_GROUP_FLAG => 'group_by'
  77. );
  78. /**
  79. * Array for converting MYSQLI_TYPE_* constants to text values
  80. * @var array
  81. * @access public
  82. */
  83. var $types = array(
  84. MYSQLI_TYPE_DECIMAL => 'decimal',
  85. 246 => 'decimal',
  86. MYSQLI_TYPE_TINY => 'tinyint',
  87. MYSQLI_TYPE_SHORT => 'int',
  88. MYSQLI_TYPE_LONG => 'int',
  89. MYSQLI_TYPE_FLOAT => 'float',
  90. MYSQLI_TYPE_DOUBLE => 'double',
  91. // MYSQLI_TYPE_NULL => 'DEFAULT NULL', // let flags handle it
  92. MYSQLI_TYPE_TIMESTAMP => 'timestamp',
  93. MYSQLI_TYPE_LONGLONG => 'bigint',
  94. MYSQLI_TYPE_INT24 => 'mediumint',
  95. MYSQLI_TYPE_DATE => 'date',
  96. MYSQLI_TYPE_TIME => 'time',
  97. MYSQLI_TYPE_DATETIME => 'datetime',
  98. MYSQLI_TYPE_YEAR => 'year',
  99. MYSQLI_TYPE_NEWDATE => 'date',
  100. MYSQLI_TYPE_ENUM => 'enum',
  101. MYSQLI_TYPE_SET => 'set',
  102. MYSQLI_TYPE_TINY_BLOB => 'tinyblob',
  103. MYSQLI_TYPE_MEDIUM_BLOB => 'mediumblob',
  104. MYSQLI_TYPE_LONG_BLOB => 'longblob',
  105. MYSQLI_TYPE_BLOB => 'blob',
  106. MYSQLI_TYPE_VAR_STRING => 'varchar',
  107. MYSQLI_TYPE_STRING => 'char',
  108. MYSQLI_TYPE_GEOMETRY => 'geometry',
  109. );
  110. // {{{ getTableFieldDefinition()
  111. /**
  112. * Get the structure of a field into an array
  113. *
  114. * @param string $table_name name of table that should be used in method
  115. * @param string $field_name name of field that should be used in method
  116. * @return mixed data array on success, a MDB2 error on failure
  117. * @access public
  118. */
  119. function getTableFieldDefinition($table_name, $field_name)
  120. {
  121. $db =& $this->getDBInstance();
  122. if (PEAR::isError($db)) {
  123. return $db;
  124. }
  125. $result = $db->loadModule('Datatype', null, true);
  126. if (PEAR::isError($result)) {
  127. return $result;
  128. }
  129. list($schema, $table) = $this->splitTableSchema($table_name);
  130. $table = $db->quoteIdentifier($table, true);
  131. $query = "SHOW FULL COLUMNS FROM $table LIKE ".$db->quote($field_name);
  132. $columns = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
  133. if (PEAR::isError($columns)) {
  134. return $columns;
  135. }
  136. foreach ($columns as $column) {
  137. $column = array_change_key_case($column, CASE_LOWER);
  138. $column['name'] = $column['field'];
  139. unset($column['field']);
  140. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  141. if ($db->options['field_case'] == CASE_LOWER) {
  142. $column['name'] = strtolower($column['name']);
  143. } else {
  144. $column['name'] = strtoupper($column['name']);
  145. }
  146. } else {
  147. $column = array_change_key_case($column, $db->options['field_case']);
  148. }
  149. if ($field_name == $column['name']) {
  150. $mapped_datatype = $db->datatype->mapNativeDatatype($column);
  151. if (PEAR::isError($mapped_datatype)) {
  152. return $mapped_datatype;
  153. }
  154. list($types, $length, $unsigned, $fixed) = $mapped_datatype;
  155. $notnull = false;
  156. if (empty($column['null']) || $column['null'] !== 'YES') {
  157. $notnull = true;
  158. }
  159. $default = false;
  160. if (array_key_exists('default', $column)) {
  161. $default = $column['default'];
  162. if (is_null($default) && $notnull) {
  163. $default = '';
  164. }
  165. }
  166. $autoincrement = false;
  167. if (!empty($column['extra']) && $column['extra'] == 'auto_increment') {
  168. $autoincrement = true;
  169. }
  170. $collate = null;
  171. if (!empty($column['collation'])) {
  172. $collate = $column['collation'];
  173. $charset = preg_replace('/(.+?)(_.+)?/', '$1', $collate);
  174. }
  175. $definition[0] = array(
  176. 'notnull' => $notnull,
  177. 'nativetype' => preg_replace('/^([a-z]+)[^a-z].*/i', '\\1', $column['type'])
  178. );
  179. if (!is_null($length)) {
  180. $definition[0]['length'] = $length;
  181. }
  182. if (!is_null($unsigned)) {
  183. $definition[0]['unsigned'] = $unsigned;
  184. }
  185. if (!is_null($fixed)) {
  186. $definition[0]['fixed'] = $fixed;
  187. }
  188. if ($default !== false) {
  189. $definition[0]['default'] = $default;
  190. }
  191. if ($autoincrement !== false) {
  192. $definition[0]['autoincrement'] = $autoincrement;
  193. }
  194. if (!is_null($collate)) {
  195. $definition[0]['collate'] = $collate;
  196. $definition[0]['charset'] = $charset;
  197. }
  198. foreach ($types as $key => $type) {
  199. $definition[$key] = $definition[0];
  200. if ($type == 'clob' || $type == 'blob') {
  201. unset($definition[$key]['default']);
  202. } elseif ($type == 'timestamp' && $notnull && empty($definition[$key]['default'])) {
  203. $definition[$key]['default'] = '0000-00-00 00:00:00';
  204. }
  205. $definition[$key]['type'] = $type;
  206. $definition[$key]['mdb2type'] = $type;
  207. }
  208. return $definition;
  209. }
  210. }
  211. return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
  212. 'it was not specified an existing table column', __FUNCTION__);
  213. }
  214. // }}}
  215. // {{{ getTableIndexDefinition()
  216. /**
  217. * Get the structure of an index into an array
  218. *
  219. * @param string $table_name name of table that should be used in method
  220. * @param string $index_name name of index that should be used in method
  221. * @return mixed data array on success, a MDB2 error on failure
  222. * @access public
  223. */
  224. function getTableIndexDefinition($table_name, $index_name)
  225. {
  226. $db =& $this->getDBInstance();
  227. if (PEAR::isError($db)) {
  228. return $db;
  229. }
  230. list($schema, $table) = $this->splitTableSchema($table_name);
  231. $table = $db->quoteIdentifier($table, true);
  232. $query = "SHOW INDEX FROM $table /*!50002 WHERE Key_name = %s */";
  233. $index_name_mdb2 = $db->getIndexName($index_name);
  234. $result = $db->queryRow(sprintf($query, $db->quote($index_name_mdb2)));
  235. if (!PEAR::isError($result) && !is_null($result)) {
  236. // apply 'idxname_format' only if the query succeeded, otherwise
  237. // fallback to the given $index_name, without transformation
  238. $index_name = $index_name_mdb2;
  239. }
  240. $result = $db->query(sprintf($query, $db->quote($index_name)));
  241. if (PEAR::isError($result)) {
  242. return $result;
  243. }
  244. $colpos = 1;
  245. $definition = array();
  246. while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) {
  247. $row = array_change_key_case($row, CASE_LOWER);
  248. $key_name = $row['key_name'];
  249. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  250. if ($db->options['field_case'] == CASE_LOWER) {
  251. $key_name = strtolower($key_name);
  252. } else {
  253. $key_name = strtoupper($key_name);
  254. }
  255. }
  256. if ($index_name == $key_name) {
  257. if (!$row['non_unique']) {
  258. return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
  259. $index_name . ' is not an existing table index', __FUNCTION__);
  260. }
  261. $column_name = $row['column_name'];
  262. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  263. if ($db->options['field_case'] == CASE_LOWER) {
  264. $column_name = strtolower($column_name);
  265. } else {
  266. $column_name = strtoupper($column_name);
  267. }
  268. }
  269. $definition['fields'][$column_name] = array(
  270. 'position' => $colpos++
  271. );
  272. if (!empty($row['collation'])) {
  273. $definition['fields'][$column_name]['sorting'] = ($row['collation'] == 'A'
  274. ? 'ascending' : 'descending');
  275. }
  276. }
  277. }
  278. $result->free();
  279. if (empty($definition['fields'])) {
  280. return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
  281. $index_name . ' is not an existing table index', __FUNCTION__);
  282. }
  283. return $definition;
  284. }
  285. // }}}
  286. // {{{ getTableConstraintDefinition()
  287. /**
  288. * Get the structure of a constraint into an array
  289. *
  290. * @param string $table_name name of table that should be used in method
  291. * @param string $constraint_name name of constraint that should be used in method
  292. * @return mixed data array on success, a MDB2 error on failure
  293. * @access public
  294. */
  295. function getTableConstraintDefinition($table_name, $constraint_name)
  296. {
  297. $db =& $this->getDBInstance();
  298. if (PEAR::isError($db)) {
  299. return $db;
  300. }
  301. list($schema, $table) = $this->splitTableSchema($table_name);
  302. $constraint_name_original = $constraint_name;
  303. $table = $db->quoteIdentifier($table, true);
  304. $query = "SHOW INDEX FROM $table /*!50002 WHERE Key_name = %s */";
  305. if (strtolower($constraint_name) != 'primary') {
  306. $constraint_name_mdb2 = $db->getIndexName($constraint_name);
  307. $result = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2)));
  308. if (!PEAR::isError($result) && !is_null($result)) {
  309. // apply 'idxname_format' only if the query succeeded, otherwise
  310. // fallback to the given $index_name, without transformation
  311. $constraint_name = $constraint_name_mdb2;
  312. }
  313. }
  314. $result = $db->query(sprintf($query, $db->quote($constraint_name)));
  315. if (PEAR::isError($result)) {
  316. return $result;
  317. }
  318. $colpos = 1;
  319. //default values, eventually overridden
  320. $definition = array(
  321. 'primary' => false,
  322. 'unique' => false,
  323. 'foreign' => false,
  324. 'check' => false,
  325. 'fields' => array(),
  326. 'references' => array(
  327. 'table' => '',
  328. 'fields' => array(),
  329. ),
  330. 'onupdate' => '',
  331. 'ondelete' => '',
  332. 'match' => '',
  333. 'deferrable' => false,
  334. 'initiallydeferred' => false,
  335. );
  336. while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) {
  337. $row = array_change_key_case($row, CASE_LOWER);
  338. $key_name = $row['key_name'];
  339. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  340. if ($db->options['field_case'] == CASE_LOWER) {
  341. $key_name = strtolower($key_name);
  342. } else {
  343. $key_name = strtoupper($key_name);
  344. }
  345. }
  346. if ($constraint_name == $key_name) {
  347. if ($row['non_unique']) {
  348. //FOREIGN KEY?
  349. return $this->_getTableFKConstraintDefinition($table, $constraint_name_original, $definition);
  350. }
  351. if ($row['key_name'] == 'PRIMARY') {
  352. $definition['primary'] = true;
  353. } elseif (!$row['non_unique']) {
  354. $definition['unique'] = true;
  355. }
  356. $column_name = $row['column_name'];
  357. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  358. if ($db->options['field_case'] == CASE_LOWER) {
  359. $column_name = strtolower($column_name);
  360. } else {
  361. $column_name = strtoupper($column_name);
  362. }
  363. }
  364. $definition['fields'][$column_name] = array(
  365. 'position' => $colpos++
  366. );
  367. if (!empty($row['collation'])) {
  368. $definition['fields'][$column_name]['sorting'] = ($row['collation'] == 'A'
  369. ? 'ascending' : 'descending');
  370. }
  371. }
  372. }
  373. $result->free();
  374. if (empty($definition['fields'])) {
  375. return $this->_getTableFKConstraintDefinition($table, $constraint_name_original, $definition);
  376. }
  377. return $definition;
  378. }
  379. // }}}
  380. // {{{ _getTableFKConstraintDefinition()
  381. /**
  382. * Get the FK definition from the CREATE TABLE statement
  383. *
  384. * @param string $table table name
  385. * @param string $constraint_name constraint name
  386. * @param array $definition default values for constraint definition
  387. *
  388. * @return array|PEAR_Error
  389. * @access private
  390. */
  391. function _getTableFKConstraintDefinition($table, $constraint_name, $definition)
  392. {
  393. $db =& $this->getDBInstance();
  394. if (PEAR::isError($db)) {
  395. return $db;
  396. }
  397. $query = 'SHOW CREATE TABLE '. $db->escape($table);
  398. $constraint = $db->queryOne($query, 'text', 1);
  399. if (!PEAR::isError($constraint) && !empty($constraint)) {
  400. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  401. if ($db->options['field_case'] == CASE_LOWER) {
  402. $constraint = strtolower($constraint);
  403. } else {
  404. $constraint = strtoupper($constraint);
  405. }
  406. }
  407. $constraint_name_original = $constraint_name;
  408. $constraint_name = $db->getIndexName($constraint_name);
  409. $pattern = '/\bCONSTRAINT\s+'.$constraint_name.'\s+FOREIGN KEY\s+\(([^\)]+)\) \bREFERENCES\b ([^ ]+) \(([^\)]+)\)/i';
  410. if (!preg_match($pattern, str_replace('`', '', $constraint), $matches)) {
  411. //fallback to original constraint name
  412. $pattern = '/\bCONSTRAINT\s+'.$constraint_name_original.'\s+FOREIGN KEY\s+\(([^\)]+)\) \bREFERENCES\b ([^ ]+) \(([^\)]+)\)/i';
  413. }
  414. if (preg_match($pattern, str_replace('`', '', $constraint), $matches)) {
  415. $definition['foreign'] = true;
  416. $column_names = explode(',', $matches[1]);
  417. $referenced_cols = explode(',', $matches[3]);
  418. $definition['references'] = array(
  419. 'table' => $matches[2],
  420. 'fields' => array(),
  421. );
  422. $colpos = 1;
  423. foreach ($column_names as $column_name) {
  424. $definition['fields'][trim($column_name)] = array(
  425. 'position' => $colpos++
  426. );
  427. }
  428. $colpos = 1;
  429. foreach ($referenced_cols as $column_name) {
  430. $definition['references']['fields'][trim($column_name)] = array(
  431. 'position' => $colpos++
  432. );
  433. }
  434. $definition['onupdate'] = 'NO ACTION';
  435. $definition['ondelete'] = 'NO ACTION';
  436. $definition['match'] = 'SIMPLE';
  437. return $definition;
  438. }
  439. }
  440. return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
  441. $constraint_name . ' is not an existing table constraint', __FUNCTION__);
  442. }
  443. // }}}
  444. // {{{ getTriggerDefinition()
  445. /**
  446. * Get the structure of a trigger into an array
  447. *
  448. * EXPERIMENTAL
  449. *
  450. * WARNING: this function is experimental and may change the returned value
  451. * at any time until labelled as non-experimental
  452. *
  453. * @param string $trigger name of trigger that should be used in method
  454. * @return mixed data array on success, a MDB2 error on failure
  455. * @access public
  456. */
  457. function getTriggerDefinition($trigger)
  458. {
  459. $db =& $this->getDBInstance();
  460. if (PEAR::isError($db)) {
  461. return $db;
  462. }
  463. $query = 'SELECT trigger_name,
  464. event_object_table AS table_name,
  465. action_statement AS trigger_body,
  466. action_timing AS trigger_type,
  467. event_manipulation AS trigger_event
  468. FROM information_schema.triggers
  469. WHERE trigger_name = '. $db->quote($trigger, 'text');
  470. $types = array(
  471. 'trigger_name' => 'text',
  472. 'table_name' => 'text',
  473. 'trigger_body' => 'text',
  474. 'trigger_type' => 'text',
  475. 'trigger_event' => 'text',
  476. );
  477. $def = $db->queryRow($query, $types, MDB2_FETCHMODE_ASSOC);
  478. if (PEAR::isError($def)) {
  479. return $def;
  480. }
  481. $def['trigger_comment'] = '';
  482. $def['trigger_enabled'] = true;
  483. return $def;
  484. }
  485. // }}}
  486. // {{{ tableInfo()
  487. /**
  488. * Returns information about a table or a result set
  489. *
  490. * @param object|string $result MDB2_result object from a query or a
  491. * string containing the name of a table.
  492. * While this also accepts a query result
  493. * resource identifier, this behavior is
  494. * deprecated.
  495. * @param int $mode a valid tableInfo mode
  496. *
  497. * @return array an associative array with the information requested.
  498. * A MDB2_Error object on failure.
  499. *
  500. * @see MDB2_Driver_Common::setOption()
  501. */
  502. function tableInfo($result, $mode = null)
  503. {
  504. if (is_string($result)) {
  505. return parent::tableInfo($result, $mode);
  506. }
  507. $db =& $this->getDBInstance();
  508. if (PEAR::isError($db)) {
  509. return $db;
  510. }
  511. $resource = MDB2::isResultCommon($result) ? $result->getResource() : $result;
  512. if (!is_object($resource)) {
  513. return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
  514. 'Could not generate result resource', __FUNCTION__);
  515. }
  516. if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
  517. if ($db->options['field_case'] == CASE_LOWER) {
  518. $case_func = 'strtolower';
  519. } else {
  520. $case_func = 'strtoupper';
  521. }
  522. } else {
  523. $case_func = 'strval';
  524. }
  525. $count = @mysqli_num_fields($resource);
  526. $res = array();
  527. if ($mode) {
  528. $res['num_fields'] = $count;
  529. }
  530. $db->loadModule('Datatype', null, true);
  531. for ($i = 0; $i < $count; $i++) {
  532. $tmp = @mysqli_fetch_field($resource);
  533. $flags = '';
  534. foreach ($this->flags as $const => $means) {
  535. if ($tmp->flags & $const) {
  536. $flags.= $means . ' ';
  537. }
  538. }
  539. if ($tmp->def) {
  540. $flags.= 'default_' . rawurlencode($tmp->def);
  541. }
  542. $flags = trim($flags);
  543. $res[$i] = array(
  544. 'table' => $case_func($tmp->table),
  545. 'name' => $case_func($tmp->name),
  546. 'type' => isset($this->types[$tmp->type])
  547. ? $this->types[$tmp->type] : 'unknown',
  548. // http://bugs.php.net/?id=36579
  549. 'length' => $tmp->length,
  550. 'flags' => $flags,
  551. );
  552. $mdb2type_info = $db->datatype->mapNativeDatatype($res[$i]);
  553. if (PEAR::isError($mdb2type_info)) {
  554. return $mdb2type_info;
  555. }
  556. $res[$i]['mdb2type'] = $mdb2type_info[0][0];
  557. if ($mode & MDB2_TABLEINFO_ORDER) {
  558. $res['order'][$res[$i]['name']] = $i;
  559. }
  560. if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
  561. $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
  562. }
  563. }
  564. return $res;
  565. }
  566. }
  567. ?>