xpdodriver.class.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*
  3. * Copyright 2010-2015 by MODX, LLC.
  4. *
  5. * This file is part of xPDO.
  6. *
  7. * xPDO is free software; you can redistribute it and/or modify it under the
  8. * terms of the GNU General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option) any later
  10. * version.
  11. *
  12. * xPDO is distributed in the hope that it will be useful, but WITHOUT ANY
  13. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  14. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * xPDO; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  18. * Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. /**
  21. * The mysql implementation of the xPDODriver class.
  22. *
  23. * @package xpdo
  24. * @subpackage om.mysql
  25. */
  26. /**
  27. * Include the parent {@link xPDODriver} class.
  28. */
  29. require_once (dirname(__DIR__) . '/xpdodriver.class.php');
  30. /**
  31. * Provides mysql driver abstraction for an xPDO instance.
  32. *
  33. * This is baseline metadata and methods used throughout the framework. xPDODriver
  34. * class implementations are specific to a PDO driver and this instance is
  35. * implemented for mysql.
  36. *
  37. * @package xpdo
  38. * @subpackage om.mysql
  39. */
  40. class xPDODriver_mysql extends xPDODriver {
  41. public $quoteChar = "'";
  42. public $escapeOpenChar = '`';
  43. public $escapeCloseChar = '`';
  44. public $_currentTimestamps= array (
  45. 'CURRENT_TIMESTAMP',
  46. 'CURRENT_TIMESTAMP()',
  47. 'NOW()',
  48. 'LOCALTIME',
  49. 'LOCALTIME()',
  50. 'LOCALTIMESTAMP',
  51. 'LOCALTIMESTAMP()',
  52. 'SYSDATE()'
  53. );
  54. public $_currentDates= array (
  55. 'CURDATE()',
  56. 'CURRENT_DATE',
  57. 'CURRENT_DATE()'
  58. );
  59. public $_currentTimes= array (
  60. 'CURTIME()',
  61. 'CURRENT_TIME',
  62. 'CURRENT_TIME()'
  63. );
  64. /**
  65. * Get a mysql xPDODriver instance.
  66. *
  67. * @param xPDO &$xpdo A reference to a specific xPDO instance.
  68. */
  69. function __construct(xPDO &$xpdo) {
  70. parent :: __construct($xpdo);
  71. $this->dbtypes['integer']= array('/INT/i');
  72. $this->dbtypes['boolean']= array('/^BOOL/i');
  73. $this->dbtypes['float']= array('/^DEC/i','/^NUMERIC$/i','/^FLOAT$/i','/^DOUBLE/i','/^REAL/i');
  74. $this->dbtypes['string']= array('/CHAR/i','/TEXT/i','/^ENUM$/i','/^SET$/i','/^TIME$/i','/^YEAR$/i');
  75. $this->dbtypes['timestamp']= array('/^TIMESTAMP$/i');
  76. $this->dbtypes['datetime']= array('/^DATETIME$/i');
  77. $this->dbtypes['date']= array('/^DATE$/i');
  78. $this->dbtypes['binary']= array('/BINARY/i','/BLOB/i');
  79. $this->dbtypes['bit']= array('/^BIT$/i');
  80. }
  81. }