Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* in order to support named params, which Firebird itself doesn't,
- we need to replace :foo by ?, and store the name we just replaced */
- new_sql = c = emalloc(sql_len+1);
- for (l = in_quote = in_param = 0; l <= sql_len; ++l) {
- if (!(in_quote ^= (sql[l] == '\''))) {
- if (!in_param) {
- switch (sql[l]) {
- case ':':
- in_param = 1;
- ppname = pname;
- *ppname++ = sql[l];
- case '?':
- *c++ = '?';
- ++pindex;
- continue;
- }
- } else {
- if ((in_param &= ((sql[l] >= 'A' && sql[l] <= 'Z') || (sql[l] >= 'a' && sql[l] <= 'z')
- || (sql[l] >= '0' && sql[l] <= '9') || sql[l] == '_' || sql[l] == '-'))) {
- *ppname++ = sql[l];
- continue;
- } else {
- *ppname++ = 0;
- if (named_params) {
- zval tmp;
- ZVAL_LONG(&tmp, pindex);
- zend_hash_str_update(named_params, pname, (unsigned int)(ppname - pname - 1), &tmp);
- }
- }
- }
- }
- *c++ = sql[l];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement