PHPでOracle SQLステートメントを実行するためのクラスを作成しようとしています。
これが私の関数を呼び出そうとしている私のindex.phpです
<?php
include "dbaseconn/dbcontrol.php";
$DbControl = new DbControl;
$DbControl->execute(" SELECT * FROM SAMPLE_TABLE");
foreach($DbControl->data as $items)
{
echo $items['SAMPLE_COLUMN_NAME'];
}
?>
そして私の機能のための私のdbcontrol.php
<?php
class DbControl{
public $dbstr ='(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (COMMUNITY = tcp.world)(PROTOCOL = TCP)(HOST = XX.XXX.XXX.XX)(PORT = XXXX))
)
(CONNECT_DATA =
(SID = XXXXX)
)
)';
public $user = "XXXXX";
public $password = "XXXXX";
function connect(){
$this->connection = oci_connect($this->user,$this->password,$this->dbstr) or die(oci_error());
}
function execute($query){
$this -> connect(); //Database Connect
$this -> statement = oci_parse($this->connection,$query); //prepare the statement
$this -> execute = oci_execute($this -> statement); //execute the statement
$this -> totalRows = oci_num_rows($this -> statement); //get total number of rows
$this -> data = array();
if($this -> totalRows > 0){
//fetch data
while($result = oci_fetch_array($this->statement)){
$this -> data[] = $result;
}
}
}
}
?>
何が間違っているように見えるのかわかりません。しかし、私はこれを実行するたびに. ページには何も表示されません。結果なし、データなし。しかし、データベースにはデータがあると確信しています。