@@ -116,6 +116,8 @@ static PHP_METHOD(swoole_postgresql_coro, __construct);
116
116
static PHP_METHOD (swoole_postgresql_coro, __destruct);
117
117
static PHP_METHOD (swoole_postgresql_coro, connect);
118
118
static PHP_METHOD (swoole_postgresql_coro, escape);
119
+ static PHP_METHOD (swoole_postgresql_coro, escapeLiteral);
120
+ static PHP_METHOD (swoole_postgresql_coro, escapeIdentifier);
119
121
static PHP_METHOD (swoole_postgresql_coro, query);
120
122
static PHP_METHOD (swoole_postgresql_coro, prepare);
121
123
static PHP_METHOD (swoole_postgresql_coro, execute);
@@ -227,6 +229,8 @@ static const zend_function_entry swoole_postgresql_coro_methods[] =
227
229
PHP_ME (swoole_postgresql_coro, fieldCount, arginfo_pg_field_count, ZEND_ACC_PUBLIC)
228
230
PHP_ME (swoole_postgresql_coro, metaData, arginfo_pg_meta_data, ZEND_ACC_PUBLIC)
229
231
PHP_ME (swoole_postgresql_coro, escape, arginfo_pg_escape, ZEND_ACC_PUBLIC)
232
+ PHP_ME (swoole_postgresql_coro, escapeLiteral, arginfo_pg_escape, ZEND_ACC_PUBLIC)
233
+ PHP_ME (swoole_postgresql_coro, escapeIdentifier, arginfo_pg_escape, ZEND_ACC_PUBLIC)
230
234
PHP_ME (swoole_postgresql_coro, fetchObject, arginfo_pg_fetch_object, ZEND_ACC_PUBLIC)
231
235
PHP_ME (swoole_postgresql_coro, fetchAssoc, arginfo_pg_fetch_assoc, ZEND_ACC_PUBLIC)
232
236
PHP_ME (swoole_postgresql_coro, fetchArray, arginfo_pg_fetch_array, ZEND_ACC_PUBLIC)
@@ -1462,6 +1466,52 @@ static PHP_METHOD(swoole_postgresql_coro, escape) {
1462
1466
}
1463
1467
}
1464
1468
1469
+ static PHP_METHOD (swoole_postgresql_coro, escapeLiteral) {
1470
+ char *str, *tmp;
1471
+ size_t l_str;
1472
+ PGconn *pgsql;
1473
+
1474
+ ZEND_PARSE_PARAMETERS_START (1 , 1 )
1475
+ Z_PARAM_STRING (str, l_str)
1476
+ ZEND_PARSE_PARAMETERS_END_EX (RETURN_FALSE);
1477
+
1478
+ pg_object *object = php_swoole_postgresql_coro_get_object (ZEND_THIS);
1479
+ pgsql = object->conn ;
1480
+
1481
+ tmp = PQescapeLiteral (pgsql, str, l_str);
1482
+ if (tmp == nullptr ) {
1483
+ zend_update_property_string (swoole_postgresql_coro_ce, ZEND_THIS, ZEND_STRL (" error" ), PQerrorMessage (pgsql));
1484
+
1485
+ RETURN_FALSE;
1486
+ }
1487
+
1488
+ RETVAL_STRING (tmp);
1489
+ PQfreemem (tmp);
1490
+ }
1491
+
1492
+ static PHP_METHOD (swoole_postgresql_coro, escapeIdentifier) {
1493
+ char *str, *tmp;
1494
+ size_t l_str;
1495
+ PGconn *pgsql;
1496
+
1497
+ ZEND_PARSE_PARAMETERS_START (1 , 1 )
1498
+ Z_PARAM_STRING (str, l_str)
1499
+ ZEND_PARSE_PARAMETERS_END_EX (RETURN_FALSE);
1500
+
1501
+ pg_object *object = php_swoole_postgresql_coro_get_object (ZEND_THIS);
1502
+ pgsql = object->conn ;
1503
+
1504
+ tmp = PQescapeIdentifier (pgsql, str, l_str);
1505
+ if (tmp == nullptr ) {
1506
+ zend_update_property_string (swoole_postgresql_coro_ce, ZEND_THIS, ZEND_STRL (" error" ), PQerrorMessage (pgsql));
1507
+
1508
+ RETURN_FALSE;
1509
+ }
1510
+
1511
+ RETVAL_STRING (tmp);
1512
+ PQfreemem (tmp);
1513
+ }
1514
+
1465
1515
/* {{{ PHP_MINIT_FUNCTION
1466
1516
*/
1467
1517
PHP_MINIT_FUNCTION (swoole_postgresql) {
0 commit comments