Exemple #1
0
             echo "<font face=Verdana size=-2 color=green><b>Query#" . $num . " : " . htmlspecialchars($query) . "</b></font><br>";
             $stat = @ociparse($db, $query);
             @ociexecute($stat);
             if ($error = @ocierror()) {
                 echo "<table width=100%><tr><td><font face=Verdana size=-2>Error : <b>" . $error['message'] . "</b></font></td></tr></table><br>";
             } else {
                 $rowcount = @ocirowcount($stat);
                 if ($rowcount != 0) {
                     echo "<table width=100%><tr><td><font face=Verdana size=-2>affected rows : <b>" . $rowcount . "</b></font></td></tr></table><br>";
                 } else {
                     echo "<table width=100%><tr>";
                     for ($j = 1; $j <= @ocinumcols($stat); $j++) {
                         echo "<td bgcolor=#cccccc><font face=Verdana size=-2><b>&nbsp;" . htmlspecialchars(@ocicolumnname($stat, $j)) . "&nbsp;</b></font></td>";
                     }
                     echo "</tr>";
                     while (ocifetch($stat)) {
                         echo "<tr>";
                         for ($j = 1; $j <= @ocinumcols($stat); $j++) {
                             echo "<td><font face=Verdana size=-2>&nbsp;" . htmlspecialchars(@ociresult($stat, $j)) . "&nbsp;</font></td>";
                         }
                         echo "</tr>";
                     }
                     echo "</table><br>";
                 }
                 @ocifreestatement($stat);
             }
         }
     }
     @ocilogoff($db);
 }
 break;
Exemple #2
0
 function nextid($seqname)
 {
     $this->connect();
     $Query_ID = @ociparse($this->Link_ID, "SELECT {$seqname}.NEXTVAL FROM DUAL");
     if (!@ociexecute($Query_ID)) {
         $this->Error = @OCIError($Query_ID);
         if ($this->Error["code"] == 2289) {
             $Query_ID = ociparse($this->Link_ID, "CREATE SEQUENCE {$seqname}");
             if (!ociexecute($Query_ID)) {
                 $this->Error = OCIError($Query_ID);
                 $this->Errors->addError("Database error: " . $this->Error["message"]);
                 return 0;
             } else {
                 $Query_ID = ociparse($this->Link_ID, "SELECT {$seqname}.NEXTVAL FROM DUAL");
                 ociexecute($Query_ID);
             }
         }
     }
     if (ocifetch($Query_ID)) {
         $next_id = ociresult($Query_ID, "NEXTVAL");
     } else {
         $next_id = 0;
     }
     ocifreestatement($Query_ID);
     return $next_id;
 }
<html>
  <body>
  <?php 
$connect = oci_connect("lp10", "d3whrc2", "iutdb");
//Connexion à la base
$stmt = ociparse($connect, "select * from PLANTE");
//On parse la requête à effectuer sans oublier de lui passer la chaine de connexion en paramêtre
ociexecute($stmt, OCI_DEFAULT);
//On execute la requête en lui passant l'option OCI_DEFAULT
echo "Début----<br>\n\n";
while (ocifetch($stmt)) {
    //On parcourt les résultats
    echo ociresult($stmt, 1);
    //On récupère le premier champ de la ma_table
    echo ociresult($stmt, 2);
    //On récupère le deuxième champ de la ma_table
}
echo "<br>----fin\n\n";
ocilogoff($connect);
//On se déconnecte du serveur
?>
  </body>
</html>
<body>
<h1>PHP und Oracle</h1>
<table border="1">
<tr>
    <th>Interpret</th>
    <th>Titel</th>
    <th>Jahr</th>
</tr>
<?php 
$db = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)\r\n       (HOST=localhost) (PORT=1521)))\r\n       (CONNECT_DATA=(SERVICE_NAME=xe)))";
// Oracle 10g
//$db="//localhost/xe";
$c = ocilogon("hr", "geheim", $db);
$s = ociparse($c, "SELECT * FROM cds");
if (ociexecute($s)) {
    while (ocifetch($s)) {
        echo "<tr>";
        echo "<td>" . ociresult($s, "INTERPRET") . "</td>";
        echo "<td>" . ociresult($s, "TITEL") . "</td>";
        echo "<td>" . ociresult($s, "JAHR") . "</td>";
        echo "</tr>";
    }
} else {
    $e = oci_error($s);
    echo htmlentities($e['message']);
}
?>
</table>
</body>
</html>
 /**
  * db::fetch_row()		Alias to {DB}_fetch_row()
  * 
  * @param string $result
  * @return 
  **/
 function fetch_row($result = "")
 {
     global $GonxAdmin;
     switch ($GonxAdmin["dbtype"]) {
         case "mysql":
             $this->dbResultLine = @mysql_fetch_row($result);
             break;
         case "postgresql":
             $this->dbResultLine = @pg_fetch_row($result, 0);
             break;
         case "oracle":
             $this->dbResultLine = @ocifetch($result);
             break;
         case "sqlite":
             break;
         case "mssql":
             $this->dbResultLine = @mssql_fetch_row($result);
             break;
     }
     // switch
     return $this->dbResultLine;
 }
 function currentid($seqname)
 {
     $this->connect();
     $Query_ID = @ociparse($this->Link_ID, "SELECT {$seqname}.CURRVAL FROM DUAL");
     @ociexecute($Query_ID);
     if (@ocifetch($Query_ID)) {
         $current_id = ociresult($Query_ID, "CURRVAL");
     } else {
         $current_id = 0;
     }
     ocifreestatement($Query_ID);
     return $current_id;
 }
Exemple #7
0
 /**
  * 分页算法从 adodb 修改
  */
 function selectLimit($sql, $length = 'ALL', $offset = 0)
 {
     if (strpos($sql, '/*+') !== false) {
         $sql = str_replace('/*+ ', '/*+FIRST_ROWS ', $sql);
     } else {
         $sql = preg_replace('/^[ \\t\\n]*SELECT/i', 'SELECT /*+FIRST_ROWS*/', $sql);
     }
     $selectOffsetAlg1 = 100;
     $inputarr = array();
     if ($offset < $selectOffsetAlg1) {
         if ($length > 0) {
             if ($offset > 0) {
                 $length += $offset;
             }
             $sql = "SELECT * FROM ({$sql}) WHERE ROWNUM <= :length";
             $inputarr['length'] = $length;
         }
         $stmt = $this->execute($sql, $inputarr);
         for ($i = 0; $i < $offset; $i++) {
             ocifetch($stmt);
         }
         return $stmt;
     } else {
         // Algorithm by Tomas V V Cox, from PEAR DB oci8.php
         // Let Oracle return the name of the columns
         $qfields = "SELECT * FROM ({$sql}) WHERE NULL = NULL";
         $stmt = ociparse($this->conn, $qfields);
         if (!$stmt) {
             return false;
         }
         if (is_array($inputarr)) {
             foreach (array_keys($inputarr) as $k) {
                 ocibindbyname($stmt, $k, $inputarr[$k], -1);
             }
         }
         if (!ociexecute($stmt, OCI_DEFAULT)) {
             ocifreestatement($stmt);
             return false;
         }
         $ncols = ocinumcols($stmt);
         for ($i = 1; $i <= $ncols; $i++) {
             $cols[] = '"' . ocicolumnname($stmt, $i) . '"';
         }
         ocifreestatement($stmt);
         $fields = implode(', ', $cols);
         $length += $offset;
         $offset += 1;
         // in Oracle rownum starts at 1
         $sql = "SELECT {$fields} FROM " . "(SELECT rownum as adodb_rownum, {$fields} FROM " . "({$sql})" . ' WHERE rownum <= :adodb_nrows) WHERE adodb_rownum >= :adodb_offset';
         $inputarr['adodb_nrows'] = $length;
         $inputarr['adodb_offset'] = $offset;
         return $this->execute($sql, $inputarr);
     }
 }
 /**
  * Get information about student's programms and subjects.
  *
  * @param $sident
  *
  * @return array
  */
 public function getStudyInfo($sident)
 {
     $query = "SELECT zpovinn, pnazev, panazev, zvysl, zbody, to_char(zdatum,'DD.MM.YYYY')\n\t\t\t\t\tAS datum, zskr\n\t\t\t\t\tFROM zkous JOIN ( SELECT povinn,pnazev,panazev,vplatiod,vplatido\n\t\t\t\t\tFROM povinn UNION SELECT povinn,pnazev,panazev,vplatiod,vplatido\n\t\t\t\t\tFROM povinn2 ) ON (zpovinn=povinn AND vplatiod<=zskr AND vplatido>=zskr )\n\t\t\t\t\tWHERE  zsplsem='S' AND zident = {$sident} ORDER BY zskr, zdt";
     $data = $this->execute($query);
     $grades = [];
     while (ocifetch($data)) {
         $grades[] = ['code' => ociresult($data, "ZPOVINN"), 'name' => ociresult($data, "PNAZEV"), 'name_en' => ociresult($data, "PANAZEV"), 'grade' => ociresult($data, "ZVYSL"), 'credits' => ociresult($data, "ZBODY"), 'date' => ociresult($data, "DATUM"), 'year' => ociresult($data, "ZSKR")];
     }
     return $grades;
 }
function form_checkfield($name, $title, $sql)
{
    $stm = ociexec($sql);
    echo "<tr><td align=right>{$title} :</td><td>";
    while (ocifetch($stm)) {
        echo "<input type=checkbox name={$name} value=\"" . ociresult($stm, 'CVALUE') . "\">" . ociresult($stm, 'CNAME') . "<br>";
    }
    echo "</td></tr>";
}
		<a href="http://uisacad.uis.edu/~kmulpu2/DillardsReporting.html">Logout</a>
	</div>
	<?php 
$username = $_POST['username'];
$password = $_POST['pwd'];
$connection = ocilogon("tanis2", "oracle", "oracle.uis.edu");
$sqlquery = "SELECT count(*) FROM CREDENTIALS WHERE username='******' AND password='******'";
$sql_id = ociparse($connection, $sqlquery);
if (!$sql_id) {
    $e = oci_error($connection);
    echo "The following error occured:";
    print htmlentities($e['message']);
    exit;
}
ociexecute($sql_id, OCI_DEFAULT);
while (ocifetch($sql_id)) {
    $result = ociresult($sql_id, 1);
    if ($result == 1) {
        echo "<h3>You have logged in successfully<h3/>";
        echo "<a href='http://uisacad.uis.edu/~kmulpu2/criteriaForReport.html'>Click here to generate reports</a>";
    } else {
        echo '<font color="' . red . '">Invalid login credentials. Please enter correct username and password</font>';
        echo "<br/><br/>";
        echo "<a href='http://uisacad.uis.edu/~kmulpu2/DillardsReporting.html'>Back To Login Page</a>";
    }
}
ocicommit($connection);
OCIFreeStatement($sql_id);
ocilogoff($connection);
?>
</body>
Exemple #11
0
 /**
  * Get the rows returned from a SELECT query.
  *
  * @param  resource		The query result pointer
  * @param  ?integer		Whether to start reading from (NULL: irrelevant for this forum driver)
  * @return array			A list of row maps
  */
 function db_get_query_rows($stmt, $start = NULL)
 {
     $out = array();
     $i = 0;
     $num_fields = ocinumcols($stmt);
     $types = array();
     $names = array();
     for ($x = 1; $x <= $num_fields; $x++) {
         $types[$x] = ocicolumntype($stmt, $x);
         $names[$x] = strtolower(ocicolumnname($stmt, $x));
     }
     while (ocifetch($stmt)) {
         if (is_null($start) || $i >= $start) {
             $newrow = array();
             for ($j = 1; $j <= $num_fields; $j++) {
                 $v = ociresult($stmt, $j);
                 if (is_object($v)) {
                     $v = $v->load();
                 }
                 // For CLOB's
                 if ($v === false) {
                     fatal_exit(do_lang_tempcode('QUERY_FAILED', ocierror($stmt)));
                 }
                 $name = $names[$j];
                 $type = $types[$j];
                 if ($type == 'NUMBER') {
                     if (!is_null($v)) {
                         $newrow[$name] = intval($v);
                     } else {
                         $newrow[$name] = NULL;
                     }
                 } else {
                     if ($v == ' ') {
                         $v = '';
                     }
                     $newrow[$name] = $v;
                 }
             }
             $out[] = $newrow;
         }
         $i++;
     }
     return $out;
 }
ocicollgetelem();
ocicollmax();
ocicollsize();
ocicolltrim();
ocicolumnisnull();
ocicolumnname();
ocicolumnprecision();
ocicolumnscale();
ocicolumnsize();
ocicolumntype();
ocicolumntyperaw();
ocicommit();
ocidefinebyname();
ocierror();
ociexecute();
ocifetch();
ocifetchinto();
ocifetchstatement();
ocifreecollection();
ocifreecursor();
ocifreedesc();
ocifreestatement();
ociinternaldebug();
ociloadlob();
ocilogoff();
ocilogon();
ocinewcollection();
ocinewcursor();
ocinewdescriptor();
ocinlogon();
ocinumcols();