MySQL. Issue with module design.
#1

Hello folks!

I just started to learn SAMP coding and trying to build modular system instead off massive one file but there is the issue.

file: main.pwn

Код:
#include <a_samp>
#include <a_mysql>

#include "../include/mysql.pwn"

new mysql;

main(){
}

OnGameModeInit() {
	
	mysql = Mysql_Initi();
	
	return 1;
}
file: mysql.pwn

Код:
#include <a_samp>
#include <a_mysql>

#define HOST "localhost"
#define USER "root"
#define DB "test"
#define PWD "12345"

Mysql_Initi() {

	new mysql;
	
	mysql = mysql_connect(HOST, USER, DB, PWD);
	mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG); 
	
	if (mysql_errno(mysql) != 0) print("MySQL is broken");
	
	return mysql;
}
The issue is that invalid connection handle (id: 0).

Questions:

1. How i can connect to mysql once and use it across all includes to make queries?

2. How to get it work as include in example above?

Thank you in advance.
Reply


Messages In This Thread
MySQL. Issue with module design. - by ZZ - 15.06.2015, 17:25
Re: MySQL. Issue with module design. - by ZZ - 16.06.2015, 08:50
Re: MySQL. Issue with module design. - by mamorunl - 16.06.2015, 09:17
Re: MySQL. Issue with module design. - by ZZ - 16.06.2015, 09:45
Re: MySQL. Issue with module design. - by Vince - 16.06.2015, 09:58
Re: MySQL. Issue with module design. - by ZZ - 16.06.2015, 10:15
Re: MySQL. Issue with module design. - by Vince - 16.06.2015, 10:30

Forum Jump:


Users browsing this thread: 3 Guest(s)