mirror of
https://github.com/ChronosX88/psyced.git
synced 2024-12-05 00:22:19 +00:00
sql ifdefs
This commit is contained in:
parent
18e72b74cc
commit
d52b7ee982
@ -1,21 +1,26 @@
|
|||||||
#include <net.h>
|
#include <net.h>
|
||||||
|
|
||||||
|
#if defined(STORAGE_MYSQL)
|
||||||
|
# if __EFUN_DEFINED__(db_connect)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* from ldmud's concepts/mysql:
|
* from ldmud's concepts/mysql:
|
||||||
|
*
|
||||||
* As mySQL "limits" the number of connections to 100 and as every
|
* As mySQL "limits" the number of connections to 100 and as every
|
||||||
* connection to the mySQL-server takes time, you should use
|
* connection to the mySQL-server takes time, you should use
|
||||||
* database serverobjects in your MUD which constantly keep the
|
* database serverobjects in your MUD which constantly keep the
|
||||||
* connection to the mySQL-server.
|
* connection to the mySQL-server.
|
||||||
*
|
*
|
||||||
* hence we use this instead of letting each object have it's own connection
|
* hence we use this instead of letting each object have its own connection.
|
||||||
|
*
|
||||||
|
* Actually we aren't using this code at all, since psyced makes no
|
||||||
|
* operations by which it makes sense to use SQL rather than flat files.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
volatile int handle;
|
volatile int handle;
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
#if defined(STORAGE_MYSQL)
|
|
||||||
handle = db_connect(STORAGE_MYSQL_DATABASE, STORAGE_MYSQL_USER, STORAGE_MYSQL_PASSWORD);
|
handle = db_connect(STORAGE_MYSQL_DATABASE, STORAGE_MYSQL_USER, STORAGE_MYSQL_PASSWORD);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mixed query(string q, varargs mixed args) {
|
mixed query(string q, varargs mixed args) {
|
||||||
@ -30,3 +35,6 @@ mixed query(string q, varargs mixed args) {
|
|||||||
data += ({ row });
|
data += ({ row });
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include <net.h>
|
#include <net.h>
|
||||||
|
|
||||||
|
#if defined(STORAGE_PGSQL)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* using one database connection is sufficient
|
* using one database connection is sufficient
|
||||||
*
|
*
|
||||||
@ -10,10 +12,8 @@
|
|||||||
|
|
||||||
create() {
|
create() {
|
||||||
int ret;
|
int ret;
|
||||||
#if defined(STORAGE_PGSQL)
|
|
||||||
ret = pg_connect_sync(STORAGE_PGSQL_CONNECT);
|
ret = pg_connect_sync(STORAGE_PGSQL_CONNECT);
|
||||||
PT(("ret %d\n", ret))
|
PT(("ret %d\n", ret))
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mixed query(string q, varargs mixed args) {
|
mixed query(string q, varargs mixed args) {
|
||||||
@ -21,3 +21,5 @@ mixed query(string q, varargs mixed args) {
|
|||||||
// avoid sql injections
|
// avoid sql injections
|
||||||
return pg_query_sync(sprintf(q, args...));
|
return pg_query_sync(sprintf(q, args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user