Page 1 of 1

ADODB, OO, php help

Posted: Fri Apr 27, 2007 5:55 am
by mad_phpq
pickle | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


How can i move the db open connection outside the class and still get it to work? I have limited php OO experience.

[syntax="php"]<?php

include $vpath . 'adodb/adodb.inc.php';

   // menusController
   class menusController
   {
      
      
      function  Get ( $id )
      {
         $server = "host";
         $user = "user";
         $pwd = "pass";
         $db = "testdb";

         $DB = NewADOConnection('mysql');
         $DB->debug=true;
         $DB->Connect($server, $user, $pwd, $db);
         
         $rs = $DB->Execute("call insert_proc()");
         
         
      }
   }

?>

pickle | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri Apr 27, 2007 9:52 am
by pickle
You can:
  1. Create the DB connection & pass it as an argument to either the menuController constructor method or to the Get() method.
  2. Create the DB connection & declare it as a global.