OracleTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 UnitTests
  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. require_once 'Zend/Db/Select/TestCommon.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Db
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. * @group Zend_Db
  30. * @group Zend_Db_Select
  31. */
  32. class Zend_Db_Select_OracleTest extends Zend_Db_Select_TestCommon
  33. {
  34. /**
  35. * ZF-4330: this test must be done on string field
  36. */
  37. protected function _selectColumnWithColonQuotedParameter ()
  38. {
  39. $product_name = $this->_db->quoteIdentifier('product_name');
  40. $select = $this->_db->select()
  41. ->from('zfproducts')
  42. ->where($product_name . ' = ?', "as'as:x");
  43. return $select;
  44. }
  45. /**
  46. * ZF-4330 : Oracle doesn't use 'AS' to identify table alias
  47. */
  48. public function testSelectFromSelectObject ()
  49. {
  50. $select = $this->_selectFromSelectObject();
  51. $query = $select->assemble();
  52. $cmp = 'SELECT ' . $this->_db->quoteIdentifier('t') . '.* FROM (SELECT '
  53. . $this->_db->quoteIdentifier('subqueryTable') . '.* FROM '
  54. . $this->_db->quoteIdentifier('subqueryTable') . ') '
  55. . $this->_db->quoteIdentifier('t');
  56. $this->assertEquals($query, $cmp);
  57. }
  58. /**
  59. * ZF-4330 : for Oracle, we must add order clause
  60. */
  61. public function testSelectWhereOr ()
  62. {
  63. $select = $this->_selectWhereOr();
  64. $select->order('product_id');
  65. $stmt = $this->_db->query($select);
  66. $result = $stmt->fetchAll();
  67. $this->assertEquals(2, count($result));
  68. $this->assertEquals(1, $result[0]['product_id']);
  69. $this->assertEquals(2, $result[1]['product_id']);
  70. }
  71. /**
  72. * ZF-4330 : for Oracle, we must add order clause
  73. */
  74. public function testSelectWhereOrWithParameter ()
  75. {
  76. $select = $this->_selectWhereOrWithParameter();
  77. $select->order('product_id');
  78. $stmt = $this->_db->query($select);
  79. $result = $stmt->fetchAll();
  80. $this->assertEquals(2, count($result));
  81. $this->assertEquals(1, $result[0]['product_id']);
  82. $this->assertEquals(2, $result[1]['product_id']);
  83. }
  84. public function getDriver ()
  85. {
  86. return 'Oracle';
  87. }
  88. }