首先你要在php.ini文件中找到
下面的代码是调试通过的,可直接使用的:
html
body
php
if($dbconn!=false)
{
echo "连接成功";
if(OCILogOff($dbconn)==true)
echo "关闭连接成功!";
}
else
echo "连接失败";
/body
/html
$dbconn=oci_connect("你的账号","你的密码","你的数据库名称");//请把中文件设置为你的值;
$stmt=oci_parse($dbconn, "select * from scott.hallo");
oci_execute($stmt, OCI_DEFAULT);
echo $conn."----selecting\n\n";
while (oci_fetch($stmt))
echo ($conn."[".oci_result($stmt, "TEST")."]\n\n");
echo ($conn . "----done\n\n");
你其他程序可以运行成功? ,我过会运行下试试,等等
错误今天这一节:
"select sum(qty_stock*unit_cost) from Part;"
执行语句结尾不能像mysql那样写,以";"来执行多条语句
应该去掉";":"select sum(qty_stock*unit_cost) from Part"
建议:
你使用的oci函数最好改为最新的名字就,以下来自php手册
ocilogoff — 别名 oci_close()
Report a bug
reject note 说明
Warning
我曾经装过10G的php连接ord.
程序运行必须步骤如下
①安装orl client
extension=php_pdo_oci.dll
extension=php_oracle.dll
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
$query = 'SELECT * FROM taobaogoods';
$stid = oci_parse($conn, $query);
if (!$stid) {
$e = oci_error($conn);
$r = oci_execute($stid, OCI_DEFAULT);
if(!$r) {
$e = oci_error($stid);
echo htmlentities($e['message']);
$i =0;
while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
print 'tr';
foreach($row as $item) {
print 'td'.($item ? $item:'?').'/td';
$i++;
//exit;
print '/tr';
print '/table/body/html';
oci_close($conn);
强烈推荐使用ADODB库链接数据库.
如果一定要使用PHP内置函数,那么:
oci_connect
(
username,
password
,
dbname
)
例子:
$conn
=
oci_connect('hr',
'hr',
'orcl');
//
建立连接
if
(!$conn)
$e
oci_error();
htmlentities($e['message']);
$query
'SELECT
*
FROM
DEPARTMENTS';
查询语句
$stid
oci_parse($conn,
$query);
配置SQL语句,准备执行
(!$stid)
oci_error($conn);
$r
oci_execute($stid,
OCI_DEFAULT);
执行SQL.OCI_DEFAULT表示不要自动commit
if(!$r)
oci_error($stid);
echo
打印执行结果
'table
border="1"';
while($row
oci_fetch_array($stid,
OCI_RETURN_NULLS))
'tr';
foreach($row
as
$item)
'td'.($item?htmlentities($item):' ').'/td';
'/tr';
'/table';
$cx="select seq_id.nextval as seq from dual";
$conn-query($cx);
while($conn-next_record()){
$seq_id=$conn-f("seq");
以上就是土嘎嘎小编为大家整理的包含phpociexecute的词条相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!