phporacle数据库
⑴ php,pdo怎么连接oracle数据库
php有强来大的功能不但可以自支持mysql,mssql,mysqli之个我们还可以与oracle数据连接,要让php支持oracle非常的简单我们只要把php.ini中的;extention = php_oci8.dll分号去掉即可.
请先安装oracle的客户端,能够用客户端访问oracle。
php支持oracle连接函数
php.ini文件中的配置,去掉 ;extention = php_oci8.dll,去掉前面的分号,重启apache就可以了,如果不行,我们再把php目录中的php_oci8.dll拷到windows系统的system32下面去吧.
oracle数据库建立链接,代码如下:
$conn=oci_connect('username','password',"(DEscriptION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.100)(PORT=1521))(CONNECT_DATA=(SID=test)))");
⑵ Oracle 数据库 如何连接 php
function printoraerr($in_cur)
{
// 检查Oracle是否出错
// 如果存在错误则显示
// 当指针被激活时每次请求Oracle后调用该函数
if(ora_errorcode($in_cur))
echo "Oracle code - ".ora_error($in_cur)."\n";
return;
}
if (!($conn=ora_logon("user@TNSNAME","password")))
{echo "Connection to database failed\n";
exit;
}
echo "Connected as connection - $conn \n";
echo "Opening cursor ... \n";
$cursor=ora_open($conn); printoraerr($cursor);
echo "Opened cursor - $cursor \n";
$qry="select user,sysdate from al";
echo "Parsing the query $qry ... \n";
ora_parse($cursor,$qry,0); printoraerr($cursor);
echo "Query parsed \n";
echo "Executing cursor ... \n";
ora_exec($cursor); printoraerr($cursor);
echo "Executed cursor \n";
echo "Fetching cursor ... \n";
while(ora_fetch($cursor))
{
$user=ora_getcolumn($cursor,0); printoraerr($cursor);
$sysdate=ora_getcolumn($cursor,1); printoraerr($cursor);
echo " row = $user, $sysdate \n";
}
echo "Fetched all records \n";
echo "Closing cursor ... \n";
ora_close($cursor);
echo "Closed cursor \n";
echo "Logging off from oracle... \n";
ora_logoff($conn);
echo "Logged off from oracle \n";
?>
⑶ php 连接oracle数据库语句怎么写
php教程连接oracle数据库教程代码
$conn = OCILogon("scott","tiger","你的oracle数据库名字");
$stmt = OCIParse($conn,"select empno, ename from emp");
OCIDefineByName($stmt,"EMPNO",&$empno);
OCIDefineByName($stmt,"ENAME",&$ename);
OCIExecute($stmt);
while (OCIFetch($stmt)) {
echo "empno:".$empno."n";
echo "ename:".$ename."n";
}
OCIFreeStatement($stmt);
OCILogoff($conn);
⑷ php中怎么配置支持oracle 11g数据库
1、安装oracle 11g client或instantclient 11
2、编译php支持oracle
--with-oci8[=DIR]
--with-pdo-oci[=DIR]
3、配置php.ini支持oracle 11g
windows:
extension=php_oci8_11g.dll
linux:参考
http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html
4、ora.php实例
<?php
$conn = oci_connect('user', 'passwd', 'ip:1521/orcl'); // 建立连接
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
$query = 'SELECT * FROM account'; // 查询语句
$stid = oci_parse($conn, $query); // 配置SQL语句,准备执行
if (!$stid) {
$e = oci_error($conn);
print htmlentities($e['message']);
exit;
}
$r = oci_execute($stid, OCI_DEFAULT); // 执行SQL。OCI_DEFAULT表示不要自动commit
if(!$r) {
$e = oci_error($stid);
echo htmlentities($e['message']);
exit;
}
// 打印执行结果
print '<table border="1">';
while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
print '<tr>';
foreach($row as $item) {
print '<td>'.($item?htmlentities($item):' ').'</td>';
//print_r($item);
}
print '</tr>';
}
print '</table>';
oci_close($conn);
?>
⑸ PHP中如何查询oracle数据库,写出简单的例子,谢谢
嘻嘻这个不难但很难说只能给你个思路
ODBC
odbc_connect() 连接方法