xpdodriver.class.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 sqlsrv implementation of the xPDODriver class.
  22. *
  23. * @package xpdo
  24. * @subpackage om.sqlsrv
  25. */
  26. /**
  27. * Include the parent {@link xPDODriver} class.
  28. */
  29. require_once (dirname(__DIR__) . '/xpdodriver.class.php');
  30. /**
  31. * Provides sqlsrv 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 sqlsrv.
  36. *
  37. * @package xpdo
  38. * @subpackage om.sqlsrv
  39. */
  40. class xPDODriver_sqlsrv extends xPDODriver {
  41. public $quoteChar = "'";
  42. public $escapeOpenChar = '[';
  43. public $escapeCloseChar = ']';
  44. public $_currentTimestamps= array(
  45. "CURRENT_TIMESTAMP",
  46. "GETDATE()"
  47. );
  48. public $_currentDates= array(
  49. "CURRENT_DATE"
  50. );
  51. public $_currentTimes= array(
  52. "CURRENT_TIME"
  53. );
  54. /**
  55. * Get a sqlsrv xPDODriver instance.
  56. *
  57. * @param xPDO &$xpdo A reference to a specific xPDO instance.
  58. */
  59. function __construct(xPDO &$xpdo) {
  60. parent :: __construct($xpdo);
  61. $this->dbtypes['integer']= array('/INT$/i');
  62. $this->dbtypes['float']= array('/^DEC/i','/^NUMERIC$/i','/^FLOAT$/i','/^REAL$/i','/MONEY$/i');
  63. $this->dbtypes['string']= array('/CHAR$/i','/TEXT$/i');
  64. $this->dbtypes['date']= array('/^DATE$/i');
  65. $this->dbtypes['datetime']= array('/DATETIME/i');
  66. $this->dbtypes['time']= array('/^TIME$/i');
  67. $this->dbtypes['binary']= array('/BINARY$/i','/^IMAGE$/i');
  68. $this->dbtypes['bit']= array('/^BIT$/i');
  69. }
  70. }