Created
August 24, 2011 14:12
-
-
Save raphaeldealmeida/1168154 to your computer and use it in GitHub Desktop.
Teste CLOB no Oracle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'Zend/Loader/Autoloader.php'; | |
$loader = Zend_Loader_Autoloader::getInstance(); | |
class ClobTest extends PHPUnit_Framework_TestCase{ | |
public function setUp() { | |
parent::setUp(); | |
// $this->dbAdapter = Zend_Db::factory('pdo_sqlite', array('dbname'=>':memory:')); | |
$this->dbAdapter = Zend_Db::factory('oracle', array('username'=>'HR', | |
'password'=>'HR', | |
'dbname'=>'XE' )); | |
Zend_Db_Table::setDefaultAdapter($this->dbAdapter); | |
$this->dbAdapter->query("CREATE TABLE posts( | |
id INT NOT NULL, | |
texto CLOB, | |
PRIMARY KEY (id))"); | |
$this->dbAdapter->query("INSERT INTO posts | |
(id, texto) | |
VALUES ('1', 'teste')"); | |
} | |
public function tearDown() { | |
parent::tearDown(); | |
$this->dbAdapter->query("DELETE FROM posts"); | |
$this->dbAdapter->query("DROP TABLE posts"); | |
} | |
/** | |
* @expectedException Zend_Db_Statement_Oracle_Exception | |
*/ | |
public function testUpdateClob4k1SemBind() { | |
$tamanhoString = 4001; | |
$stringGigante4k1 = str_pad('', $tamanhoString, '7'); | |
$this->dbAdapter->query("UPDATE posts | |
SET texto = '$stringGigante4k1' | |
WHERE id = 1"); | |
$result = $this->dbAdapter->fetchAll("SELECT texto FROM posts WHERE id = 1"); | |
$this->assertEquals($tamanhoString, strlen($result[0]['TEXTO'])); | |
} | |
public function testUpdateClob4k() { | |
$tamanhoString = 4000; | |
$stringGigante4k = str_pad('', $tamanhoString, '7'); | |
$this->dbAdapter->query("UPDATE posts | |
SET texto = :clob | |
WHERE id = 1", array('clob' => $stringGigante4k)); | |
$result = $this->dbAdapter->fetchAll("SELECT texto FROM posts WHERE id = 1"); | |
$this->assertEquals($tamanhoString, strlen($result[0]['TEXTO'])); | |
} | |
public function testUpdateClob4k1() { | |
$tamanhoString = 4001; | |
$stringGigante4k1 = str_pad('', $tamanhoString, '7'); | |
$this->dbAdapter->query("UPDATE posts | |
SET texto = :clob | |
WHERE id = 1", array('clob' => $stringGigante4k1)); | |
$result = $this->dbAdapter->fetchAll("SELECT texto FROM posts WHERE id = 1"); | |
$this->assertEquals($tamanhoString, strlen($result[0]['TEXTO'])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment