Quantcast
Channel: WHMCS Community Forums
Viewing all articles
Browse latest Browse all 13458

connect to db

$
0
0
Hi,

I am trying to connect to the db in a function im working on. For the Mysqli library you must have the db connection live to use the function so i need to do something like

$db = new ??????

the ? is what i dont know, whats the WHMCS class name for a new db connection. Im looking at the api now but not seeing it.

what im doing is working on the old bridge code to phpbb that i found on here, i am converting it to Mysqli library

as you can see i have added the connection var as required by the new library example mysqli_query($db,$sqlcmd)

but inside the function i must assign $db to a new connection and i dont know what that class is on the whmcs side.

PHP Code:


/* ##########################  WHMCS SIDE ############################ */

function getusername($userid) {

$db = new ????

    global 
$user_fieldid;
    
$sqlcmd "select value from tblcustomfieldsvalues where fieldid=$user_fieldid and relid=$userid";
    
$result mysqli_query($db,$sqlcmd) or die("mysqli Error in getting Username :".mysqli_error($db));
    while (
$row mysqli_fetch_object($result)) {
        return 
$row->value;
    }

}

function 
getuserpass($userid) {

$db = new ????

    global 
$pass_fieldid;
    
$sqlcmd "select value from tblcustomfieldsvalues where fieldid=$pass_fieldid and relid=$userid";
    
$result mysqli_query($db,$sqlcmd) or die("mysqli Error in getting Username :".mysqli_error($db));
    while (
$row mysqli_fetch_object($result)) {
        return 
$row->value;
    }

}

add_hook("ClientAdd",1,"create_forum_account");

?> 


Viewing all articles
Browse latest Browse all 13458

Trending Articles