/** * *@param $id_ciu * * **/ public function queryByIC($id_ciu) { $this->conex = DataBase::getInstance(); $stid = oci_parse($this->conex, "SELECT * FROM TBL_REPRESENTANTEEMPRESAS WHERE CLV_REPRESENTANTE=:id_ciu"); if (!$stid) { $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Realizar la lógica de la consulta oci_bind_by_name($stid, ':id_ciu', $id_ciu); $r = oci_execute($stid); if (!$r) { $e = oci_error($stid); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $result = new RepresentanteEmpresa(); // Obtener los resultados de la consulta while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $it = new ArrayIterator($fila); while ($it->valid()) { $result->__SET(strtolower($it->key()), $it->current()); $it->next(); } } //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); //retorna el resultado de la consulta return $result; }
/** * Obtiene el SQL de la funcion especificada * @return String or false */ protected function getObjectSql() { if ($this->remote) { $sql = "select line, text from all_source where name = UPPER(:v_function_name) and type = :v_object_type order by name, type, line"; } else { $sql = "select line, text from user_source where name = UPPER(:v_function_name) and type = :v_object_type order by name, type, line"; } $stmt = oci_parse($this->getConnection(), $sql); oci_bind_by_name($stmt, ":v_function_name", $this->objectName); oci_bind_by_name($stmt, ":v_object_type", $this->objectType); if (!@oci_execute($stmt)) { $e = oci_error($stmt); $this->setMensaje("Error al obtener el SQL del objeto {$this->objectType} '{$this->objectName}' - {$e['message']}"); return false; } $sqlResult = ''; while ($row = oci_fetch_array($stmt, OCI_ASSOC | OCI_RETURN_NULLS)) { $sqlResult .= $row['TEXT']; } $this->sourceSql = $sqlResult; if (empty($sqlResult)) { $this->setMensaje("No se pudo obtener el SQL del objeto {$this->objectType} '{$this->objectName}'"); return false; } return $this->sourceSql; }
function get_Roadnet_xml($r) { $xml = '<?xml version="1.0" encoding="utf-8"?> <roads>'; $roadid = null; $roadname = null; while ($row = oci_fetch_array($r, OCI_BOTH)) { if ($roadid == null || $roadid != $row['ROAD_ID']) { if ($roadid != null) { $xml .= "</road>\n"; } $xml .= "<road>\n"; $xml .= "<roadid>" . $row['ROAD_ID'] . "</roadid>\n"; if ($row['ROADSTATUS'] != null) { $xml .= "<roadstatus>" . $row['ROADSTATUS'] . "</roadstatus>\n"; } else { $xml .= "<roadstatus>" . '0' . "</roadstatus>\n"; } } $xml .= "<node>\n"; $xml .= "<nodeid>" . $row['NODEID'] . "</nodeid>\n"; $xml .= "<nodx>" . $row['NODEX'] . "</nodx>\n"; $xml .= "<nody>" . $row['NODEY'] . "</nody>\n"; $xml .= "<nodeindex>" . $row['NODEINDEX'] . "</nodeindex>\n"; $xml .= "</node>\n"; if ($roadid != $row['ROAD_ID']) { $roadid = $row['ROAD_ID']; } } $xml .= "</road>\n"; $xml .= "</roads>"; return $xml; }
function fetchAndUpdateFacultyInfo($query, $conn, $nextPage) { $stid = oci_parse($conn, $query); var_dump($query); oci_execute($stid); echo "<form action=\"{$nextPage}?user=FACULTY\">"; echo "<table border='1'>\n"; while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $i = 1; foreach ($row as $item) { echo "<tr>\n"; $column_name = oci_field_name($stid, $i); echo "<td> {$column_name} </td>\n"; if ($column_name == "UnityId" || $column_name == "FacultyNo" || $column_name == "Balance" || $column_name == "Type" || $column_name == "Category" || $column_name == "isHeld" || $column_name == "Department") { echo " <td>" . "<input type=\"text\" name=\"{$column_name}\" value=\"{$item}\" readonly>" . "</td>\n"; } else { echo " <td>" . "<input type=\"text\" name=\"{$column_name}\" value=\"{$item}\" >" . "</td>\n"; } $i++; echo "</tr>\n"; } } echo "</table>\n"; echo "<input type=\"submit\" value=\"Update\">"; echo "</form>"; }
/** * Function takes in an sql statement and returns data as an array. When calling, always alias * resuts returned from stored function as 'dataArray' */ function executeQuery($SQLstatement, $parserFunction = "defaultFunction") { $conn = $GLOBALS['oracle_connection']; if (!$conn) { return array('error' => oci_error()); } $preparedStatement = oci_parse($conn, $SQLstatement); //Prepare statement $success = oci_execute($preparedStatement); //execute preparedStatement if (!$success) { return array('error' => oci_error($preparedStatement)); } $arrayOfDataReturned = array(); //Array containing all data returned from result set $currentRecord; //temp user for each result set while ($functionResults = oci_fetch_array($preparedStatement, OCI_ASSOC)) { //Get first class in result set /**Calls variable function; SEE: http://www.php.net/manual/en/functions.variable-functions.php**/ $currentRecord = $parserFunction($functionResults); //Convert information array to class array_push($arrayOfDataReturned, $currentRecord); //push created object into all classes array //echo($allStudentClasses[0]->term + "<br />"); } oci_free_statement($preparedStatement); return $arrayOfDataReturned; }
function get_list($data) { $results = array(); $games = array(); $conn = oci_connect('malz', '1Qaz2wsx', '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=db1.chpc.ndsu.nodak.edu)(Port=1521)))(CONNECT_DATA=(SID=cs)))'); //Select customer with last name from field $userQuery = 'select userName from Account where listId = :data'; $listQuery = 'select * from ListGame, Game where listId = :data and ListGame.gameId = Game.gameId'; $stid = oci_parse($conn, $userQuery); $stid2 = oci_parse($conn, $listQuery); oci_bind_by_name($stid, ':data', $data); oci_bind_by_name($stid2, ':data', $data); oci_execute($stid, OCI_DEFAULT); //iterate through each row while ($row = oci_fetch_array($stid, OCI_ASSOC)) { $results[] = $row; } oci_execute($stid2, OCI_DEFAULT); while ($row = oci_fetch_array($stid2, OCI_ASSOC)) { $games[] = $row; } $results[] = $games; echo json_encode($results); oci_free_statement($stid); oci_free_statement($stid2); oci_close($conn); }
/** * *@param $id_ciu * * **/ public function getById($id_jefe) { $this->conex = DataBase::getInstance(); //Consulta SQL $consulta = "SELECT * FROM FISC_JEFE_OFICINA WHERE \n\t\t\t\t\t\tID_JEFE=:id_jefe"; $stid = oci_parse($this->conex, $consulta); if (!$stid) { $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Realizar la lógica de la consulta oci_bind_by_name($stid, ':id_jefe', $id_jefe); $r = oci_execute($stid); if (!$r) { $e = oci_error($stid); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $result = array(); // Obtener los resultados de la consulta while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $it = new ArrayIterator($fila); $alm = new Denuncia(); while ($it->valid()) { $alm->__SET(strtolower($it->key()), $it->current()); $it->next(); } $result[] = $alm; } //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); //retorna el resultado de la consulta return $result; }
function have_right_on($right, $url) { $rights = oci_parse($GLOBALS['conn'], "SELECT {$right} " . " FROM vu_userrights " . " WHERE user_id = {$_SESSION['user_id']} " . "\t\tAND\tcompany_ref_id = {$_SESSION['company_id']} " . " AND url = '{$url}' "); oci_execute($rights); $row = oci_fetch_array($rights); return $row[0] === 'Yes'; }
public function fetch($limit = -1) { if ($this->___n > 0) { $this->___limit++; if ($this->___limit == $limit) { $this->___limit = -1; return false; } if (!$this->___is_oci_) { foreach ($this->___result as $result) { foreach ($result as $name => $value) { if (!is_int($name)) { $name = strtolower($name); $this[$name] = $this->getfieldvalue($value); } } return true; } return false; } else { while ($result = oci_fetch_array($this->___result)) { foreach ($result as $name => $value) { if (!is_int($name)) { $name = strtolower($name); $this[$name] = $this->getfieldvalue($value); } } return true; } oci_free_statement($this->___result); return false; } } }
function cargarArray($sentencia) { include dirname(__FILE__) . '/conectar_ORACLE.php'; $array = array(); $sentenciaExec = oci_parse($c, $sentencia); oci_execute($sentenciaExec); $error = 0; $k = 0; $ncols = oci_num_fields($sentenciaExec); for ($i = 1; $i <= $ncols; ++$i) { $colname = oci_field_name($sentenciaExec, $i); $array[0][$k] = $colname; $k++; } $cont = 0; $j = 1; $k = 0; while ($row = oci_fetch_array($sentenciaExec, OCI_BOTH + OCI_RETURN_NULLS)) { while ($cont < $ncols) { $array[$j][$cont] = $row[$cont]; $cont++; } $cont = 0; $k = 0; $j++; } if (oci_num_rows($sentenciaExec) == 0) { oci_free_statement($sentenciaExec); return false; } else { oci_free_statement($sentenciaExec); return $array; } }
public function buscarPorProcedimiento() { $sql = "SELECT job, to_char(last_date, 'DD/MM/YYYY') last_date, last_sec, to_char(next_date, 'DD/MM/YYYY') next_date, next_sec, interval, failures, what from user_jobs WHERE UPPER(what) LIKE UPPER('%' || :v_procedure_name || '%')"; $stmt = oci_parse($this->getConnection(), $sql); oci_bind_by_name($stmt, ":v_procedure_name", $this->objectName); if (!@oci_execute($stmt)) { $e = oci_error($stmt); $this->setMensaje("Error al obtener los datos del job que ejecuta el proceso '{$this->objectName}' de la tabla user_jobs - {$e['message']}"); $this->setEstado(false); } $row = oci_fetch_array($stmt, OCI_ASSOC | OCI_RETURN_NULLS); if (empty($row)) { $this->setEstado(false); } $this->jobId = $row['JOB']; $this->lastDate = $row['LAST_DATE']; $this->lastSec = $row['LAST_SEC']; $this->nextDate = $row['NEXT_DATE']; $this->nextSec = $row['NEXT_SEC']; $this->interval = $row['INTERVAL']; $this->failures = $row['FAILURES']; $this->jobSql = $row['WHAT']; $this->setEstado(true); return $this->getEstado(); }
protected function getDetalle() { $sql = "SELECT synonym_name, table_owner, table_name, db_link FROM user_synonyms WHERE synonym_name = UPPER(:v_synonym_name)"; $stmt = oci_parse($this->getConnection(), $sql); oci_bind_by_name($stmt, ":v_synonym_name", $this->objectName); if (!@oci_execute($stmt)) { $e = oci_error($stmt); $this->setMensaje("Error al obtener los datos del sinónimo '{$this->objectName}' de la tabla user_synonyms - {$e['message']}"); $this->setEstado(false); return false; } $row = oci_fetch_array($stmt, OCI_ASSOC | OCI_RETURN_NULLS); if (empty($row)) { $sqlPublic = "SELECT * FROM all_synonyms WHERE synonym_name = UPPER(:v_synonym_name) AND owner = 'PUBLIC'"; $stmt2 = oci_parse($this->getConnection(), $sqlPublic); oci_bind_by_name($stmt2, ":v_synonym_name", $this->objectName); if (!@oci_execute($stmt2)) { $e = oci_error($stmt2); $this->setMensaje("Error al obtener los datos del sinónimo '{$this->objectName}' de la tabla all_synonyms - {$e['message']}"); $this->setEstado(false); return false; } $row = oci_fetch_array($stmt2, OCI_ASSOC | OCI_RETURN_NULLS); if (empty($row)) { $this->setMensaje("No se encontró el sinónimo '{$this->objectName}' en la tabla user_synonyms"); $this->setEstado(false); return false; } } $this->tableOwner = $row['TABLE_OWNER']; $this->tableName = $row['TABLE_NAME']; $this->dbLinkName = $row['DB_LINK']; $this->setEstado(true); return true; }
public function getById($id) { $this->conex = DataBase::getInstance(); $stid = oci_parse($this->conex, "SELECT *\n\t\t\tFROM FISC_CIUDADANO WHERE ID_CIUDADANO=:id"); if (!$stid) { $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Realizar la lógica de la consulta oci_bind_by_name($stid, ':id', $id); $r = oci_execute($stid); if (!$r) { $e = oci_error($stid); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Obtener los resultados de la consulta $alm = new FiscCiudadano(); while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $it = new ArrayIterator($fila); while ($it->valid()) { $alm->__SET(strtolower($it->key()), $it->current()); $it->next(); } } //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); //retorna el resultado de la consulta return $alm; }
public function fetch_db_flash_cache_detail($conn_db) { global $error; $sql = "select name, value from v\$parameter where name like 'db_flash_cache_%'"; $state_id = oci_parse($conn_db, $sql); $result = oci_execute($state_id); if ($result == FALSE) { $error->set_msg("Failed SQL = '$sql'"); return(ERROR); } while ($row = oci_fetch_array($state_id, OCI_BOTH)) { if ($row['NAME'] == 'db_flash_cache_file') { if (isset($row['VALUE'])) { $db_flash_cache_file = $row['VALUE']; } else { $db_flash_cache_file = ''; } } if ($row['NAME'] == 'db_flash_cache_size') { if (isset($row['VALUE'])) { $db_flash_cache_size = $row['VALUE']; } else { $db_flash_cache_size = '0'; } } } if (!empty($db_flash_cache_file)) { $db_flash_cache_enable = TRUE; } else { $db_flash_cache_enable = FALSE; } $array_db_flash_cache_detail = array('enable' => $db_flash_cache_enable, 'file' => $db_flash_cache_file, 'size' => $db_flash_cache_size); return($array_db_flash_cache_detail); }
public function getDetalle() { $sql = "SELECT trigger_name, trigger_type, triggering_event, table_name, status, description, trigger_body FROM user_triggers WHERE trigger_name = UPPER(:v_trigger_name)"; $stmt = oci_parse($this->getConnection(), $sql); oci_bind_by_name($stmt, ":v_trigger_name", $this->objectName); if (!@oci_execute($stmt)) { $e = oci_error($stmt); $this->setMensaje("Error al obtener los datos del trigger '{$this->objectName}' de la tabla user_triggers - {$e['message']}"); return false; } $row = oci_fetch_array($stmt, OCI_ASSOC | OCI_RETURN_NULLS); if (empty($row)) { $this->setMensaje("No se pudo encontrar el trigger especificado en la tabla user_triggers"); return false; } $this->triggerType = $row['TRIGGER_TYPE']; $this->triggeringEvent = $row['TRIGGERING_EVENT']; $this->affectedTable = $row['TABLE_NAME']; $this->triggerStatus = $row['STATUS']; $this->description = $row['DESCRIPTION']; $this->triggerSql = $row['TRIGGER_BODY']; if ($this->triggerStatus != 'ENABLED') { $this->setMensaje("El trigger se encuentra inhabilitado"); return false; } return true; }
/** * @access public * @return bool */ public function hasNext() { if (count($this->_rowBuffer) >= Oci8Iterator::RECORD_BUFFER) { return true; } else { if (is_null($this->_cursor)) { return count($this->_rowBuffer) > 0; } else { $row = oci_fetch_array($this->_cursor, OCI_ASSOC + OCI_RETURN_NULLS); if ($row) { $row = array_change_key_case($row, CASE_LOWER); $sr = new SingleRow($row); $this->_currentRow++; // Enfileira o registo array_push($this->_rowBuffer, $sr); // Traz novos até encher o Buffer if (count($this->_rowBuffer) < DBIterator::RECORD_BUFFER) { $this->hasNext(); } return true; } else { oci_free_statement($this->_cursor); $this->_cursor = null; return count($this->_rowBuffer) > 0; } } } }
public function getUserObjectData() { $sql = "SELECT object_name, object_type, TO_CHAR(created, 'DD/MM/YYYY') AS created, TO_CHAR(last_ddl_time, 'DD/MM/YYYY') AS last_ddl_time, status FROM user_objects WHERE object_name = UPPER(:v_obj_name) AND object_type = UPPER(:v_obj_type)"; $stmt = oci_parse($this->getConnection(), $sql); oci_bind_by_name($stmt, ":v_obj_name", $this->objectName); oci_bind_by_name($stmt, ":v_obj_type", $this->objectType); if (!@oci_execute($stmt)) { $e = oci_error($stmt); $this->setMensaje("Error al obtener los datos del objeto '{$this->objectName}' de la tabla user_objects - {$e['message']}"); return false; } $row = @oci_fetch_array($stmt, OCI_ASSOC | OCI_RETURN_NULLS); if (empty($row)) { $this->setMensaje("No se pudo encontrar el objeto '{$this->objectName}' en la tabla user_objects"); return false; } $this->fechaCreacion = $row['CREATED']; $this->fechaModificacion = $row['LAST_DDL_TIME']; $this->oracleStatus = $row['STATUS']; if ($this->oracleStatus != 'VALID') { $this->setMensaje("El objeto '{$this->objectName}' tiene el estado '{$this->oracleStatus}' en la tabla user_objects"); return false; } return true; }
public function fetchArray($mode = OCI_BOTH) { set_error_handler(static::getErrorHandler()); $row = oci_fetch_array($this->resource, $mode); restore_error_handler(); return $row; }
/** * @see ResultSet::next() */ function next() { // no specific result position available // Returns an array, which corresponds to the next result row or FALSE // in case of error or there is no more rows in the result. $this->fields = oci_fetch_array($this->result, $this->fetchmode + OCI_RETURN_NULLS + OCI_RETURN_LOBS); if (!$this->fields) { // grab error via array $error = oci_error($this->result); if (!$error) { // end of recordset $this->afterLast(); return false; } else { throw new SQLException('Error fetching result', $error['code'] . ': ' . $error['message']); } } // Oracle returns all field names in uppercase and associative indices // in the result array will be uppercased too. if ($this->fetchmode === ResultSet::FETCHMODE_ASSOC && $this->lowerAssocCase) { $this->fields = array_change_key_case($this->fields, CASE_LOWER); } // Advance cursor position $this->cursorPos++; return true; }
function cargarArray($FUPE_CD_PROMOTOR, $FUPE_FE_ESTADO_DESDE, $FUPE_FE_ESTADO_HASTA, $queries) { include dirname(__FILE__) . '/conectar_ORACLE.php'; //echo $queries.";<br /><br />"; $array = array(); $query = oci_parse($c, $queries); oci_execute($query); $error = 0; $ncols = oci_num_fields($query); $cont = 0; $j = 0; $k = 0; while ($row = oci_fetch_array($query, OCI_BOTH + OCI_RETURN_NULLS)) { while ($cont < $ncols) { $array[$j][$cont] = $row[$cont]; $cont++; } $cont = 0; $k = 0; $j++; } if (oci_num_rows($query) == 0) { return false; } else { return $array; } }
function get_filteredGames($data) { // The connection string is loooooooong. It's easiest to copy/paste this line. Remember to replace 'username' and 'password'! $conn = oci_connect('malz', '1Qaz2wsx', '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=db1.chpc.ndsu.nodak.edu)(Port=1521)))(CONNECT_DATA=(SID=cs)))'); if ($data === 'all') { $results = array(); $query = 'select * from Game'; $stid = oci_parse($conn, $query); oci_bind_by_name($stid, ':data', $data); oci_execute($stid); //iterate through each row while ($row = oci_fetch_array($stid, OCI_ASSOC)) { $results[] = $row; } echo json_encode($results); oci_free_statement($stid); oci_close($conn); } else { $results = array(); $data = $data . '%'; $query = 'select * from Game where gameName like :data'; $stid = oci_parse($conn, $query); oci_bind_by_name($stid, ':data', $data); oci_execute($stid); //iterate through each row while ($row = oci_fetch_array($stid, OCI_ASSOC)) { $results[] = $row; } echo json_encode($results); oci_free_statement($stid); oci_close($conn); } }
/** * Returns a row from a resultset. * * @return array|boolean The next row in the resultset or false if there * are no more results. */ protected function _fetchArray() { $array = oci_fetch_array($this->_result, $this->_map[$this->_fetchMode] | OCI_RETURN_NULLS); if ($array) { $array = array_change_key_case($array, CASE_LOWER); } return $array; }
function getRequetes($from, $conn) { $req = "SELECT distinct(count(*)) from {$from}"; $cur = PreparerRequete($conn, $req); $r = ExecuterRequete($cur); $return = oci_fetch_array($cur); oci_free_statement($cur); return $return; }
private function fetch_next() { if ($row = oci_fetch_array($this->stmt, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) { $row = array_change_key_case($row, CASE_LOWER); unset($row['oracle_rownum']); array_walk($row, array('oci_native_moodle_database', 'onespace2empty')); } return $row; }
public function SelectRecord($sql, $conn) { $parse = oci_parse($sql, $conn); oci_execute($parse); while ($row = oci_fetch_array($parse)) { array_push($this->returnArray, $row); } return json_encode($this->returnArray); }
public function SelectFrom($query) { $conn = $this->Connection(); $parse = oci_parse($conn, $query); oci_execute($parse); while ($row = oci_fetch_array($parse)) { array_push($this->response, $row); } return $this->response; }
public function getAll($tSql) { $stid = oci_parse($this->db, $tSql); $r = oci_execute($stid); $tDatas = array(); while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $tDatas[] = $row; } return $tDatas; }
public function exist($conn_db, $name) { $state_id = oci_parse($conn_db, "SELECT count(*) FROM user$ WHERE type# = 0 and name = '" . CLOUD_USER . "'"); $result = oci_execute($state_id); $row = oci_fetch_array($state_id, OCI_BOTH); if ($row[0] == '1') { return(TRUE); } else { return(FALSE); } }
function getOneColumnAsArray() { $column = array(); $queryId = $this->connection->executeStatement($this->getStatement()); while (is_array($row = oci_fetch_array($queryId, OCI_NUM + OCI_RETURN_NULLS))) { $column[] = $row[0]; } oci_free_statement($queryId); return $column; }
/** * Met les résultats d'une requête dans un tableau */ public static function tableau($data) { $donnees = array(); $i = 0; while ($tab = oci_fetch_array($data)) { $donnees[$i] = $tab; $i++; } return $donnees; }