略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: odbc_do

2024-11-15

odbc_do

(PHP 4, PHP 5, PHP 7, PHP 8)

odbc_do别名 odbc_exec()

说明

此函数是该函数的别名: odbc_exec().

add a noteadd a note

User Contributed Notes 3 notes

up
1
phil.nyc
15 years ago
To clear up: the SQL standard requires strings to be inside single quotes: 'string'.  It simply does not accept double quotes for this purpose.

Furthermore, in PHP, you can have a single quote inside double quotes: "select a from b where c = 'string'" without the need to escape.
up
1
scottmweaver
15 years ago
Hey guys,

I used the following code to run normal double quotes inside my SQL queries. Hopefully this will save someone else a headache or two-

<?php

   
/**
     * Query Function
     * Allows quoted queries to be sent to SQL
     */

   
function query($query, $conn)
    {
       
odbc_do($conn, 'SET QUOTED_IDENTIFIER OFF');
        return
odbc_do($conn, $query);
    }
?>
up
-1
yashkhopade at hotmail dot com
18 years ago
i have use this function so many times. it works well for my requirements. ok well done...

<?php
         $sqlstr
="SELECT bill_no FROM SCROL";
        
$queryresult=odbc_do($conn,$sqlstr);
        
odbc_fetch_row($queryresult,$bills);

       
// if we want to access the records
        // then we have to write the following code
        
       
echo $bills[0];
     
?>

the out put for this will:

1
which is actullay first record of resultset.

官方地址:https://www.php.net/manual/en/function.odbc-do.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3