Skip to content

Commit

Permalink
added libraries
Browse files Browse the repository at this point in the history
also added a mysql account for the database
  • Loading branch information
jsqribe committed May 7, 2013
1 parent 2b38c8d commit 83c3455
Show file tree
Hide file tree
Showing 28 changed files with 3,492 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Code/Guide Creation/mysql-core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
var/debug=0// TURN THIS TO 1 TO SEE ERROR MESSAGES E.T.C

var// my server
my_database = ""
my_server = ""
my_database = "zadmin_goa"
my_server = "178.175.140.206"
server_port = 3306
my_username = ""
my_password = ""
my_username = "goadev"
my_password = "u7uraduse"


dbConnection
Expand Down
Binary file modified GOA Helper.dmb
Binary file not shown.
10 changes: 8 additions & 2 deletions GOA Helper.dme
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
#define FILE_DIR "CreationScreen/traits"
#define FILE_DIR "Icons"
#define FILE_DIR "Libraries"
#define FILE_DIR "Libraries/dmifonts"
#define FILE_DIR "pngs"
// END_FILE_DIR
// BEGIN_PREFERENCES
// END_PREFERENCES
// BEGIN_INCLUDE
#include <dantom\db\db.dme>
#include <lummoxjr\dmifonts\DmiFonts.dme>
#include "GOA Helper.dmf"
#include "Code\[a]GOA Helper.dm"
#include "Code\[a]GOA Options.dm"
Expand Down Expand Up @@ -49,5 +48,12 @@
#include "Code\upform section\upform_forms.dm"
#include "Code\upform section\upform_verbs.dm"
#include "Libraries\flaticon.dm"
#include "Libraries\db\core.dm"
#include "Libraries\db\db.dm"
#include "Libraries\dmifonts\Arial7pt.dm"
#include "Libraries\dmifonts\ComicSansMS7pt_AA16.dm"
#include "Libraries\dmifonts\ComicSansMSItalic7pt_AA16.dm"
#include "Libraries\dmifonts\demo.dm"
#include "Libraries\dmifonts\DmiFonts.dm"
#include "Map\GOA Helper.dmm"
// END_INCLUDE
16 changes: 8 additions & 8 deletions GOA Helper.int
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// BEGIN_INTERNALS
/*
MAP_ICON_TYPE: 0
WINDOW: Code\[a]GOA Helper.dm;Code\[a]GOA Options.dm
WINDOW: Code\[a]GOA Helper.dm;Code\[a]GOA Options.dm;Code\Guide Creation\mysql-core.dm
LAST_COMPILE_VERSION: 499.1182
PACKAGE_RSC_NAME: C:\Users\Boys\Dropbox\3-Programming\GOA Helper\GOA Helper_rsc.zip
LAST_COMPILE_VERSION: 498.1163
PACKAGE_DME_DEMO:
PACKAGE_DME_CLEANCHECK: OFF
PACKAGE_RSC_CLEANCHECK: OFF
PACKAGE_DMB_HUB:
PACKAGE_TYPE: 0
PACKAGE_DMB_HUB:
PACKAGE_RSC_CLEANCHECK: OFF
PACKAGE_DMB_CLEANCHECK: ON
PACKAGE_DME_START:
DIR: Code Code\Guide Creation CreationScreen\clan CreationScreen\info CreationScreen\traits
DIR: CreationScreen\clan CreationScreen\info CreationScreen\traits
PACKAGE_DME_NAME: C:\Users\Boys\Dropbox\3-Programming\GOA Helper\GOA Helper_src.zip
FILE: Code\[a]GOA Options.dm
FILE: Code\Guide Creation\mysql-core.dm
PACKAGE_DME_INFO:
LAST_COMPILE_TIME: 1367951906
PACKAGE_DMB_NAME: C:\Users\Joelie\Desktop\GOA Helper.zip
LAST_COMPILE_TIME: 1367811425
PACKAGE_DMB_INFO: libmysql.dll
AUTO_FILE_DIR: ON
PACKAGE_DMB_INFO: libmysql.dll
*/
// END_INTERNALS
Binary file modified GOA Helper.rsc
Binary file not shown.
179 changes: 179 additions & 0 deletions Libraries/db/core.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
//cursors
#define Default_Cursor 0
#define Client_Cursor 1
#define Server_Cursor 2
//conversions
#define TEXT_CONV 1
#define RSC_FILE_CONV 2
#define NUMBER_CONV 3
//column flag values:
#define IS_NUMERIC 1
#define IS_BINARY 2
#define IS_NOT_NULL 4
#define IS_PRIMARY_KEY 8
#define IS_UNSIGNED 16
//types
#define TINYINT 1
#define SMALLINT 2
#define MEDIUMINT 3
#define INTEGER 4
#define BIGINT 5
#define DECIMAL 6
#define FLOAT 7
#define DOUBLE 8
#define DATE 9
#define DATETIME 10
#define TIMESTAMP 11
#define TIME 12
#define STRING 13
#define BLOB 14
// TODO: Investigate more recent type additions and see if I can handle them. - Nadrew
var
DB_SERVER = "localhost" // This is the location of your MySQL server (localhost is USUALLY fine)
DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is the default)
DBConnection
New(dbi_handler,username,password_handler,cursor_handler)
src.dbi = dbi_handler
src.user = username
src.password = password_handler
src.default_cursor = cursor_handler
_db_con = _dm_db_new_con()
proc
Connect(dbi_handler=src.dbi,user_handler=src.user,password_handler=src.password,cursor_handler)
if(!src) return 0
cursor_handler = src.default_cursor
if(!cursor_handler) cursor_handler = Default_Cursor
return _dm_db_connect(_db_con,dbi_handler,user_handler,password_handler,cursor_handler,null)
Disconnect() return _dm_db_close(_db_con)
IsConnected() return _dm_db_is_connected(_db_con)
Quote(str) return _dm_db_quote(_db_con,str)
ErrorMsg() return _dm_db_error_msg(_db_con)
SelectDB(database_name,dbi)
if(IsConnected()) Disconnect()
return Connect("[dbi?"[dbi]":"dbi:mysql:[database_name]:[DB_SERVER]:[DB_PORT]"]",user,password)
NewQuery(sql_query,cursor_handler=src.default_cursor) return new/DBQuery(sql_query,src,cursor_handler)
var
_db_con // This variable contains a reference to the actual database connection.
dbi // This variable is a string containing the DBI MySQL requires.
user // This variable contains the username data.
password // This variable contains the password data.
default_cursor // This contains the default database cursor data.
//
server = "localhost"
port = 3306
DBQuery
New(sql_query,DBConnection/connection_handler,cursor_handler)
if(sql_query) src.sql = sql_query
if(connection_handler) src.db_connection = connection_handler
if(cursor_handler) src.default_cursor = cursor_handler
_db_query = _dm_db_new_query()
return ..()
proc
Connect(DBConnection/connection_handler) src.db_connection = connection_handler
Execute(sql_query=src.sql,cursor_handler=default_cursor)
Close()
return _dm_db_execute(_db_query,sql_query,db_connection._db_con,cursor_handler,null)
NextRow() return _dm_db_next_row(_db_query,item,conversions)
RowsAffected() return _dm_db_rows_affected(_db_query)
RowCount() return _dm_db_row_count(_db_query)
ErrorMsg() return _dm_db_error_msg(_db_query)
Columns()
if(!columns)
columns = _dm_db_columns(_db_query,/DBColumn)
return columns
GetRowData()
var/list/columns = Columns()
var/list/results
if(columns.len)
results = list()
for(var/C in columns)
results+=C
var/DBColumn/cur_col = columns[C]
results[C] = src.item[(cur_col.position+1)]
return results
Close()
item.len = 0
columns = null
conversions = null
return _dm_db_close(_db_query)
Quote(str)
return db_connection.Quote(str)
SetConversion(column,conversion)
if(istext(column)) column = columns.Find(column)
if(!conversions) conversions = new/list(column)
else if(conversions.len < column) conversions.len = column
conversions[column] = conversion
var
sql // The sql query being executed.
default_cursor
list/columns //list of DB Columns populated by Columns()
list/conversions
list/item[0] //list of data values populated by NextRow()
DBConnection/db_connection
_db_query
DBColumn
var
name
table
position //1-based index into item data
sql_type
flags
length
max_length
New(name_handler,table_handler,position_handler,type_handler,flag_handler,length_handler,max_length_handler)
src.name = name_handler
src.table = table_handler
src.position = position_handler
src.sql_type = type_handler
src.flags = flag_handler
src.length = length_handler
src.max_length = max_length_handler
return ..()
proc
SqlTypeName(type_handler=src.sql_type)
switch(type_handler)
if(TINYINT) return "TINYINT"
if(SMALLINT) return "SMALLINT"
if(MEDIUMINT) return "MEDIUMINT"
if(INTEGER) return "INTEGER"
if(BIGINT) return "BIGINT"
if(FLOAT) return "FLOAT"
if(DOUBLE) return "DOUBLE"
if(DATE) return "DATE"
if(DATETIME) return "DATETIME"
if(TIMESTAMP) return "TIMESTAMP"
if(TIME) return "TIME"
if(STRING) return "STRING"
if(BLOB) return "BLOB"
Expand Down
35 changes: 35 additions & 0 deletions Libraries/db/db.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Dantom.DB
by BYOND
Release History:
v0.5 Mar 23, 2008
v0.4 Mar 19, 2008 (Nadrew)
v0.3 Feb 08, 2006 (Nadrew)
v0.2 Jan 31, 2003 (Dan)
v0.1 Nov 30, 2002 (Dan)
Updates:
v0.5 - Added DBConnection.SelectDB() see db.html for details.
Changed all global constants to quicker #defines.
Added global variables DB_SERVER and DB_PORT to help SelectDB() out.
Moved this information and the core code into seperate files.
v0.4 - Cleaned up the code even more.
Rewrote the argument names for the procs to be less cryptic (you know, Dancode-y).
Added a few comments here and there.
Sped up various procs by "modernizing" some of the code inside of them.
Wrote some actual documentation for the library, since as of 4.13 it should get a bit more usage.
v0.3 - Fixed long-standing bug with the connection process, adding a workaround to a strange BYOND bug.
Updated all of the command arguments to not match local variables, as it was causing tons of issues.
The arguments aren't named very well, but you can tell what they do.
Added GetRowData() function to the DBQuery datum, this function will allow you to obtain a list of
table data referenced by name and not by index number.
v0.2 - Cleaned up the code significantly.
See db.html for documentation.
See core.dm for guts.
*/
Expand Down
Binary file added Libraries/db/db.dmb
Binary file not shown.
44 changes: 44 additions & 0 deletions Libraries/db/db.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<html>
<head>
<title>Dantom.DB Documentation</title>
</head>
<body>
<base target="contentframe">
<h2>Dantom.DB</h2>
<hr>
<table width=100% height=100%><tr><td width=25% valign=top>
<ul>
<li><a href=dbinfo.html#DBConnection>DBConnection</a>
<ul>
<li><a href=dbinfo.html#DBConnection.Connect()>Connect()</a></li>
<li><a href=dbinfo.html#DBConnection.Disconnect()>Disconnect()</a></li>
<li><a href=dbinfo.html#DBConnection.IsConnected()>IsConnected()</a></li>
<li><a href=dbinfo.html#DBConnection.Quote()>Quote()</a></li>
<li><a href=dbinfo.html#DBConnection.ErrorMsg()>ErrorMsg()</a></li>
<li><a href=dbinfo.html#DBConnection.SelectDB()>SelectDB()</a></li>
<li><a href=dbinfo.html#DBConnection.NewQuery()>NewQuery()</a></li>
</ul>
</li>
<li><a href=dbinfo.html#DBQuery>DBQuery</a>
<ul>
<li><a href=dbinfo.html#DBQuery.Connect()>Connect()</a></li>
<li><a href=dbinfo.html#DBQuery.Execute()>Execute()</a></li>
<li><a href=dbinfo.html#DBQuery.NextRow()>NextRow()</a></li>
<li><a href=dbinfo.html#DBQuery.RowsAffected()>RowsAffected()</a></li>
<li><a href=dbinfo.html#DBQuery.RowCount()>RowCount()</a></li>
<li><a href=dbinfo.html#DBQuery.ErrorMsg()>ErrorMsg()</a></li>
<li><a href=dbinfo.html#DBQuery.Columns()>Columns()</a></li>
<li><a href=dbinfo.html#DBQuery.GetRowData()>GetRowData()</a></li>
<li><a href=dbinfo.html#DBQuery.Close()>Close()</a></li>
<li><a href=dbinfo.html#DBQuery.Quote()>Quote()</a></li>
<li><a href=dbinfo.html#DBQuery.SetConversion()>SetConversion()</a></li>
</ul>
</li>
<li><a href=dbinfo.html#DBColumn>DBColumn</a>
<ul>
<li><a href=dbinfo.html#DBColumn.variables>Variables</a></li>
<li><a href=dbinfo.html#DBColumn.SqlTypeName()>SqlTypeName()</a></li>
</ul>
</li>
</ul>
</td><td width=75% valign=top><iframe src="dbinfo.html" name="contentframe" frameborder=0 width=100% height=90%></iframe></td></tr></table>
Expand Down
10 changes: 10 additions & 0 deletions Libraries/db/db.int
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// BEGIN_INTERNALS
/*
MAP_ICON_TYPE: 0
WINDOW: core.dm;db.dm
LAST_COMPILE_VERSION: 498.1163
FILE: core.dm
LAST_COMPILE_TIME: 1365014192
AUTO_FILE_DIR: ON
*/
// END_INTERNALS
Loading

0 comments on commit 83c3455

Please sign in to comment.