Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2652673
  • 博文数量: 416
  • 博客积分: 10220
  • 博客等级: 上将
  • 技术积分: 4193
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-15 09:47
文章分类

全部博文(416)

文章存档

2022年(1)

2021年(1)

2020年(1)

2019年(5)

2018年(7)

2017年(6)

2016年(7)

2015年(11)

2014年(1)

2012年(5)

2011年(7)

2010年(35)

2009年(64)

2008年(48)

2007年(177)

2006年(40)

我的朋友

分类: PHP

2017-09-22 14:53:10

参考:

http://www.allwebdevhelp.com/php/help-tutorials.php?i=328
http://php.net/manual/en/function.odbc-execute.php

php官方给出的样例是:
$a 1;
$b 2;
$c 3;
$stmt    odbc_prepare($conn'CALL myproc(?,?,?)');
$success odbc_execute($stmt, array($a$b$c));
?>
自己写的odbc驱动程序,它会调用odbc 接口SQLDescribeParam,接口参数绑定SQLBindParameter,我的程序获取数据正常返回给php时,

出现异常:
0x00007FFC032CA898 (php5ts.dll)处(位于 php.exe 中)引发的异常: 0xC0000005: 读取位置 0x000000000408012C 时发生访问冲突。
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 2666955145 bytes) in D:\dev2\vc\esproc\php\test2.php on line 21
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2666955145 bytes) in D:\dev2\vc\esproc\php\test2.php on line 21
本质是不应该是内存问题,应该是它越界造成的.(偷懒,没有去看php5ts.dll对应的源代码)

下面测试程序有正常返回数据集.
$conn = odbc_connect("myproc", "user", "passwd") or die("Could not connect to ODBC database!");

/*
$sql = odbc_prepare($conn, "{call hsql(?)}");
$params = array(1, 5);
$rs = odbc_execute($sql, $params);  
*/
/*
$a = 3;
$stmt    = odbc_prepare($conn, 'CALL hsql(?)');
$rs = odbc_execute($stmt, array($a));
*/
/*下面的写法不再调用SQLDescribeParam,把函数与参数当字符串整体传递过去执行.
   Server端支持这种格式解析,因此能返回数据.
*/
$Param1 = '10';
$query_string = "call hsql($Param1)";
$rs = odbc_prepare($conn, $query_string);
odbc_execute($rs);

do{
while (odbc_fetch_row($rs)) { 
for ($i=1; $i<=odbc_num_fields($rs); $i++) { 
  if(odbc_result($rs,$i)){ 
  if ($i==110 || $i==103){ //for test
  echo date("r",strtotime(odbc_result($rs,$i)));
  //echo strtotime(odbc_result($rs,$i));
  }else{
  echo odbc_result($rs,$i)." "; 
  }
  } 
} //endf
echo "\n";
}//endw
echo "\n";
}while(odbc_next_result($rs)); //多数据集
?>




阅读(1468) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~