1

I'm not able to return same data with PDO functions and with ODBC_* functions. With the same driver.

The database is SAP HANA.

Code:

        $driver = 'HDBODBC';
        $host = "XX.XX.XX.XX:30015";
        $db_name = "MY_DATABASE";
        $username = "XXX";
        $password = "XXXX";
        $conn = odbc_connect("Driver=$driver;ServerNode=$host;Database=$db_name;", $username, $password, SQL_CUR_USE_ODBC);

        $params = [
            'Belkin',
            '',
            '',
            'AL'
        ];
        $sql = 'SELECT * FROM "MY_DATABASE"."PRODUCT" (%s%s%s) LIMIT 10';
        $sql = sprintf($sql,"'",implode("','",$params),"'");

        $result = odbc_exec($conn,$sql);

        while($row = odbc_fetch_array($result)){
            dump($row);
            break;
        }

        $dsn = "odbc:Driver=$driver;ServerNode=$host;Database=$db_name";


        $dbh = new PDO($dsn, $username, $password);
        $stmt = $dbh->prepare($sql);
        $stmt -> execute();
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC);

        dump($result[0]);

First dump returns:

Dump odbc functions

Second dump returns:

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.