コード例 #1
0
ファイル: Executor.php プロジェクト: winkbrace/oracle
 /**
  * Voer insert uit en return last inserted id
  *
  * @param string $sequence
  * @param bool $commit
  * @return int|false $lastId
  */
 public function insert($sequence = null, $commit = self::COMMIT)
 {
     if ($this->statement->getStatementType() != 'INSERT') {
         return false;
     }
     if (empty($sequence)) {
         return false;
     }
     if (!$this->execute($commit)) {
         return false;
     }
     // try to return the currval of the given sequence
     $resource = oci_parse($this->statement->getConnectionResource(), "select " . $sequence . ".currval cv from dual");
     oci_define_by_name($resource, 'CV', $lastId);
     $flag = $commit === true ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT;
     if (!oci_execute($resource, $flag)) {
         return false;
     }
     oci_fetch($resource);
     return $lastId;
 }
コード例 #2
0
ファイル: Fetcher.php プロジェクト: winkbrace/oracle
 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();
     }
 }
コード例 #3
0
ファイル: StatementTest.php プロジェクト: winkbrace/oracle
 public function testGetStatementType()
 {
     $statement = new Statement("select * from test", $this->connection);
     $this->assertEquals('SELECT', $statement->getStatementType());
     $statement = new Statement("update test set value = 'hearty ' || value", $this->connection);
     $this->assertEquals('UPDATE', $statement->getStatementType());
 }