16.06.2015, 10:15
Quote:
With modular designs, pay close attention to the scope of the variables. If you need to use globals in a module, declare them as static rather than new so they are only visible in the module they're used in. Local variables declared within functions usually need not be declared static since there only visible to the function, anyway.
For you MySQL "class", create a global variable to hold the connection handle. Make it static so it is only visible in that file. This connection handle can be used in that file as is. If you need to use the same handle in other files, create a "getter" (like in Java), a simple wrapper that returns the variable. PHP код:
PHP код:
PHP код:
To make things easier for myself, I created an include named "default.inc" and placed it the pawno/include folder. This file will be implicitly included by the compiler without the need to specify it yourself. Then I defined these: PHP код:
PHP код:
|
Getter it's nice but main idea is to connect once in include and then use this handler everywhere. With you code logic i will be need to initiliaze connection in every file and as far as i know mysql implementation for PAWN don't contain check if there is already established connection.
if you don't mind here is some questions:
1. Why my example not working? Except static and getter code is the same.
2. Why in include "invalid function or declaration" is appear?