/** * test if the correct bind variable is used in case of overlap * Example: you could have :reseller or :resellersoort, and only :resellersoort is in the query * We don't want to attempt to bind :reseller in this case * I copied this test from BinderTest, because I absolutely want to make sure the query executes as expected */ public function testOverlappingBindVariableNames() { $sql = "select *\n from dm_resellers r\n join dm_resellersoort rs on r.soortcode = rs.soortcode\n where rs.soortcode = :resellersoort"; $statement = new Statement($sql, new Connection('dm')); $statement->bind(array(':reseller' => 'Tele2', ':resellersoort' => 1)); $result = $statement->execute(); $this->assertTrue($result); }
public function render() { // if error_reporting = 0 (hide all errors in production) don't show the error if (error_reporting() === 0) { return null; } $data = array('id' => 'sql' . mt_rand(0, 9999), 'error_message' => $this->getErrorMessage(), 'known_error_message' => $this->knownErrorMessage(), 'sql' => $this->statement->getSql(), 'binds' => $this->statement->toStringBindVariables()); $view = $this->createErrorView($data); return $view->render(); }
protected function setNumRows() { // oci_num_rows will return the number of fetched rows so far for a SELECT statement // for all other query types this is fine // If the user has fetched records in a while loop, the num rows will be the amount of rows fetched so far. // When the user hasn't fetched anything yet, we will fetch the complete result and return the count. $this->numRows = oci_num_rows($this->statement->getResource()); if ($this->statement->getStatementType() == 'SELECT' && empty($this->numRows)) { $this->fetchAll(); // unlike fetchResult, this will only fetch the result when result is empty $this->numRows = $this->result->count(); } }
/** * Bind a variable for a procedure with an OUT parameter (size is required) * the out parameter can be fetched with getOutParameter($name) * * @param string $bind * @param string $name * @param int $size * * @return bool success */ public function bindOutParameter($bind, $name, $size) { return oci_bind_by_name($this->statement->getResource(), $bind, $this->outParameters[$name], $size); }
/** * Rollback */ public function rollback() { return oci_rollback($this->statement->getConnectionResource()); }
/** * @param $sql * @return Error */ protected function runStatementToFail($sql) { $statement = new Statement($sql, $this->connection); $statement->execute(); return new Error($statement); }
/** * @return string */ public function render() { $data = array('sql' => $this->statement->getSql(), 'binds' => $this->statement->toStringBindVariables(), 'schema' => $this->statement->getSchema()); $view = new SimpleView(__DIR__ . '/debug.phtml', $data); return $view->render(); }
public function testGetSchema() { $statement = new Statement("select * from test", $this->connection); $this->assertEquals('TEST', $statement->getSchema()); }