2
0

OracleTest.php 3.1 KB

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