Lines Matching refs:querystr

2486 		smart_str querystr = {0};  local
2489 smart_str_appends(&querystr, "select relname from pg_class where oid=");
2490 smart_str_append_unsigned(&querystr, oid);
2491 smart_str_0(&querystr);
2493 …if ((tmp_res = PQexec(pg_result->conn, ZSTR_VAL(querystr.s))) == NULL || PQresultStatus(tmp_res) !…
2497 smart_str_free(&querystr);
2502 smart_str_free(&querystr);
5530 smart_str querystr = {0}; local
5554 smart_str_appends(&querystr,
5564 smart_str_appends(&querystr,
5575 smart_str_appendl(&querystr, escaped, new_len);
5579 smart_str_appends(&querystr, "' AND n.nspname = '");
5583 smart_str_appendl(&querystr, escaped, new_len);
5587 smart_str_appends(&querystr, "' ORDER BY a.attnum;");
5588 smart_str_0(&querystr);
5591 pg_result = PQexec(pg_link, ZSTR_VAL(querystr.s));
5594 smart_str_free(&querystr);
5598 smart_str_free(&querystr);
6545 static int do_exec(smart_str *querystr, ExecStatusType expect, PGconn *pg_link, zend_ulong opt) /* … argument
6548 if (PQsendQuery(pg_link, ZSTR_VAL(querystr->s))) {
6555 pg_result = PQexec(pg_link, ZSTR_VAL(querystr->s));
6569 static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const char *table) /* {{{ … argument
6577 smart_str_appendl(querystr, table, len);
6580 smart_str_appends(querystr, escaped);
6588 smart_str_appendc(querystr, '.');
6589 smart_str_appendl(querystr, after_dot, len);
6592 smart_str_appendc(querystr, '.');
6593 smart_str_appends(querystr, escaped);
6607 smart_str querystr = {0}; local
6617 smart_str_appends(&querystr, "INSERT INTO ");
6618 build_tablename(&querystr, pg_link, table);
6619 smart_str_appends(&querystr, " DEFAULT VALUES");
6633 smart_str_appends(&querystr, "INSERT INTO ");
6634 build_tablename(&querystr, pg_link, table);
6635 smart_str_appends(&querystr, " (");
6644 smart_str_appends(&querystr, tmp);
6647 smart_str_appendl(&querystr, ZSTR_VAL(fld), ZSTR_LEN(fld));
6649 smart_str_appendc(&querystr, ',');
6651 ZSTR_LEN(querystr.s)--;
6652 smart_str_appends(&querystr, ") VALUES (");
6664 smart_str_appendc(&querystr, '\'');
6665 smart_str_appendl(&querystr, tmp, new_len);
6666 smart_str_appendc(&querystr, '\'');
6669 smart_str_appendl(&querystr, Z_STRVAL_P(val), Z_STRLEN_P(val));
6673 smart_str_append_long(&querystr, Z_LVAL_P(val));
6676 smart_str_appendl(&querystr, buf, snprintf(buf, sizeof(buf), "%F", Z_DVAL_P(val)));
6679 smart_str_appendl(&querystr, "NULL", sizeof("NULL")-1);
6686 smart_str_appendc(&querystr, ',');
6689 ZSTR_LEN(querystr.s)--;
6690 smart_str_appends(&querystr, ");");
6694 smart_str_0(&querystr);
6697 do_exec(&querystr, PGRES_COMMAND_OK, pg_link, (opt & PGSQL_CONV_OPTS)) == 0) {
6707 *sql = querystr.s;
6710 smart_str_free(&querystr);
6801 static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr, HashTable *ht, int … argument
6813 smart_str_appends(querystr, tmp);
6816 smart_str_appendl(querystr, ZSTR_VAL(fld), ZSTR_LEN(fld));
6819 smart_str_appends(querystr, " IS ");
6821 smart_str_appendc(querystr, '=');
6829 smart_str_appendc(querystr, '\'');
6830 smart_str_appendl(querystr, tmp, new_len);
6831 smart_str_appendc(querystr, '\'');
6834 smart_str_appendl(querystr, Z_STRVAL_P(val), Z_STRLEN_P(val));
6838 smart_str_append_long(querystr, Z_LVAL_P(val));
6842 …smart_str_appendl(querystr, buf, MIN(snprintf(buf, sizeof(buf), "%F", Z_DVAL_P(val)), sizeof(buf) …
6846 smart_str_appendl(querystr, "NULL", sizeof("NULL")-1);
6852 smart_str_appendl(querystr, pad, pad_len);
6854 if (querystr->s) {
6855 ZSTR_LEN(querystr->s) -= pad_len;
6867 smart_str querystr = {0}; local
6896 smart_str_appends(&querystr, "UPDATE ");
6897 build_tablename(&querystr, pg_link, table);
6898 smart_str_appends(&querystr, " SET ");
6900 if (build_assignment_string(pg_link, &querystr, Z_ARRVAL_P(var_array), 0, ",", 1, opt))
6903 smart_str_appends(&querystr, " WHERE ");
6905 …if (build_assignment_string(pg_link, &querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")…
6908 smart_str_appendc(&querystr, ';');
6909 smart_str_0(&querystr);
6911 if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt) == 0) {
6921 *sql = querystr.s;
6924 smart_str_free(&querystr);
6973 smart_str querystr = {0}; local
6994 smart_str_appends(&querystr, "DELETE FROM ");
6995 build_tablename(&querystr, pg_link, table);
6996 smart_str_appends(&querystr, " WHERE ");
6998 …if (build_assignment_string(pg_link, &querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")…
7001 smart_str_appendc(&querystr, ';');
7002 smart_str_0(&querystr);
7004 if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt) == 0) {
7013 *sql = querystr.s;
7016 smart_str_free(&querystr);
7109 smart_str querystr = {0}; local
7132 smart_str_appends(&querystr, "SELECT * FROM ");
7133 build_tablename(&querystr, pg_link, table);
7134 smart_str_appends(&querystr, " WHERE ");
7136 …if (build_assignment_string(pg_link, &querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")…
7139 smart_str_appendc(&querystr, ';');
7140 smart_str_0(&querystr);
7142 pg_result = PQexec(pg_link, ZSTR_VAL(querystr.s));
7146 php_error_docref(NULL, E_NOTICE, "Failed to execute '%s'", ZSTR_VAL(querystr.s));
7153 *sql = querystr.s;
7156 smart_str_free(&querystr);