Advertisement
Guest User

Untitled

a guest
Nov 25th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. <?php
  2. 2 /*
  3. 3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. 4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. 5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. 6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. 7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. 8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. 9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. 10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. 11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. 12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. 13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. 14 *
  15. 15 * This software consists of voluntary contributions made by many individuals
  16. 16 * and is licensed under the MIT license. For more information, see
  17. 17 * <http://www.doctrine-project.org>.
  18. 18 */
  19.  
  20. namespace DoctrineDBALDriver;
  21.  
  22. use PDO;
  23.  
  24. class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
  25. {
  26. public function __construct($dsn, $user = null, $password = null, array $options = null)
  27. {
  28. try {
  29. parent::__construct($dsn, $user, $password, $options);
  30. $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DoctrineDBALDriverPDOStatement', array()));
  31. $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  32. } catch (PDOException $exception) {
  33. throw new PDOException($exception);
  34. }
  35. }
  36.  
  37. public function exec($statement)
  38. {
  39. try {
  40. return parent::exec($statement);
  41. } catch (PDOException $exception) {
  42. throw new PDOException($exception);
  43. }
  44. }
  45.  
  46. public function getServerVersion()
  47. {
  48. return PDO::getAttribute(PDO::ATTR_SERVER_VERSION);
  49. }
  50.  
  51. public function prepare($prepareString, $driverOptions = array())
  52. {
  53. try {
  54. return parent::prepare($prepareString, $driverOptions);
  55. } catch (PDOException $exception) {
  56. throw new PDOException($exception);
  57. }
  58. }
  59.  
  60. public function query()
  61. {
  62. $args = func_get_args();
  63. $argsCount = count($args);
  64.  
  65. try {
  66. if ($argsCount == 4) {
  67. return parent::query($args[0], $args[1], $args[2], $args[3]);
  68. }
  69.  
  70. if ($argsCount == 3) {
  71. return parent::query($args[0], $args[1], $args[2]);
  72. }
  73.  
  74. if ($argsCount == 2) {
  75. return parent::query($args[0], $args[1]);
  76. }
  77.  
  78. return parent::query($args[0]);
  79. } catch (PDOException $exception) {
  80. throw new PDOException($exception);
  81. }
  82. }
  83.  
  84. public function quote($input, $type = PDO::PARAM_STR)
  85. {
  86. return parent::quote($input, $type);
  87. }
  88.  
  89. public function lastInsertId($name = null)
  90. {
  91. return parent::lastInsertId($name);
  92. }
  93.  
  94. public function requiresQueryForServerVersion()
  95. {
  96. return false;
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement