Example #1
0
static int dblib_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_value)
{
	pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;

	switch (attr) {
		case PDO_ATTR_DEFAULT_STR_PARAM:
			ZVAL_LONG(return_value, H->assume_national_character_set_strings ? PDO_PARAM_STR_NATL : PDO_PARAM_STR_CHAR);
			break;

		case PDO_ATTR_EMULATE_PREPARES:
			/* this is the only option available, but expose it so common tests and whatever else can introspect */
			ZVAL_TRUE(return_value);
			break;

		case PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER:
			ZVAL_BOOL(return_value, H->stringify_uniqueidentifier);
			break;

		case PDO_DBLIB_ATTR_VERSION:
			ZVAL_STRING(return_value, dbversion());
			break;

		case PDO_DBLIB_ATTR_SKIP_EMPTY_ROWSETS:
			ZVAL_BOOL(return_value, H->skip_empty_rowsets);
			break;

		default:
			return 0;
	}

	return 1;
}
static ngx_dbd_t *
ngx_dbd_freetds_create(ngx_pool_t *pool, ngx_log_t *log)
{
    ngx_dbd_t              *dbd;
    ngx_dbd_freetds_ctx_t  *ctx;

    ngx_log_debug0(NGX_LOG_DEBUG_MYSQL, log, 0, "dbd freetds create");

    dbd = ngx_pcalloc(pool, sizeof(ngx_dbd_t));
    if (dbd == NULL) {
        return NULL;
    }

    ctx = ngx_pcalloc(pool, sizeof(ngx_dbd_freetds_ctx_t));
    if (ctx == NULL) {
        return NULL;
    }

    dbinit();

    /* dbsetversion */

    /* dbgetmaxprocs */

    /* dbsetmaxprocs(256); */

#if 0
    ngx_log_error(NGX_LOG_ALERT, log, 0, "version of db-lib:%s", dbversion());
#endif

    ctx->login = dblogin();
    if (ctx->login == NULL) {
        return NULL;
    }

    dbprocerrhandle(ctx->login, (DBERRHANDLE_PROC) ngx_dbd_freetds_err_handler);
    dbprocmsghandle(ctx->login, (DBMSGHANDLE_PROC) ngx_dbd_freetds_msg_handler);

    dbd->pool = pool;
    dbd->log = log;
    dbd->ctx = ctx;

    return dbd;
}