Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3f1cf0f
Create README.md
MichaelHillcox Sep 16, 2016
c392130
Added connect prams to mysql_real_connect updated a few bits
Sep 16, 2016
c458966
Updated docs and fixed error message
Sep 16, 2016
471f59a
Updated Readme to reflect new cvar and default ports.
Sep 16, 2016
1392a50
Rewrote mysql_fetch_rows's logic to support 2D arrays and different r…
Sep 16, 2016
2ee485d
Updated docs.
Sep 16, 2016
3542765
Fixed issues
Sep 16, 2016
58a80fb
Issue and removed unused declaration
Sep 16, 2016
4acbb94
Still getting good at this C stuff.
Sep 16, 2016
c625796
Removed unused cvars & fixed something.
Sep 16, 2016
cf632a1
Fixed.
Sep 16, 2016
b8af8a8
[HUGE] Added unix support ( files )
Sep 16, 2016
332da3a
added correct .so
Sep 16, 2016
667ee47
fixed complier issues
Sep 16, 2016
004e99a
Made check for windows/unix
Sharpienero Sep 16, 2016
d9b5ced
Added check for windows/unix
Sharpienero Sep 16, 2016
d3be7dc
Various fixes #1, support for 4 databases begins
T-Maxxx Sep 17, 2016
ea95770
Improved 'mysql_real_connect' for few DBs
T-Maxxx Sep 17, 2016
155badc
Improved 'mysql_close'
T-Maxxx Sep 17, 2016
fe535ec
Improved 'mysql_affected_rows'
T-Maxxx Sep 17, 2016
9be248d
Improved 'mysql_query'
T-Maxxx Sep 17, 2016
84fe460
Improved 'mysql_num_rows'
T-Maxxx Sep 17, 2016
52c646d
Improved 'mysql_num_fields'
T-Maxxx Sep 17, 2016
097ae04
'mysql_fetch_row' rises. Again ._.
T-Maxxx Sep 17, 2016
1407283
Improved 'mysql_fetch_rows'
T-Maxxx Sep 17, 2016
b7e969c
Some bugfixes
T-Maxxx Sep 17, 2016
aeb37ec
New compile OS-specific directory, Windows checked
T-Maxxx Sep 17, 2016
aff3507
Fixed compile scripts
T-Maxxx Sep 17, 2016
6e0a3f5
Edited compiler script for Unix, added experimental field 'rewind' fo…
T-Maxxx Sep 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mysql.config
mysql.creator
mysql.creator*
mysql.files
mysql.includes
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# mysql
CoD4X MySQL support for GSC.

# Contributors
- [Sharpienero](https://github.com/Sharpienero/)
- [Michael Hillcox](https://github.com/MichaelHillcox/)
- [T-Maxxx](https://github.com/T-Max/)

# Script Docs
### MySQL Related Functions

#### CVARS
##### `mysql_port`
You can use `mysql_port` to define a default port to connect to. `mysql_real_connect` will still prioritise its own argument
over the CVAR so leaving `mysql_real_connect`'s port empty will cause it to fall back to `mysql_port`. If `mysql_port` and
`mysql_real_connect`'s ports are both empty then by default fall back onto mysqls default port `3306`

Usage example: `set mysql_port 3306`

#### `mysql_real_connect()`

Connects to a database

Usage example `db = mysql_real_connect(host, user, pass, db, *port)`

####### Note: *the port pram is optional

###### Use 127.0.0.1 on unix, and the default port for mysql is 3306.

#### `mysql_close()`

Close a MySQL Connection

Usage example `mysql_close()`

#### `mysql_errno()`

Returns the MySQL Error number.
Usage example: `error = mysql_errno()`

#### `mysql_error()`

Returns the MySQL Error number.
Usage example: `error = mysql_error()`

#### `mysql_query()`

Send a query to a database and returns the result for use in the following functions:

Usage example:
```cs
query = mysql_query(<string query>)
```

#### `mysql_rowcount()`
Returns the amount of rows

Usage example: `count = mysql_rowcount()`

#### `mysql_affected_rows()`
Returns the amount of affected rows

Usage example: `count = mysql_affected_rows()`

#### `mysql_num_field()`

Returns number of fields

Usage example = `count = mysql_num_field()`


#### `mysql_fetch_rows()`

Fetches and handles all rows from the `mysql_query()`

Usage example = `data = mysql_fetch_rows()`

Returns: This function will return two different data types depending on the field count. If the field count is one, `if( mysql_num_field(mysql) == 1 )`, then the function will return a key based array `data['field_name']`. If the `mysql_num_field()` is larger than one then it will return a 2D array. The first array being a numeric array and the second being a key based array `data[0]['field_name']`.
Binary file added bin/unix/cod4x_mysql.so
Binary file not shown.
File renamed without changes.
Binary file added bin/win32/cod4x_mysql.dll
Binary file not shown.
Empty file added bin/win32/dummy
Empty file.
16 changes: 16 additions & 0 deletions build_unix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
cd bin/unix
LIBNAME='cod4x_mysql.so'

echo Compiling...
gcc -m32 -O3 -Wall -Wattributes -fPIC -s -fvisibility=hidden -I../../mysql/unix/include -c ../../*.c

echo Linking...
gcc -m32 -O3 -s -shared -fvisibility=hidden -o $LIBNAME *.o ../../mysql/unix/lib/libmysqlclient.a

echo Cleaning up...
rm *.o

echo Done.

cd ../..
15 changes: 8 additions & 7 deletions build_win32.bat
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
@echo off
cd bin
cd bin/win32
set LIBNAME="cod4x_mysql.dll"

echo Compile...
gcc -O3 -I../mysql/include -c ../*.c
echo Compiling...
gcc -O3 -Wall -s -fvisibility=hidden -I../../mysql/windows/include -c ../../*.c

echo Link...
gcc -O3 -shared -o cod4x_mysql.dll *.o ../mysql/lib/libmysql.lib ../../libcom_plugin.a
echo Linking...
gcc -O3 -s -shared -fvisibility=hidden -o %LIBNAME% *.o ../../mysql/windows/lib/libmysql.lib ../../../libcom_plugin.a

echo Cleanup...
echo Cleaning up...
del *.o

echo Done.

cd ..
cd ../..
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading