Skip to content

Commit 0ae6ecb

Browse files
committed
Do not advertise support for a PDO feature if it's not implemented by the ODBC driver
And ammend PDO::quote() test to take into account drivers which do not support the feature
1 parent 2326c18 commit 0ae6ecb

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

ext/pdo/tests/pdo_quote_empty_string.phpt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
PDO::quote() must accept empty string
2+
PDO::quote() must accept empty string for drivers which support this feature
33
--SKIPIF--
44
<?php
55
if (!extension_loaded('pdo')) die('skip');
@@ -13,10 +13,19 @@ PDOTest::skip();
1313
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
1414
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
1515

16-
$pdo = PDOTest::factory();
17-
18-
var_dump($pdo->quote(''));
16+
$pdo = PDOTest::factory();
17+
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1918

19+
try {
20+
$result = $pdo->quote('');
21+
if (!is_string($result)) {
22+
var_dump($result);
23+
}
24+
} catch (\PDOException) {
25+
// Do nothing as quoting is not supported with this driver
26+
}
2027
?>
28+
DONE
29+
2130
--EXPECT--
22-
string(2) "''"
31+
DONE

ext/pdo_odbc/odbc_driver.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,14 @@ static zend_long odbc_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_le
257257
return row_count;
258258
}
259259

260+
/* TODO: Do ODBC quoter
260261
static int odbc_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type param_type )
261262
{
262-
/* pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data; */
263-
/* TODO: figure it out */
263+
// pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
264+
// TODO: figure it out
264265
return 0;
265266
}
267+
*/
266268

267269
static int odbc_handle_begin(pdo_dbh_t *dbh)
268270
{
@@ -373,7 +375,7 @@ static const struct pdo_dbh_methods odbc_methods = {
373375
odbc_handle_closer,
374376
odbc_handle_preparer,
375377
odbc_handle_doer,
376-
odbc_handle_quoter,
378+
NULL, /* quoter */
377379
odbc_handle_begin,
378380
odbc_handle_commit,
379381
odbc_handle_rollback,

0 commit comments

Comments
 (0)