DBIDrizzle.class.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Interface to the Drizzle extension
  5. *
  6. * WARNING - EXPERIMENTAL, never use in production,
  7. * drizzle module segfaults often and when you least expect it to
  8. *
  9. * TODO: This file and drizzle-wrappers.lib.php should be devoid
  10. * of any segault related hacks.
  11. * TODO: Crashing versions of drizzle module and/or libdrizzle
  12. * should be blacklisted
  13. *
  14. * @package PhpMyAdmin-DBI
  15. * @subpackage Drizzle
  16. */
  17. if (! defined('PHPMYADMIN')) {
  18. exit;
  19. }
  20. require_once './libraries/logging.lib.php';
  21. require_once './libraries/dbi/drizzle-wrappers.lib.php';
  22. require_once './libraries/dbi/DBIExtension.int.php';
  23. /**
  24. * MySQL client API
  25. */
  26. if (! defined('PMA_MYSQL_CLIENT_API')) {
  27. define('PMA_MYSQL_CLIENT_API', (int)drizzle_version());
  28. }
  29. /**
  30. * Interface to the Drizzle extension
  31. *
  32. * @package PhpMyAdmin-DBI
  33. * @subpackage Drizzle
  34. */
  35. class PMA_DBI_Drizzle implements PMA_DBI_Extension
  36. {
  37. /**
  38. * Helper function for connecting to the database server
  39. *
  40. * @param PMA_Drizzle $drizzle connection handle
  41. * @param string $host Drizzle host
  42. * @param integer $port Drizzle port
  43. * @param string $uds server socket
  44. * @param string $user username
  45. * @param string $password password
  46. * @param string $db database name
  47. * @param integer $options connection options
  48. *
  49. * @return PMA_DrizzleCon
  50. */
  51. private function _realConnect($drizzle, $host, $port, $uds, $user, $password,
  52. $db = null, $options = 0
  53. ) {
  54. if ($uds) {
  55. $con = $drizzle->addUds($uds, $user, $password, $db, $options);
  56. } else {
  57. $con = $drizzle->addTcp($host, $port, $user, $password, $db, $options);
  58. }
  59. return $con;
  60. }
  61. /**
  62. * connects to the database server
  63. *
  64. * @param string $user drizzle user name
  65. * @param string $password drizzle user password
  66. * @param bool $is_controluser whether this is a control user connection
  67. * @param array $server host/port/socket/persistent
  68. * @param bool $auxiliary_connection (when true, don't go back to login if
  69. * connection fails)
  70. *
  71. * @return mixed false on error or a mysqli object on success
  72. */
  73. public function connect($user, $password, $is_controluser = false,
  74. $server = null, $auxiliary_connection = false
  75. ) {
  76. global $cfg;
  77. if ($server) {
  78. $server_port = (empty($server['port']))
  79. ? false
  80. : (int)$server['port'];
  81. $server_socket = (empty($server['socket']))
  82. ? ''
  83. : $server['socket'];
  84. $server['host'] = (empty($server['host']))
  85. ? 'localhost'
  86. : $server['host'];
  87. } else {
  88. $server_port = (empty($cfg['Server']['port']))
  89. ? false
  90. : (int) $cfg['Server']['port'];
  91. $server_socket = (empty($cfg['Server']['socket']))
  92. ? null
  93. : $cfg['Server']['socket'];
  94. }
  95. if (strtolower($GLOBALS['cfg']['Server']['connect_type']) == 'tcp') {
  96. $GLOBALS['cfg']['Server']['socket'] = '';
  97. }
  98. $drizzle = new PMA_Drizzle();
  99. $client_flags = 0;
  100. /* Optionally compress connection */
  101. if ($GLOBALS['cfg']['Server']['compress']) {
  102. $client_flags |= DRIZZLE_CAPABILITIES_COMPRESS;
  103. }
  104. /* Optionally enable SSL */
  105. if ($GLOBALS['cfg']['Server']['ssl']) {
  106. $client_flags |= DRIZZLE_CAPABILITIES_SSL;
  107. }
  108. if (! $server) {
  109. $link = @$this->_realConnect(
  110. $drizzle, $cfg['Server']['host'],
  111. $server_port, $server_socket, $user,
  112. $password, false, $client_flags
  113. );
  114. // Retry with empty password if we're allowed to
  115. if ($link == false && isset($cfg['Server']['nopassword'])
  116. && $cfg['Server']['nopassword'] && ! $is_controluser
  117. ) {
  118. $link = @$this->_realConnect(
  119. $drizzle, $cfg['Server']['host'], $server_port, $server_socket,
  120. $user, null, false, $client_flags
  121. );
  122. }
  123. } else {
  124. $link = @$this->_realConnect(
  125. $drizzle, $server['host'], $server_port, $server_socket,
  126. $user, $password
  127. );
  128. }
  129. if ($link != false) {
  130. $GLOBALS['dbi']->postConnect($link, $is_controluser);
  131. return $link;
  132. }
  133. if ($is_controluser) {
  134. trigger_error(
  135. __(
  136. 'Connection for controluser as defined'
  137. . ' in your configuration failed.'
  138. ),
  139. E_USER_WARNING
  140. );
  141. return false;
  142. }
  143. // we could be calling $GLOBALS['dbi']->connect() to connect to another
  144. // server, for example in the Synchronize feature, so do not
  145. // go back to main login if it fails
  146. if ($auxiliary_connection) {
  147. return false;
  148. }
  149. PMA_logUser($user, 'drizzle-denied');
  150. global $auth_plugin;
  151. $auth_plugin->authFails();
  152. return $link;
  153. }
  154. /**
  155. * selects given database
  156. *
  157. * @param string $dbname database name to select
  158. * @param PMA_DrizzleCom $link connection object
  159. *
  160. * @return bool
  161. */
  162. public function selectDb($dbname, $link = null)
  163. {
  164. if (empty($link)) {
  165. if (isset($GLOBALS['userlink'])) {
  166. $link = $GLOBALS['userlink'];
  167. } else {
  168. return false;
  169. }
  170. }
  171. return $link->selectDb($dbname);
  172. }
  173. /**
  174. * runs a query and returns the result
  175. *
  176. * @param string $query query to execute
  177. * @param PMA_DrizzleCon $link connection object
  178. * @param int $options query options
  179. *
  180. * @return PMA_DrizzleResult
  181. */
  182. public function realQuery($query, $link, $options)
  183. {
  184. $buffer_mode = $options & PMA_DatabaseInterface::QUERY_UNBUFFERED
  185. ? PMA_Drizzle::BUFFER_ROW
  186. : PMA_Drizzle::BUFFER_RESULT;
  187. $res = $link->query($query, $buffer_mode);
  188. return $res;
  189. }
  190. /**
  191. * Run the multi query and output the results
  192. *
  193. * @param object $link connection object
  194. * @param string $query multi query statement to execute
  195. *
  196. * @return result collection | boolean(false)
  197. */
  198. public function realMultiQuery($link, $query)
  199. {
  200. return false;
  201. }
  202. /**
  203. * returns array of rows with associative and numeric keys from $result
  204. *
  205. * @param PMA_DrizzleResult $result Drizzle result object
  206. *
  207. * @return array
  208. */
  209. public function fetchArray($result)
  210. {
  211. return $result->fetchRow(PMA_Drizzle::FETCH_BOTH);
  212. }
  213. /**
  214. * returns array of rows with associative keys from $result
  215. *
  216. * @param PMA_DrizzleResult $result Drizzle result object
  217. *
  218. * @return array
  219. */
  220. public function fetchAssoc($result)
  221. {
  222. return $result->fetchRow(PMA_Drizzle::FETCH_ASSOC);
  223. }
  224. /**
  225. * returns array of rows with numeric keys from $result
  226. *
  227. * @param PMA_DrizzleResult $result Drizzle result object
  228. *
  229. * @return array
  230. */
  231. public function fetchRow($result)
  232. {
  233. return $result->fetchRow(PMA_Drizzle::FETCH_NUM);
  234. }
  235. /**
  236. * Adjusts the result pointer to an arbitrary row in the result
  237. *
  238. * @param PMA_DrizzleResult $result Drizzle result object
  239. * @param int $offset offset to seek
  240. *
  241. * @return boolean true on success, false on failure
  242. */
  243. public function dataSeek($result, $offset)
  244. {
  245. return $result->seek($offset);
  246. }
  247. /**
  248. * Frees memory associated with the result
  249. *
  250. * @param PMA_DrizzleResult $result database result
  251. *
  252. * @return void
  253. */
  254. public function freeResult($result)
  255. {
  256. if ($result instanceof PMA_DrizzleResult) {
  257. $result->free();
  258. }
  259. }
  260. /**
  261. * Check if there are any more query results from a multi query
  262. *
  263. * @param object $link the connection object
  264. *
  265. * @return bool false
  266. */
  267. public function moreResults($link = null)
  268. {
  269. // N.B.: PHP's 'mysql' extension does not support
  270. // multi_queries so this function will always
  271. // return false. Use the 'mysqli' extension, if
  272. // you need support for multi_queries.
  273. return false;
  274. }
  275. /**
  276. * Prepare next result from multi_query
  277. *
  278. * @param object $link the connection object
  279. *
  280. * @return bool false
  281. */
  282. public function nextResult($link = null)
  283. {
  284. // N.B.: PHP's 'mysql' extension does not support
  285. // multi_queries so this function will always
  286. // return false. Use the 'mysqli' extension, if
  287. // you need support for multi_queries.
  288. return false;
  289. }
  290. /**
  291. * Returns a string representing the type of connection used
  292. *
  293. * @param PMA_DrizzleCon $link connection object
  294. *
  295. * @return string type of connection used
  296. */
  297. public function getHostInfo($link = null)
  298. {
  299. if (null === $link) {
  300. if (isset($GLOBALS['userlink'])) {
  301. $link = $GLOBALS['userlink'];
  302. } else {
  303. return false;
  304. }
  305. }
  306. $str = $link->port()
  307. ? $link->host() . ':' . $link->port() . ' via TCP/IP'
  308. : 'Localhost via UNIX socket';
  309. return $str;
  310. }
  311. /**
  312. * Returns the version of the Drizzle protocol used
  313. *
  314. * @param PMA_DrizzleCon $link connection object
  315. *
  316. * @return int version of the Drizzle protocol used
  317. */
  318. public function getProtoInfo($link = null)
  319. {
  320. if (null === $link) {
  321. if (isset($GLOBALS['userlink'])) {
  322. $link = $GLOBALS['userlink'];
  323. } else {
  324. return false;
  325. }
  326. }
  327. return $link->protocolVersion();
  328. }
  329. /**
  330. * returns a string that represents the client library version
  331. *
  332. * @return string Drizzle client library version
  333. */
  334. public function getClientInfo()
  335. {
  336. return 'libdrizzle (Drizzle ' . drizzle_version() . ')';
  337. }
  338. /**
  339. * returns last error message or false if no errors occurred
  340. *
  341. * @param PMA_DrizzleCon $link connection object
  342. *
  343. * @return string|bool $error or false
  344. */
  345. public function getError($link = null)
  346. {
  347. $GLOBALS['errno'] = 0;
  348. /* Treat false same as null because of controllink */
  349. if ($link === false) {
  350. $link = null;
  351. }
  352. if (null === $link && isset($GLOBALS['userlink'])) {
  353. $link =& $GLOBALS['userlink'];
  354. // Do not stop now. We still can get the error code
  355. // with mysqli_connect_errno()
  356. // } else {
  357. // return false;
  358. }
  359. if (null !== $link) {
  360. $error_number = drizzle_con_errno($link->getConnectionObject());
  361. $error_message = drizzle_con_error($link->getConnectionObject());
  362. } else {
  363. $error_number = drizzle_errno();
  364. $error_message = drizzle_error();
  365. }
  366. if (0 == $error_number) {
  367. return false;
  368. }
  369. // keep the error number for further check after
  370. // the call to getError()
  371. $GLOBALS['errno'] = $error_number;
  372. return $GLOBALS['dbi']->formatError($error_number, $error_message);
  373. }
  374. /**
  375. * returns the number of rows returned by last query
  376. *
  377. * @param PMA_DrizzleResult $result Drizzle result object
  378. *
  379. * @return string|int
  380. */
  381. public function numRows($result)
  382. {
  383. // see the note for $GLOBALS['dbi']->tryQuery();
  384. if (!is_bool($result)) {
  385. return @$result->numRows();
  386. } else {
  387. return 0;
  388. }
  389. }
  390. /**
  391. * returns last inserted auto_increment id for given $link
  392. * or $GLOBALS['userlink']
  393. *
  394. * @param PMA_DrizzleCon $link connection object
  395. *
  396. * @return string|int
  397. */
  398. public function insertId($link = null)
  399. {
  400. if (empty($link)) {
  401. if (isset($GLOBALS['userlink'])) {
  402. $link = $GLOBALS['userlink'];
  403. } else {
  404. return false;
  405. }
  406. }
  407. // copied from mysql and mysqli
  408. // When no controluser is defined, using mysqli_insert_id($link)
  409. // does not always return the last insert id due to a mixup with
  410. // the tracking mechanism, but this works:
  411. return $GLOBALS['dbi']->fetchValue('SELECT LAST_INSERT_ID();', 0, 0, $link);
  412. // Curiously, this problem does not happen with the mysql extension but
  413. // there is another problem with BIGINT primary keys so insertId()
  414. // in the mysql extension also uses this logic.
  415. }
  416. /**
  417. * returns the number of rows affected by last query
  418. *
  419. * @param PMA_DrizzleResult $link connection object
  420. * @param bool $get_from_cache whether to retrieve from cache
  421. *
  422. * @return string|int
  423. */
  424. public function affectedRows($link = null, $get_from_cache = true)
  425. {
  426. if (empty($link)) {
  427. if (isset($GLOBALS['userlink'])) {
  428. $link = $GLOBALS['userlink'];
  429. } else {
  430. return false;
  431. }
  432. }
  433. if ($get_from_cache) {
  434. return $GLOBALS['cached_affected_rows'];
  435. } else {
  436. return $link->affectedRows();
  437. }
  438. }
  439. /**
  440. * returns metainfo for fields in $result
  441. *
  442. * @param PMA_DrizzleResult $result Drizzle result object
  443. *
  444. * @return array meta info for fields in $result
  445. */
  446. public function getFieldsMeta($result)
  447. {
  448. // Build an associative array for a type look up
  449. $typeAr = array();
  450. /*$typeAr[DRIZZLE_COLUMN_TYPE_DECIMAL] = 'real';
  451. $typeAr[DRIZZLE_COLUMN_TYPE_NEWDECIMAL] = 'real';
  452. $typeAr[DRIZZLE_COLUMN_TYPE_BIT] = 'int';
  453. $typeAr[DRIZZLE_COLUMN_TYPE_TINY] = 'int';
  454. $typeAr[DRIZZLE_COLUMN_TYPE_SHORT] = 'int';
  455. $typeAr[DRIZZLE_COLUMN_TYPE_LONG] = 'int';
  456. $typeAr[DRIZZLE_COLUMN_TYPE_FLOAT] = 'real';
  457. $typeAr[DRIZZLE_COLUMN_TYPE_DOUBLE] = 'real';
  458. $typeAr[DRIZZLE_COLUMN_TYPE_NULL] = 'null';
  459. $typeAr[DRIZZLE_COLUMN_TYPE_TIMESTAMP] = 'timestamp';
  460. $typeAr[DRIZZLE_COLUMN_TYPE_LONGLONG] = 'int';
  461. $typeAr[DRIZZLE_COLUMN_TYPE_INT24] = 'int';
  462. $typeAr[DRIZZLE_COLUMN_TYPE_DATE] = 'date';
  463. $typeAr[DRIZZLE_COLUMN_TYPE_TIME] = 'date';
  464. $typeAr[DRIZZLE_COLUMN_TYPE_DATETIME] = 'datetime';
  465. $typeAr[DRIZZLE_COLUMN_TYPE_YEAR] = 'year';
  466. $typeAr[DRIZZLE_COLUMN_TYPE_NEWDATE] = 'date';
  467. $typeAr[DRIZZLE_COLUMN_TYPE_ENUM] = 'unknown';
  468. $typeAr[DRIZZLE_COLUMN_TYPE_SET] = 'unknown';
  469. $typeAr[DRIZZLE_COLUMN_TYPE_VIRTUAL] = 'unknown';
  470. $typeAr[DRIZZLE_COLUMN_TYPE_TINY_BLOB] = 'blob';
  471. $typeAr[DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB] = 'blob';
  472. $typeAr[DRIZZLE_COLUMN_TYPE_LONG_BLOB] = 'blob';
  473. $typeAr[DRIZZLE_COLUMN_TYPE_BLOB] = 'blob';
  474. $typeAr[DRIZZLE_COLUMN_TYPE_VAR_STRING] = 'string';
  475. $typeAr[DRIZZLE_COLUMN_TYPE_VARCHAR] = 'string';
  476. $typeAr[DRIZZLE_COLUMN_TYPE_STRING] = 'string';
  477. $typeAr[DRIZZLE_COLUMN_TYPE_GEOMETRY] = 'geometry';*/
  478. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB] = 'blob';
  479. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE] = 'date';
  480. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DATETIME] = 'datetime';
  481. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DOUBLE] = 'real';
  482. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM] = 'unknown';
  483. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG] = 'int';
  484. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_LONGLONG] = 'int';
  485. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX] = 'unknown';
  486. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_NULL] = 'null';
  487. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_TIMESTAMP] = 'timestamp';
  488. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_TINY] = 'int';
  489. $typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR] = 'string';
  490. // array of DrizzleColumn
  491. $columns = $result->getColumns();
  492. // columns in a standarized format
  493. $std_columns = array();
  494. foreach ($columns as $k => $column) {
  495. $c = new stdClass();
  496. $c->name = $column->name();
  497. $c->orgname = $column->origName();
  498. $c->table = $column->table();
  499. $c->orgtable = $column->origTable();
  500. $c->def = $column->defaultValue();
  501. $c->db = $column->db();
  502. $c->catalog = $column->catalog();
  503. // $column->maxSize() returns always 0 while size() seems
  504. // to return a correct value (drizzle extension v.0.5, API v.7)
  505. $c->max_length = $column->size();
  506. $c->decimals = $column->decimals();
  507. $c->charsetnr = $column->charset();
  508. $c->type = $typeAr[$column->typeDrizzle()];
  509. $c->_type = $column->type();
  510. $c->flags = $this->fieldFlags($result, $k);
  511. $c->_flags = $column->flags();
  512. $c->multiple_key = (int) (bool) (
  513. $c->_flags & DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY
  514. );
  515. $c->primary_key = (int) (bool) (
  516. $c->_flags & DRIZZLE_COLUMN_FLAGS_PRI_KEY
  517. );
  518. $c->unique_key = (int) (bool) (
  519. $c->_flags & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY
  520. );
  521. $c->not_null = (int) (bool) (
  522. $c->_flags & DRIZZLE_COLUMN_FLAGS_NOT_NULL
  523. );
  524. $c->unsigned = (int) (bool) (
  525. $c->_flags & DRIZZLE_COLUMN_FLAGS_UNSIGNED
  526. );
  527. $c->zerofill = (int) (bool) (
  528. $c->_flags & DRIZZLE_COLUMN_FLAGS_ZEROFILL
  529. );
  530. $c->numeric = (int) (bool) (
  531. $c->_flags & DRIZZLE_COLUMN_FLAGS_NUM
  532. );
  533. $c->blob = (int) (bool) (
  534. $c->_flags & DRIZZLE_COLUMN_FLAGS_BLOB
  535. );
  536. $std_columns[] = $c;
  537. }
  538. return $std_columns;
  539. }
  540. /**
  541. * return number of fields in given $result
  542. *
  543. * @param PMA_DrizzleResult $result Drizzle result object
  544. *
  545. * @return int field count
  546. */
  547. public function numFields($result)
  548. {
  549. return $result->numColumns();
  550. }
  551. /**
  552. * returns the length of the given field $i in $result
  553. *
  554. * @param PMA_DrizzleResult $result Drizzle result object
  555. * @param int $i field
  556. *
  557. * @return int length of field
  558. */
  559. public function fieldLen($result, $i)
  560. {
  561. $colums = $result->getColumns();
  562. return $colums[$i]->size();
  563. }
  564. /**
  565. * returns name of $i. field in $result
  566. *
  567. * @param PMA_DrizzleResult $result Drizzle result object
  568. * @param int $i field
  569. *
  570. * @return string name of $i. field in $result
  571. */
  572. public function fieldName($result, $i)
  573. {
  574. $colums = $result->getColumns();
  575. return $colums[$i]->name();
  576. }
  577. /**
  578. * returns concatenated string of human readable field flags
  579. *
  580. * @param PMA_DrizzleResult $result Drizzle result object
  581. * @param int $i field
  582. *
  583. * @return string field flags
  584. */
  585. public function fieldFlags($result, $i)
  586. {
  587. $columns = $result->getColumns();
  588. $f = $columns[$i];
  589. $type = $f->typeDrizzle();
  590. $charsetnr = $f->charset();
  591. $f = $f->flags();
  592. $flags = '';
  593. if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) {
  594. $flags .= 'unique ';
  595. }
  596. if ($f & DRIZZLE_COLUMN_FLAGS_NUM) {
  597. $flags .= 'num ';
  598. }
  599. if ($f & DRIZZLE_COLUMN_FLAGS_PART_KEY) {
  600. $flags .= 'part_key ';
  601. }
  602. if ($f & DRIZZLE_COLUMN_FLAGS_SET) {
  603. $flags .= 'set ';
  604. }
  605. if ($f & DRIZZLE_COLUMN_FLAGS_TIMESTAMP) {
  606. $flags .= 'timestamp ';
  607. }
  608. if ($f & DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT) {
  609. $flags .= 'auto_increment ';
  610. }
  611. if ($f & DRIZZLE_COLUMN_FLAGS_ENUM) {
  612. $flags .= 'enum ';
  613. }
  614. // See http://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html:
  615. // to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG
  616. // but instead the charsetnr member of the MYSQL_FIELD
  617. // structure. Watch out: some types like DATE returns 63 in charsetnr
  618. // so we have to check also the type.
  619. // Unfortunately there is no equivalent in the mysql extension.
  620. if (($type == DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB
  621. || $type == DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR)
  622. && 63 == $charsetnr
  623. ) {
  624. $flags .= 'binary ';
  625. }
  626. if ($f & DRIZZLE_COLUMN_FLAGS_ZEROFILL) {
  627. $flags .= 'zerofill ';
  628. }
  629. if ($f & DRIZZLE_COLUMN_FLAGS_UNSIGNED) {
  630. $flags .= 'unsigned ';
  631. }
  632. if ($f & DRIZZLE_COLUMN_FLAGS_BLOB) {
  633. $flags .= 'blob ';
  634. }
  635. if ($f & DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY) {
  636. $flags .= 'multiple_key ';
  637. }
  638. if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) {
  639. $flags .= 'unique_key ';
  640. }
  641. if ($f & DRIZZLE_COLUMN_FLAGS_PRI_KEY) {
  642. $flags .= 'primary_key ';
  643. }
  644. if ($f & DRIZZLE_COLUMN_FLAGS_NOT_NULL) {
  645. $flags .= 'not_null ';
  646. }
  647. return trim($flags);
  648. }
  649. /**
  650. * Store the result returned from multi query
  651. *
  652. * @return false
  653. */
  654. public function storeResult()
  655. {
  656. return false;
  657. }
  658. }
  659. ?>