added amb739, SQL_ReadDriver()
authorDavid Anderson <dvander@alliedmods.net>
Thu Aug 09 20:06:42 2007 +0000 (2007-08-09)
changeset 129463af7da6c82c
parent 1293 2a71249ca0ab
child 1295 957df1c7b80a
added amb739, SQL_ReadDriver()
core/smn_database.cpp
plugins/include/dbi.inc
     1.1 --- a/core/smn_database.cpp	Thu Aug 09 19:48:46 2007 +0000
     1.2 +++ b/core/smn_database.cpp	Thu Aug 09 20:06:42 2007 +0000
     1.3 @@ -1236,6 +1236,24 @@
     1.4  	return (db1 == db2) ? true : false;
     1.5  }
     1.6  
     1.7 +static cell_t SQL_ReadDriver(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	IDatabase *db1=NULL;
    1.10 +	HandleError err;
    1.11 +
    1.12 +	if ((err = g_DBMan.ReadHandle(params[1], DBHandle_Database, (void **)&db1))
    1.13 +		!= HandleError_None)
    1.14 +	{
    1.15 +		return pContext->ThrowNativeError("Invalid database Handle 1/%x (error: %d)", params[1], err);
    1.16 +	}
    1.17 +
    1.18 +	IDBDriver *driver = db1->GetDriver();
    1.19 +
    1.20 +	pContext->StringToLocalUTF8(params[2], params[3], driver->GetIdentifier(), NULL);
    1.21 +
    1.22 +	return driver->GetHandle();
    1.23 +}
    1.24 +
    1.25  REGISTER_NATIVES(dbNatives)
    1.26  {
    1.27  	{"SQL_BindParamInt",		SQL_BindParamInt},
    1.28 @@ -1269,6 +1287,7 @@
    1.29  	{"SQL_PrepareQuery",		SQL_PrepareQuery},
    1.30  	{"SQL_Query",				SQL_Query},
    1.31  	{"SQL_QuoteString",			SQL_QuoteString},
    1.32 +	{"SQL_ReadDriver",			SQL_ReadDriver},
    1.33  	{"SQL_Rewind",				SQL_Rewind},
    1.34  	{"SQL_TConnect",			SQL_TConnect},
    1.35  	{"SQL_TQuery",				SQL_TQuery},
     2.1 --- a/plugins/include/dbi.inc	Thu Aug 09 19:48:46 2007 +0000
     2.2 +++ b/plugins/include/dbi.inc	Thu Aug 09 20:06:42 2007 +0000
     2.3 @@ -145,8 +145,20 @@
     2.4  native Handle:SQL_GetDriver(const String:name[]="");
     2.5  
     2.6  /**
     2.7 + * Reads the driver of an opened database.
     2.8 + *
     2.9 + * @param database		Database Handle.
    2.10 + * @param ident			Option buffer to store the identification string.
    2.11 + * @param ident_length	Maximum length of the buffer.
    2.12 + * @return				Driver Handle.
    2.13 + */
    2.14 +native Handle:SQL_ReadDriver(Handle:database, String:ident[]="", ident_length=0);
    2.15 +
    2.16 +/**
    2.17   * Retrieves a driver's identification string.
    2.18   *
    2.19 + * Example: "mysql", "sqlite"
    2.20 + *
    2.21   * @param driver		Driver Handle, or INVALID_HANDLE for the default driver.
    2.22   * @param ident			Identification string buffer.
    2.23   * @param maxlength		Maximum length of the buffer.
    2.24 @@ -158,6 +170,8 @@
    2.25  /**
    2.26   * Retrieves a driver's product string.
    2.27   *
    2.28 + * Example: "MySQL", "SQLite"
    2.29 + *
    2.30   * @param driver		Driver Handle, or INVALID_HANDLE for the default driver.
    2.31   * @param product		Product string buffer.
    2.32   * @param maxlength		Maximum length of the buffer.