當我嘗試此查詢:我是否連接到Oracle?
$query = "SELECT * FROM user_objects WHERE object_type = 'TABLE'";
...我得到一個空的結果集。
我已經使用error_reporting()設置爲E_ALL,所以我會假設,如果沒有正確連接,我會得到一個錯誤,對吧?
我正在使用一個上級給予我的類,它們用於一切,所以它應該工作。
如果您需要該代碼,請告訴我。
謝謝你們可以給我的任何幫助:)。
編輯
這裏是正在執行的實際查詢功能:
/**
* Query the database and store the result. If the query is a select it returns the number of rows
* fetched.
*
* Example:
* <code>
* $query = "SELECT * FROM tablename";
* if($sql->query($query)){
* while($sql->fetch()){
* foreach($sql->results as $a=>$b){
* print "$a: $b<br>";
* }
* print "<hr>";
* }
* }else{
* print "No results";
* }
*
* </code>
*
* @param SQL*Plus query statement
* @access public
* @return int
*/
function query($query_statement){
if($_SESSION['TESTING']==1 && $_SESSION){
$_SESSION['queries'][] = $query_statement;
$_SESSION['Total_queries'] = count($_SESSION['queries']);
}
$parse_result = $this->execute($query_statement);
if($parse_result == 0){
return 0;
}else{
if($this->_queryresult){
oci_free_statement($this->_queryresult);
}
$this->results=array();
$this->_queryresult = $parse_result;
$this->resultscount = oci_num_rows($this->_queryresult);
if(!$this->resultscount)
return 0;
else
return $this->resultscount;
}
}
代碼總是很有用:) oci_error函數應該提供更多的細節。 – JTP 2010-10-27 14:16:48
oci_error()似乎沒有輸出任何東西:(。 – Will 2010-10-27 14:47:46
至於oracle類的代碼,我不太瞭解它,以免泄漏安全漏洞等。:(我將添加查詢函數雖然 – Will 2010-10-27 14:48:31