DB layer?

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
I am working on a script that can be installed on different db system, so they are using dblayer (i'm not sure if this is something they made up or is somewhat known) but it doesn't have "mysql_fetch_field" and i need to add it in there;

http://us2.php.net/mysql_fetch_field
PHP:
    function fetch_field($query_id = 0) 
    {
        return ($query_id) ? @mysql_fetch_field($query_id) : false;
    }
that is so far what i have done, but I am missing the second argument, the $field_offset, can somebody help me fix that?
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
is this for SOD?

http://us2.php.net/mysql_fetch_field said:
field_offset

The numerical field offset. If the field offset is not specified, the next field that was not yet retrieved by this function is retrieved. The field_offset starts at 0.

try this code:
PHP:
function fetch_field($query_id = 0, $field_offset = NULL) 
    {
        return ($query_id) ? @mysql_fetch_field($query_id, $field_offset) : false;
    }
that should make it so if you don't pass a second variable to fetch_field, then it should act like there's no second value, but if you do pass a number, then it would work that way too.

the return line is actually an if else conditional. since query id = 0 by default, if there's nothing sent, it will return false in the conditional, thus not executing the mysql function.


Remember, if this works for you, then please add REP. It's not hard ;)
 
Last edited:

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
yes it is for SOD, and let me look into what you said, I tried it but it didn't work; but I might have been careless
 
Top