ADODB, OO, php help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

ADODB, OO, php help

Post 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]
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply