Ibm.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Db
  17. * @subpackage Statement
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Db_Statement_Pdo
  24. */
  25. require_once 'Zend/Db/Statement/Pdo.php';
  26. /**
  27. * Proxy class to wrap a PDOStatement object for IBM Databases.
  28. * Matches the interface of PDOStatement. All methods simply proxy to the
  29. * matching method in PDOStatement. PDOExceptions thrown by PDOStatement
  30. * are re-thrown as Zend_Db_Statement_Exception.
  31. *
  32. * @category Zend
  33. * @package Zend_Db
  34. * @subpackage Statement
  35. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Db_Statement_Pdo_Ibm extends Zend_Db_Statement_Pdo
  39. {
  40. /**
  41. * Returns an array containing all of the result set rows.
  42. *
  43. * Behaves like parent, but if limit()
  44. * is used, the final result removes the extra column
  45. * 'zend_db_rownum'
  46. *
  47. * @param int $style OPTIONAL Fetch mode.
  48. * @param int $col OPTIONAL Column number, if fetch mode is by column.
  49. * @return array Collection of rows, each in a format by the fetch mode.
  50. * @throws Zend_Db_Statement_Exception
  51. */
  52. public function fetchAll($style = null, $col = null)
  53. {
  54. $data = parent::fetchAll($style, $col);
  55. $results = array();
  56. $remove = $this->_adapter->foldCase('ZEND_DB_ROWNUM');
  57. foreach ($data as $row) {
  58. if (is_array($row) && array_key_exists($remove, $row)) {
  59. unset($row[$remove]);
  60. }
  61. $results[] = $row;
  62. }
  63. return $results;
  64. }
  65. /**
  66. * Binds a parameter to the specified variable name.
  67. *
  68. * @param mixed $parameter Name the parameter, either integer or string.
  69. * @param mixed $variable Reference to PHP variable containing the value.
  70. * @param mixed $type OPTIONAL Datatype of SQL parameter.
  71. * @param mixed $length OPTIONAL Length of SQL parameter.
  72. * @param mixed $options OPTIONAL Other options.
  73. * @return bool
  74. * @throws Zend_Db_Statement_Exception
  75. */
  76. public function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
  77. {
  78. try {
  79. if (($type === null) && ($length === null) && ($options === null)) {
  80. return $this->_stmt->bindParam($parameter, $variable);
  81. } else {
  82. return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options);
  83. }
  84. } catch (PDOException $e) {
  85. require_once 'Zend/Db/Statement/Exception.php';
  86. throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
  87. }
  88. }
  89. }