function insertImage($conn, $photo_id, $owner_name, $descriptive_info, $thumbnail, $photo) { $photo_blob = oci_new_descriptor($conn, OCI_D_LOB); $thumbnail_blob = oci_new_descriptor($conn, OCI_D_LOB); $subject = $descriptive_info[0]; $place = $descriptive_info[1]; $date_time = $descriptive_info[2]; $description = $descriptive_info[3]; $permitted = $descriptive_info[4]; $sql = 'INSERT INTO images (photo_id, owner_name, permitted, subject, place, timing, description, thumbnail, photo) VALUES (:photoid, :ownername, :permitted, :subject, :place, TO_DATE(:datetime, \'MM/DD/YYYY\'), :description, empty_blob(), empty_blob()) returning thumbnail, photo into :thumbnail, :photo'; $stid = oci_parse($conn, $sql); oci_bind_by_name($stid, ':photoid', $photo_id); oci_bind_by_name($stid, ':ownername', $owner_name); oci_bind_by_name($stid, ':permitted', $permitted); oci_bind_by_name($stid, ':subject', $subject); oci_bind_by_name($stid, ':place', $place); oci_bind_by_name($stid, ':datetime', $date_time); oci_bind_by_name($stid, ':description', $description); oci_bind_by_name($stid, ':thumbnail', $thumbnail_blob, -1, OCI_B_BLOB); oci_bind_by_name($stid, ':photo', $photo_blob, -1, OCI_B_BLOB); $res = oci_execute($stid, OCI_DEFAULT); if ($thumbnail_blob->save($thumbnail) && $photo_blob->save($photo)) { oci_commit($conn); } else { oci_rollback($conn); } oci_free_statement($stid); $photo_blob->free(); $thumbnail_blob->free(); }
/** * Insert image data to database (recoreded_data and thumbnail). * First generate an unique image id, then insert image to recoreded_data and resized image to thubnail along with * other given data */ function uploadImage($conn, $sensor_id, $date_created, $description) { $image_id = generateId($conn, "images"); if ($image_id == 0) { return; } $image2 = file_get_contents($_FILES['file_image']['tmp_name']); $image2tmp = resizeImage($_FILES['file_image']); $image2Thumbnail = file_get_contents($image2tmp['tmp_name']); // encode the stream $image = base64_encode($image2); $imageThumbnail = base64_encode($image2Thumbnail); $sql = "INSERT INTO images (image_id, sensor_id, date_created, description, thumbnail, recoreded_data)\n VALUES(" . $image_id . ", " . $sensor_id . ", TO_DATE('" . $date_created . "', 'DD/MM/YYYY hh24:mi:ss'), '" . $description . "', empty_blob(), empty_blob())\n RETURNING thumbnail, recoreded_data INTO :thumbnail, :recoreded_data"; $result = oci_parse($conn, $sql); $recoreded_dataBlob = oci_new_descriptor($conn, OCI_D_LOB); $thumbnailBlob = oci_new_descriptor($conn, OCI_D_LOB); oci_bind_by_name($result, ":recoreded_data", $recoreded_dataBlob, -1, OCI_B_BLOB); oci_bind_by_name($result, ":thumbnail", $thumbnailBlob, -1, OCI_B_BLOB); $res = oci_execute($result, OCI_DEFAULT) or die("Unable to execute query"); if ($recoreded_dataBlob->save($image) && $thumbnailBlob->save($imageThumbnail)) { oci_commit($conn); } else { oci_rollback($conn); } oci_free_statement($result); $recoreded_dataBlob->free(); $thumbnailBlob->free(); echo "New image is added with image_id ->" . $image_id . "<br>"; }
public function rollBack() { if (!oci_rollback($this->_dbh)) { throw OCI8Exception::fromErrorInfo($this->errorInfo()); } return true; }
public function rollback() { if (oci_rollback($this->connection)) { $this->autoCommit = true; } else { $e = oci_error($this->connection); throw new Sabel_Db_Exception_Driver($e["message"]); } }
public function rollBack() { if (!oci_rollback($this->dbh)) { $error = oci_error($this->dbh); throw new \Exception($error['message'], $error['code']); } $this->executeMode = OCI_COMMIT_ON_SUCCESS; return true; }
public function UpdateRecord($sql, $conn) { $status_update = false; $parse = oci_parse($sql, $conn); $execute = oci_execute($parse); if ($execute) { oci_commit($conn); $status_update = true; } else { oci_rollback($conn); $status_update = false . oci_error(); } return $status_update; }
function retrieveInfoJobPostResume($jobID) { $SelectSQL = "SELECT J.userID, J.jobTitle, J.jobID, J.status, U.name, E.companyName\n\t\t\t\t\t\tFROM Users U, employer E, Job_Post J,\n\t\t\t\t\t\t(SELECT J.userID, J.jobID\n\t\t\t\t\t\tFROM Job_Post J\n\t\t\t\t\t\tWHERE J.requiredGPA <= (SELECT R.gpa\n\t\t\t\t\t\t\t\t\t\t\t\tFROM Resume_Post R\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE R.userID = :userID AND R.resumeID = :resumeID) OR J.requiredGPA IS NULL\n\t\t\t\t\t\tINTERSECT\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tSELECT J.userID, J.jobID\n\t\t\t\t\t\t\tFROM Job_Post J\n\t\t\t\t\t\t\tWHERE (J.requiredDegree = 'Bachelor') AND EXISTS (\n\t\t\t\t\t\t\t\tSELECT R.degree \n\t\t\t\t\t\t\t\tFROM Resume_Post R\n\t\t\t\t\t\t\t\tWHERE R.userID = :userID AND R.resumeID = :resumeID AND R.degree = 'Bachelor')\n\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\tSELECT J.userID, J.jobID\n\t\t\t\t\t\t\tFROM Job_Post J\n\t\t\t\t\t\t\tWHERE (J.requiredDegree = 'Bachelor' OR J.requiredDegree = 'Master') AND EXISTS (\n\t\t\t\t\t\t\t\tSELECT R.degree \n\t\t\t\t\t\t\t\tFROM Resume_Post R\n\t\t\t\t\t\t\t\tWHERE R.userID = :userID AND R.resumeID = :resumeID AND R.degree = 'Master')\n\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\tSELECT J.userID, J.jobID\n\t\t\t\t\t\t\tFROM Job_Post J\n\t\t\t\t\t\t\tWHERE (J.requiredDegree = 'Bachelor' OR J.requiredDegree = 'Master' OR J.requiredDegree = 'Doctorate') AND EXISTS (\n\t\t\t\t\t\t\t\tSELECT R.degree \n\t\t\t\t\t\t\t\tFROM Resume_Post R\n\t\t\t\t\t\t\t\tWHERE R.userID = :userID AND R.resumeID = :resumeID AND R.degree = 'Doctorate')\n\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\tSELECT J.userID, J.jobID\n\t\t\t\t\t\t\tFROM Job_Post J\n\t\t\t\t\t\t\tWHERE J.requiredDegree IS NULL\n\t\t\t\t\t\t)\n\t\t\t\t\t\tINTERSECT\n\t\t\t\t\t\tSELECT J.userID, J.jobID\n\t\t\t\t\t\tFROM Job_Post J\n\t\t\t\t\t\tWHERE NOT EXISTS(\n\t\t\t\t\t\t\t(SELECT JRS.skill_ID \n\t\t\t\t\t\t\t FROM Job_Require_Skill JRS\n\t\t\t\t\t\t\t WHERE JRS.jobID = J.jobID AND JRS.userID = J.userID)\n\t\t\t\t\t\t\t MINUS(\n\t\t\t\t\t\t\t SELECT RHS.skill_ID\n\t\t\t\t\t\t\t FROM Resume_Have_Skill RHS, Job_Require_Skill JRS\n\t\t\t\t\t\t\t WHERE RHS.userID = :userID AND RHS.resumeID = :resumeID AND JRS.jobID = J.jobID AND JRS.userID = J.userID \n\t\t\t\t\t\t\t\t\tAND JRS.skill_ID = RHS.skill_ID AND (JRS.knowledgeLevel <= RHS.knowledgeLevel OR JRS.knowledgeLevel IS NULL)))\n\t\t\t\t\t\tMINUS\n\t\t\t\t\t\tSELECT J.job_post_userID, J.jobID\n\t\t\t\t\t\tFROM JobSeeker_Apply_Job J\n\t\t\t\t\t\tWHERE J.userID = :userID\n\t\t\t\t\t\t) AllowedJob\n\t\t\t\t\t\tWHERE J.status = '1' AND AllowedJob.userID = J.userID AND AllowedJob.jobID = J.jobID AND J.userID = U.userID AND U.userID = E.userID"; // Connect to database $stid = oci_parse($conn, $SelectSQL); oci_bind_by_name($stid, ":userID", $userID); oci_bind_by_name($stid, ":resumeID", $resumeID); // Execute and Check Errors oci_execute($stid); $err = oci_error($stid); if ($err) { oci_rollback($conn); $err_code = $err['code']; $error_msg = "CANDIDATE JOB ERROR. Some unknown database error occurred. Please inform database administrator with these error messages.<br>\n" . "Error code : " . $err['code'] . "<br>" . "Error message : " . $err['message'] . "<br>"; echo $error_msg; } return $stid; }
public function ajouterContenu($id_fichier, $contenu) { $sql = "INSERT INTO CONTENU(ID_FICHIER,CONTENU) VALUES ({$id_fichier}, EMPTY_CLOB())\n RETURNING CONTENU INTO :CONTENU_loc"; $conn = oci_connect("DBA_PARAPHEUR", "12345678", "XE"); $stmt = oci_parse($conn, $sql); // Creates an "empty" OCI-Lob object to bind to the locator $clob = oci_new_descriptor($conn, OCI_D_LOB); // Bind the returned Oracle LOB locator to the PHP LOB object oci_bind_by_name($stmt, ":CONTENU_loc", $clob, -1, OCI_B_CLOB); // Execute the statement using , OCI_DEFAULT - as a transaction oci_execute($stmt, OCI_DEFAULT) or die("Unable to execute query\n"); // Now save a value to the clob if (!$clob->save($contenu)) { // On error, rollback the transaction oci_rollback($conn); } else { // On success, commit the transaction oci_commit($conn); } }
function displaySkillOptionInfo() { global $conn; // Get Skill List and ID Form $skillListSQL = "SELECT S.skillTitle, S.skill_ID FROM SKILL S"; $skillListSTID = oci_parse($conn, $skillListSQL); // Execute and Check Errors oci_execute($skillListSTID, OCI_DEFAULT); $err = oci_error($skillListSTID); if ($err) { oci_rollback($conn); $err_code = $err['code']; $error_msg = "SKILL LIST RETRIEVE ERROR. Some unknown database error occurred. Please inform database administrator with these error messages.<br>\n" . "Error code : " . $err['code'] . "<br>" . "Error message : " . $err['message'] . "<br>"; echo $error_msg; } else { while ($row = oci_fetch_row($skillListSTID)) { echo "<input type='hidden' name='skill[]' value='" . $row[1] . "'>"; echo "<input type='checkbox' name='skill[]' value='" . $row[1] . "'>" . $row[0]; echo "<select name='skilllevel[]'>\n\t\t\t\t\t\t<option value='0'>0</option>\n\t\t\t\t\t\t<option value='1'>1</option>\n\t\t\t\t\t\t<option value='2'>2</option>\n\t\t\t\t\t\t<option value='3'>3</option>\n\t\t\t\t\t\t<option value='4'>4</option>\n\t\t\t\t\t\t<option value='5'>5</option>\n\t\t\t\t\t\t</select>"; echo "<br>"; } } }
public function rollback_transaction() { oci_rollback($this->connection); }
function rollback($fname = 'DatabaseOracle::rollback') { if ($this->mTrxLevel) { oci_rollback($this->mConn); $this->mTrxLevel = 0; $this->doQuery('SET CONSTRAINTS ALL IMMEDIATE'); } }
if ($parse) { oci_commit($conn); echo "success"; } else { oci_rollback($conn); echo "failed"; } } else { $sql = "INSERT INTO MD_PROC_DELAY_REMS(HEAD_MARK,ID,REMS,ENTRY_DATE,ENTRY_SIGN,PROC_TYPE,PROC_SUB_TYPE) values ('{$HM}','{$HMID}','{$REMS}',TO_DATE('{$REMS_DT}','MM/DD/YYYY'),'{$username}','{$PROC_TYP}','{$PROC_SUB_TYP}')"; $parse = oci_parse($conn, $sql); oci_execute($parse); if ($parse) { oci_commit($conn); echo "success"; } else { oci_rollback($conn); echo "failed"; } } break; case 'show_md_remaks': $HM = $_POST['HM']; $HMID = $_POST['HMID']; $PROC_TYP = $_POST['PROC_TYP']; $PROC_SUB_TYP = $_POST['PROC_SUB_TYP']; $title = $_POST['title']; ?> <table class="table-bordered compact" width="100%"> <thead style="background-color:gray;"> <tr> <th colspan="3" class="text-center"><?php
function res_sel($sel, $dbcnx) { if (!$dbcnx) { return null; } // $req = pg_query($sel) or die('echec sql : ' . pg_last_error()); // $req = pg_query($sel); $req = ociparse($dbcnx, $sel); // oracle if (!oci_execute($req, OCI_DEFAULT)) { oci_rollback($dbcnx); $e = oci_error($req); print "<pre><font color='red'>" . $e['sqltext'] . ': ' . $e['message'] . '</font></pre>'; $_url = "../index.php?ong=" . $_POST['ong']; echo "<br><br><b><a href={$_url}>Retour</a></b>"; die; } $res = array(); $i = 0; while ($line = oci_fetch_array($req, OCI_ASSOC + OCI_RETURN_NULLS)) { // oracle // while ($line = pg_fetch_array($req, null, PGSQL_ASSOC)) { foreach ($line as $cle => $col_value) { $res[strtolower($cle)][$i] = $col_value; } $i++; } $total_lignes = $i; // pg_free_result($req); oci_free_statement($req); //oracle // return list($res, $total_lignes); return array('res' => $res, 'total_lignes' => $total_lignes); }
/** * Rollback Transaction * * @return bool */ protected function _trans_rollback() { $this->commit_mode = OCI_COMMIT_ON_SUCCESS; return oci_rollback($this->conn_id); }
public function registrar2(Denuncia $data, FiscEmpresa $empresa) { $this->conex = DataBase::getInstance(); /*Consultar Empresa*/ $id_empresa = $empresa->__GET('id_fisc_empresa'); $consulta_empresa = "SELECT * FROM FISC_EMPRESA WHERE ID_FISC_EMPRESA= '" . $id_empresa . "'"; $compemp = oci_parse($this->conex, $consulta_empresa); if (!$compemp) { return false; } $exemp = oci_execute($compemp); if (!$exemp) { return false; } $empresa_result = oci_fetch_assoc($compemp); /*Consultar Empresa*/ /*Verificar existencia de empresa*/ if (!isset($empresa_result['ID_EMPRESA'])) { /*Insertando en la tabla FISC_EMPRESA*/ $id_emp = $empresa->__GET('id_fisc_empresa'); $rif = $empresa->__GET('rif_fisc_empresa'); $nombre = $empresa->__GET('nombre_fisc_empresa'); $telefono = $empresa->__GET('telefono_fisc_empresa'); $email = $empresa->__GET('email_fisc_empresa'); $direccion = $empresa->__GET('direccion_fisc_empresa'); $referencia = $empresa->__GET('punto_ref_fisc_empresa'); $denuncias = 1; //clave foranea de tabla denuncia $fiscalizaciones = 3; //clave foranea de tabla fiscalizaciones $consulta = "INSERT INTO FISC_EMPRESA (\n\t\t\t\tID_FISC_EMPRESA, \n\t\t\t\tRIF_FISC_EMPRESA,\n\t\t\t\tNOMBRE_FISC_EMPRESA, \n\t\t\t\tTELEFONO_FISC_EMPRESA, \n\t\t\t\tEMAIL_FISC_EMPRESA, \n\t\t\t\tDIRECCION_FISC_EMPRESA, \n\t\t\t\tDENUNCIAS_FISC_EMPRESA, \n\t\t\t\tPUNTO_REF_FISC_EMPRESA, \n\t\t\t\tFISCALIZACIONES_FISC_EMPRESA)\nvalues\n(\n\t:id_emp,\n\t:rif_emp,\n\t:nombre, \n\t:telefono,\n\t:email,\n\t:direccion,\n\t:denuncias,\n\t:ref,\n\t:fiscalizaciones\n\t)"; $stid = oci_parse($this->conex, $consulta); if (!$stid) { echo "Desde el parse 1"; $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); return false; } oci_bind_by_name($stid, ':id_emp', $id_emp); oci_bind_by_name($stid, ':rif_emp', $rif); oci_bind_by_name($stid, ':nombre', $nombre); oci_bind_by_name($stid, ':telefono', $telefono); oci_bind_by_name($stid, ':email', $email); oci_bind_by_name($stid, ':direccion', $direccion); oci_bind_by_name($stid, ':denuncias', $denuncias); oci_bind_by_name($stid, ':ref', $referencia); oci_bind_by_name($stid, ':fiscalizaciones', $fiscalizaciones); $r = oci_execute($stid, OCI_NO_AUTO_COMMIT); if (!$r) { echo "Desde el execute 1"; $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //Revertimos los cambios //oci_rollback($this->conex); //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); return false; } /*Insertando en la tabla FISC_EMPRESA*/ } /*Verificar existencia de empresa*/ /*Insertando en la tabla FISC_APODERADO*/ $id_den = $data->__GET('id_denuncia'); $id_ciu = $data->__GET('id_ciudadano'); $motivo = $data->__GET('motivo_denuncia'); $sts = $data->__GET('estatus_denuncia'); $fecha = $data->__GET('fecha_denuncia'); $rif = $data->__GET('rif'); $descripcion = $data->__GET('descripcion'); $responsable = $data->__GET('responsable'); //$apoderado = $data->__GET('apoderado'); $consulta = "INSERT INTO FISC_APODERADO(\n\tid_denuncia,\n\tid_ciudadano,\n\trif,\n\tmotivo_denuncia,\n\testatus_denuncia,\n\tfecha_denuncia,\n\tdescripcion, \n\tresponsable)\nvalues (\n\t:id_den,\n\t:id_ciu,\n\t:rif,\n\t:mot,\n\t:sts,\n\t:fec,\n\t:descrip,\n\t:responsable)"; $stid = oci_parse($this->conex, $consulta); /*values ( :id_den,:id_ciu,:rif,:mot,:sts, :fec,:descrp,:creator,:upd)");*/ if (!$stid) { echo "Desde el parse 2"; $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //$e = oci_error($this->conex); //trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); return false; } // Realizar la lógica de la consulta oci_bind_by_name($stid, ':id_den', $id_den); oci_bind_by_name($stid, ':id_ciu', $id_ciu); oci_bind_by_name($stid, ':rif', $rif); oci_bind_by_name($stid, ':mot', $motivo); oci_bind_by_name($stid, ':sts', $sts); oci_bind_by_name($stid, ':fec', $fecha); oci_bind_by_name($stid, ':descrip', $descripcion); oci_bind_by_name($stid, ':responsable', $responsable); //oci_bind_by_name($stid, ':apoderado', $apoderado); /* oci_bind_by_name($stid, ':creator', $data->__GET('createdby')); oci_bind_by_name($stid, ':updater', $data->__GET('updatedby')); oci_bind_by_name($stid, ':upd', $data->__GET('updatedate')); */ $r = oci_execute($stid, OCI_NO_AUTO_COMMIT); if (!$r) { echo "Desde el execute 2"; $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //Revertimos los cambios oci_rollback($this->conex); //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); return false; } //Libera los recursos oci_free_statement($stid); /*Insertando en la tabla FISC_APODERADO*/ //No ocurrió ningún fallo al insertar los datos de la denuncia /*Insertando en la tabla FISC_DOCUMENTOS $documentos = $data->__GET('documentos'); //$error = false; for($i=0;$i<count($documentos);$i++) { $consulta = "INSERT INTO FISC_DOC_DEN( id_denuncia, id_documento) values ( :id_den,:id_doc)"; $stid = oci_parse($this->conex, $consulta); if (!$stid) { echo "Desde el parse 3"; $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); oci_rollback($this->conex); //$error = true; //self::eliminar($id_den); //$e = oci_error($this->conex); //trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); return false; } oci_bind_by_name($stid, ':id_den', $id_den); oci_bind_by_name($stid, ':id_doc', $documentos[$i]); $r = oci_execute($stid, OCI_NO_AUTO_COMMIT); if (!$r) { echo "Desde el execute 3"; $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //$error = true; //self::eliminar($id_den); oci_rollback($this->conex); //$e = oci_error($stid); //trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); return false; } } Insertando en la tabla FISC_DOCUMENTOS*/ //Verificar existencia de Apoderado /* if( !isset($apoderado_result['ID_APODERADO'])) { //Insertando en la tabla FISC_APODERADO $nombres_apoderado = $data->__GET('nombres_apoderado'); $apellidos_apoderado = $data->__GET('apellidos_apoderado'); $consulta = "INSERT INTO FISC_APODERADO( id_apoderado, nombres_apoderado, apellidos_apoderado) values ( :id_apo, :name_apo, :ape_apo)"; $stid_apo = oci_parse($this->conex, $consulta); if (!$stid_apo) { echo "Desde el parse 4"; $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); oci_rollback($this->conex); //$error = true; //self::eliminar($id_den); //$e = oci_error($this->conex); //trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); return false; } oci_bind_by_name($stid_apo, ':id_apo', $id_apoderado); oci_bind_by_name($stid_apo, ':name_apo', $nombres_apoderado); oci_bind_by_name($stid_apo, ':ape_apo', $apellidos_apoderado); $execute_apo = oci_execute($stid_apo, OCI_NO_AUTO_COMMIT); if (!$execute_apo) { echo "Desde el execute 4"; $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //$error = true; //self::eliminar($id_den); oci_rollback($this->conex); //$e = oci_error($stid); //trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); return false; } //Insertando en la tabla FISC_APODERADO }//Verificar existencia de Apoderado */ $r = oci_commit($this->conex); if (!$r) { oci_close($this->conex); return false; } // Cierra la conexión Oracle oci_close($this->conex); return true; }
/** * {@inheritdoc} */ public function rollBack() { if (!oci_rollback($this->dbh)) { throw OCI8Exception::fromErrorInfo($this->errorInfo()); } $this->executeMode = OCI_COMMIT_ON_SUCCESS; return true; }
/** +---------------------------------------------------------- * 事务回滚 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return boolen +---------------------------------------------------------- * @throws ThinkExecption +---------------------------------------------------------- */ public function rollback() { if ($this->transTimes > 0) { $result = oci_rollback($this->_linkID); if (!$result) { throw_exception($this->error()); } $this->transTimes = 0; } return true; }
/** * Rollback a transaction * * @return boolean */ public function rollBack() { if ($this->connection === false) { $this->connect(); } return @oci_rollback($this->connection); }
public function __destruct() { if (is_resource($this->connection)) { @oci_rollback($this->connection); @oci_close($this->connection); } }
/** * Rolls back a transaction * * @throws \PDOException * @return bool TRUE on success or FALSE on failure. */ public function rollBack() { if (!$this->inTransaction()) { throw new \PDOException('There is no active transaction'); } if (oci_rollback($this->_dbh)) { $this->_inTransaction = false; return true; } return false; }
/** * Ends a non-successful transaction by using a rollback * @return void */ public function transactionRollback() { oci_rollback($this->linkDB); $this->bitTxOpen = false; }
while (ocifetchinto($sth2, $row2, OCI_ASSOC + OCI_RETURN_NULLS)) { $maxGoal = $row2['FUNDING_GOAL']; } if ($maxGoal < $currentFund + $amount * $max_count) { echo '<script type="text/javascript">'; echo 'alert("YOU HAVE EXCEEDED THE FUNDING GOAL!");'; echo 'window.location.href = "myProjectView.php";'; echo '</script>'; } else { //not similiar package // prepare $sql = "insert into package ( project_id, amount, max_count, package_reward) values ( :project_id, :amount, :max_count, :package_reward)"; $sth = oci_parse($dbh, $sql); // execute //oci_bind_by_name($sth, ':package_id', $package_id); oci_bind_by_name($sth, ':project_id', $project_id); oci_bind_by_name($sth, ':amount', $amount); oci_bind_by_name($sth, ':max_count', $max_count); oci_bind_by_name($sth, ':package_reward', $package_reward); oci_execute($sth, OCI_DEFAULT); $error = oci_error($sth); if ($error['code']) { echo "<p>Error updating database.</p>"; oci_rollback($dbh); exit; } oci_commit($dbh); header('Location: theProjectView.php?id=' . $project_id); } } }
/** * Roll back a transaction and return to autocommit mode. * * @return void * @throws Zend_Db_Adapter_Oracle_Exception */ protected function _rollBack() { if (!oci_rollback($this->_connection)) { throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection)); } $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); }
/** * Execute Queries for Oracle Database * * @param type $sql * @param type $connection */ function executeQueryOci($sql, $connection, $aParameter = array()) { $aDNS = $connection->getDSN(); $sUsername = $aDNS["username"]; $sPassword = $aDNS["password"]; $sHostspec = $aDNS["hostspec"]; $sDatabse = $aDNS["database"]; $sPort = $aDNS["port"]; if ($sPort != "1521") { // if not default port $conn = oci_connect($sUsername, $sPassword, $sHostspec . ":" . $sPort . "/" . $sDatabse); } else { $conn = oci_connect($sUsername, $sPassword, $sHostspec . "/" . $sDatabse); } if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); return $e; } switch (true) { case preg_match("/^(SELECT|SHOW|DESCRIBE|DESC|WITH)\\s/i", $sql): $stid = oci_parse($conn, $sql); if (count($aParameter) > 0) { foreach ($aParameter as $key => $val) { oci_bind_by_name($stid, $key, $val); } } oci_execute($stid, OCI_DEFAULT); $result = array(); $i = 1; while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $result[$i++] = $row; } oci_free_statement($stid); oci_close($conn); return $result; break; case preg_match("/^(INSERT|UPDATE|DELETE)\\s/i", $sql): $stid = oci_parse($conn, $sql); $isValid = true; if (count($aParameter) > 0) { foreach ($aParameter as $key => $val) { oci_bind_by_name($stid, $key, $val); } } $objExecute = oci_execute($stid, OCI_DEFAULT); $result = oci_num_rows($stid); if ($objExecute) { oci_commit($conn); } else { oci_rollback($conn); $isValid = false; } oci_free_statement($stid); oci_close($conn); if ($isValid) { return $result; } else { return oci_error(); } break; default: // Stored procedures $stid = oci_parse($conn, $sql); $aParameterRet = array(); if (count($aParameter) > 0) { foreach ($aParameter as $key => $val) { $aParameterRet[$key] = $val; // The third parameter ($aParameterRet[$key]) returned a value by reference. oci_bind_by_name($stid, $key, $aParameterRet[$key]); } } $objExecute = oci_execute($stid, OCI_DEFAULT); oci_free_statement($stid); oci_close($conn); return $aParameterRet; break; } }
/** * Roll back a transaction and return to autocommit mode. * * @return void * @throws Zend_Db_Adapter_Oracle_Exception */ protected function _rollBack() { if (!oci_rollback($this->_connection)) { /** * @see Zend_Db_Adapter_Oracle_Exception */ require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection)); } $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); }
/** * Roll back ( undo ) the current transaction. * @throws SQLException * @return void */ protected function rollbackTrans() { $result = oci_rollback($this->dblink); if (!$result) { throw new SQLException('Unable to rollback transaction', $this->nativeError()); } $this->execMode = OCI_COMMIT_ON_SUCCESS; }
/** * Makes sure each database and extension handles BEGIN, COMMIT and ROLLBACK * * @param string &$sql The SQL to check for a transaction query * @param string $result_class The type of result object to create * @return mixed `FALSE` if normal processing should continue, otherwise an object of the type $result_class */ private function handleTransactionQueries(&$sql, $result_class) { // SQL Server supports transactions, but starts then with BEGIN TRANSACTION if ($this->type == 'mssql' && preg_match('#^\\s*(begin|start(\\s+transaction)?)\\s*#i', $sql)) { $sql = 'BEGIN TRANSACTION'; } $begin = FALSE; $commit = FALSE; $rollback = FALSE; // Track transactions since most databases don't support nesting if (preg_match('#^\\s*(begin|start)(\\s+(transaction|work))?\\s*$#iD', $sql)) { if ($this->inside_transaction) { throw new fProgrammerException('A transaction is already in progress'); } $this->inside_transaction = TRUE; $begin = TRUE; } elseif (preg_match('#^\\s*(commit)(\\s+(transaction|work))?\\s*$#iD', $sql)) { if (!$this->inside_transaction) { throw new fProgrammerException('There is no transaction in progress'); } $this->inside_transaction = FALSE; $commit = TRUE; } elseif (preg_match('#^\\s*(rollback)(\\s+(transaction|work))?\\s*$#iD', $sql)) { if (!$this->inside_transaction) { throw new fProgrammerException('There is no transaction in progress'); } $this->inside_transaction = FALSE; $rollback = TRUE; } if (!$begin && !$commit && !$rollback) { return FALSE; } // The PDO, OCI8 and SQLSRV extensions require special handling through methods and functions $is_pdo = $this->extension == 'pdo'; $is_oci = $this->extension == 'oci8'; $is_sqlsrv = $this->extension == 'sqlsrv'; $is_ibm_db2 = $this->extension == 'ibm_db2'; if (!$is_pdo && !$is_oci && !$is_sqlsrv && !$is_ibm_db2) { return FALSE; } $this->statement = $sql; // PDO seems to act weird if you try to start transactions through a normal query call if ($is_pdo) { try { $is_mssql = $this->type == 'mssql' && substr($this->database, 0, 4) != 'dsn:'; $is_oracle = $this->type == 'oracle' && substr($this->database, 0, 4) != 'dsn:'; if ($begin) { // The SQL Server PDO object hasn't implemented transactions if ($is_mssql) { $this->connection->exec('BEGIN TRANSACTION'); } elseif ($is_oracle) { $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); } else { $this->connection->beginTransaction(); } } elseif ($commit) { if ($is_mssql) { $this->connection->exec('COMMIT'); } elseif ($is_oracle) { $this->connection->exec('COMMIT'); $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, TRUE); } else { $this->connection->commit(); } } elseif ($rollback) { if ($is_mssql) { $this->connection->exec('ROLLBACK'); } elseif ($is_oracle) { $this->connection->exec('ROLLBACK'); $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, TRUE); } else { $this->connection->rollBack(); } } } catch (Exception $e) { $db_type_map = array('db2' => 'DB2', 'mssql' => 'MSSQL', 'mysql' => 'MySQL', 'oracle' => 'Oracle', 'postgresql' => 'PostgreSQL', 'sqlite' => 'SQLite'); throw new fSQLException('%1$s error (%2$s) in %3$s', $db_type_map[$this->type], $e->getMessage(), $sql); } } elseif ($is_oci) { if ($commit) { oci_commit($this->connection); } elseif ($rollback) { oci_rollback($this->connection); } } elseif ($is_sqlsrv) { if ($begin) { sqlsrv_begin_transaction($this->connection); } elseif ($commit) { sqlsrv_commit($this->connection); } elseif ($rollback) { sqlsrv_rollback($this->connection); } } elseif ($is_ibm_db2) { if ($begin) { db2_autocommit($this->connection, FALSE); } elseif ($commit) { db2_commit($this->connection); db2_autocommit($this->connection, TRUE); } elseif ($rollback) { db2_rollback($this->connection); db2_autocommit($this->connection, TRUE); } } if ($result_class) { $result = new $result_class($this); $result->setSQL($sql); $result->setResult(TRUE); return $result; } return TRUE; }
protected function doRollback($fname = __METHOD__) { if ($this->mTrxLevel) { oci_rollback($this->mConn); $this->mTrxLevel = 0; $this->doQuery('SET CONSTRAINTS ALL IMMEDIATE'); } }
/** * Rollback Transaction * * @return bool */ public function trans_rollback() { // When transactions are nested we only begin/commit/rollback the outermost ones if (!$this->trans_enabled or $this->_trans_depth > 0) { return TRUE; } $this->commit_mode = OCI_COMMIT_ON_SUCCESS; return oci_rollback($this->conn_id); }
/** * Rollback changes in a transaction. * @param string optional savepoint name * @return void * @throws DibiDriverException */ public function rollback($savepoint = NULL) { if (!oci_rollback($this->connection)) { $err = oci_error($this->connection); throw new DibiDriverException($err['message'], $err['code']); } $this->autocommit = TRUE; }