|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-10-21 20:59 UTC] Grant dot Walters at walters dot co dot nz
Platforms:
Using PHP 4.0.6/Openlink 4.1/Progress 8.3D.
Other:
I've tried PHP 4.0.4/4.0.5/4.0.6, Openlink 3.2,4.0,4.1, Progress 8.3C,8.3D,9.1C, shared memory and TCP/IP based connections.
Problem:
Doesn't seem to matter what I do, I am completely unable to select specific rows using ODBC.
I think the code below is correct, it's snipped from scripts.
<?
$dsn="DSN=$database;UID=$user;PWD=$password";
// I've tried all these without a difference.
$cursor="SQL_CUR_USE_ODBC";
//$cursor="SQL_CUR_IF_NEEDED";
//$cursor="SQL_CUR_USE_DRIVER";
//$cursor="SQL_CUR_DEFAULT";
$sql="SELECT * FROM user_table";
$text="";
function db_fetch_into($id, $number) {
global $text;
$text = "<TD>ROW: $number</TD>";
//Never Returns Anything
//odbc_fetch_into($id, $number, $result_array);
//Always Works
odbc_fetch_into($id, $result_array);
//Always Works
//odbc_fetch_into($id, 0, $result_array);
return $result_array;
}
if ($conn=odbc_connect("$dsn","","","$cursor")){
echo "<TABLE border='1'>";
//while ((odbc_fetch_into($results,$pos,$row)) && ($count<$limit)) {
$pos=0;
while ((list($var1,$var2) = db_fetch_into($result, $pos)) && ($pos<10)) {
echo "<TR>$text<TD>$var1</TD><TD>$var2</TD></TR>";
$pos ++;
}
echo "</TABLE>";
odbc_free_result($result);
odbc_close($conn);
} else {
// No connection .....
}
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 20:00:01 2025 UTC |
A correction to my previous information: The piece I commented out was in the php_opdbc.h file and was a reference to iodbc.h. This file is not present in the V4 ODBCSDK. I am unable to determine exactly which version of the SDK is being used as the Openlink ODBCSDK files have no version numbers anywhere. However.... I have gone back to what I had with the Openlink 3.2 drivers (and put back the iodbc.h line). The same thing happens regarding the sql query containing a ('). However.... The Openlink team suggested a series of changes including using odbc_prepare. Using 3.2 and 4.1 the following works. $sql="SELECT ID,Category,description FROM card_type WHERE description=?"; $results = odbc_prepare($conn,$sql); $parms=array("PEPPERELL'S"); odbc_execute($results,$parms); if ($results) { while (odbc_fetch_into($results,$row)) { echo $row[0]." ".$row[1]." ".$row[2]."<BR>"; } } I still think it has to be a bug with on the PHP side to do with how PHP parses the $sql contents, that is resulting in a syntax error in the SQL statement passed to Openlink. According to the Microsoft ODBC SDK, error 37000 is remapped to 42000 which says: 42000: *StatementText contained an SQL statement that was not preparable or contained a syntax error. The user did not have permission to execute the SQL statement contained in *StatementText. This is definitely not a permission issue. Openlink alse mentioned changes to disable the use of DYNAMIC_CURSOR. As I currently can make the queries I need (so far), I will carry on with what I have.