Jump to content

mysqli object help


mad_php

Recommended Posts

My Object Oriented Php skills is limited. How can i connect to this database without having to instantiate a db connection on every class or function. Ie can i instantiate it on a global include file and run the $mysql->prepare statement without it crashing. Can anyone help me? Thanks

 

class menusController

{

 

function  Get ( $id )

{

**** > $mysqli = new mysqli("SERVER","USER","PASS","DB"); ****

 

$stmt = $mysqli->prepare("call menusGet_proc(?)");

$stmt->bind_param("i", $id);

 

$stmt->execute();

 

$stmt->bind_result($id,$name);

 

if ( $stmt->fetch() ){

$clObject = new menusInfo ( $id, $name );

}

 

return $clObject;

}

Link to comment
https://forums.phpfreaks.com/topic/48782-mysqli-object-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.