#include "php_pq.h"
#include "php_pqexc.h"
-#include "php_pqconn_event.h"
#include "php_pq_misc.h"
+#include "php_pqconn_event.h"
#undef PHP_PQ_TYPE
#include "php_pq_type.h"
/* clear result object associated with a result handle */
-void php_pq_clear_res(PGresult *r) {
+void php_pqres_clear(PGresult *r) {
php_pq_object_t *o = PQresultInstanceData(r, php_pqconn_event);
if (o) {
}
/* clear any asynchronous results */
-void php_pq_clear_conn(PGconn *conn) {
+void php_pqconn_clear(PGconn *conn) {
PGresult *r;
php_pqconn_event_data_t *evdata = PQinstanceData(conn, php_pqconn_event);
while ((r = PQgetResult(conn))) {
- php_pq_clear_res(r);
+ php_pqres_clear(r);
}
if (evdata && evdata->obj) {
/* safe wrappers to clear any asynchronous wrappers before querying synchronously */
PGresult *php_pq_exec(PGconn *conn, const char *query) {
- php_pq_clear_conn(conn);
+ php_pqconn_clear(conn);
return PQexec(conn, query);
}
PGresult *php_pq_exec_params(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const * paramValues, const int *paramLengths, const int *paramFormats, int resultFormat) {
- php_pq_clear_conn(conn);
+ php_pqconn_clear(conn);
return PQexecParams(conn, command, nParams, paramTypes, paramValues, paramLengths, paramFormats, resultFormat);
}
PGresult *php_pq_prepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes) {
- php_pq_clear_conn(conn);
+ php_pqconn_clear(conn);
return PQprepare(conn, stmtName, query, nParams, paramTypes);
}
PGresult *php_pq_exec_prepared(PGconn *conn, const char *stmtName, int nParams, const char *const * paramValues, const int *paramLengths, const int *paramFormats, int resultFormat) {
- php_pq_clear_conn(conn);
+ php_pqconn_clear(conn);
return PQexecPrepared(conn, stmtName, nParams, paramValues, paramLengths, paramFormats, resultFormat);
}
}
}
-int php_pq_compare_index(const void *lptr, const void *rptr)
+int php_pq_compare_index_80(Bucket *lptr, Bucket *rptr)
{
- zend_ulong l = ((const Bucket *) lptr)->h;
- zend_ulong r = ((const Bucket *) rptr)->h;
+ zend_ulong l = lptr->h;
+ zend_ulong r = rptr->h;
if (l < r) {
return -1;
}
return 0;
}
+int php_pq_compare_index_70(const void *lptr, const void *rptr) {
+ return php_pq_compare_index_80((Bucket *) lptr, (Bucket *) rptr);
+}
void php_pq_hash_ptr_dtor(zval *p)
{
zval rv, tmp;
ZVAL_NULL(&rv);
- zend_call_method_with_1_params(getThis(), php_pqdt_class_entry, NULL, "format", &rv,
- zend_read_property(php_pqdt_class_entry, getThis(), ZEND_STRL("format"), 0, &tmp));
+ php_pq_call_method(getThis(), "format", 1, &rv, php_pq_read_property(getThis(), "format", &tmp));
RETVAL_ZVAL(&rv, 1, 1);
}
ZEND_BEGIN_ARG_INFO_EX(ai_pqdt_create_from_format, 0, 0, 2)
ZEND_ARG_INFO(0, format)
ZEND_ARG_INFO(0, datetime)
+#if PHP_VERSION_ID >= 70200
+ ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 1)
+#else
ZEND_ARG_INFO(0, timezone)
+#endif
ZEND_END_ARG_INFO();
static PHP_METHOD(pqdt, createFromFormat)
{
{0}
};
-zval *php_pqdt_from_string(zval *zv, char *input_fmt, char *dt_str, size_t dt_len, char *output_fmt, zval *ztimezone)
+zval *php_pqdt_from_string(zval *zv, char *input_fmt, char *dt_str, size_t dt_len, const char *output_fmt, zval *ztimezone)
{
php_date_obj *dobj;
zval_dtor(zv);
ZVAL_NULL(zv);
} else if (output_fmt) {
- zend_update_property_string(php_pqdt_class_entry, zv, ZEND_STRL("format"), output_fmt);
+ zval fmt;
+ ZVAL_STRING(&fmt, output_fmt);
+ php_pq_update_property(zv, "format", &fmt);
+ zval_ptr_dtor(&fmt);
}
return zv;
ZVAL_NULL(&rv);
- if (Z_OBJ_HT_P(zdt)->cast_object
- && SUCCESS == Z_OBJ_HT_P(zdt)->cast_object(zdt, &rv, IS_STRING)
- ) {
+ if (php_pq_cast_object(zdt, IS_STRING, &rv)) {
return Z_STR(rv);
} else if (instanceof_function(Z_OBJCE_P(zdt), php_date_get_date_ce())) {
zval rv, zfmt;
ZVAL_NULL(&rv);
ZVAL_STRING(&zfmt, format);
- zend_call_method_with_1_params(zdt, Z_OBJCE_P(zdt), NULL, "format", &rv, &zfmt);
+ php_pq_call_method(zdt, "format", 1, &rv, &zfmt);
zval_ptr_dtor(&zfmt);
if (Z_TYPE(rv) == IS_STRING) {
case '{':
return parse_array(a);
+ case '}':
+ return SUCCESS;
+
case '"':
a->quotes = 1;
++a->ptr;
static ZEND_RESULT_CODE parse_elements(ArrayParserState *a)
{
- char delims[] = {'}', PHP_PQ_DELIM_OF_ARRAY(a->typ), 0};
+ char delims[] = {'}', (char) PHP_PQ_DELIM_OF_ARRAY(a->typ), 0};
while (SUCCESS == parse_element(a, delims[1])) {
switch (caa(a, delims, 0)) {