mad_php Posted April 26, 2007 Share Posted April 26, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.