Page 1 of 1

Old (Deprecated?) Commands

Posted: Sat Oct 20, 2007 5:51 pm
by Walkere
Howdy,

I've been working on a module for my website and I came across a few situations in which I found two different examples of accomplishing what I wanted (in the documentation and other mod code).

The first situation involves getting a reference to $db.

In one place, I found...
$db =& $gCms->GetDb();

Somewhere else I found...
$db = $this->cms->db;

The second one seems to be better to me.  I was just curious if one method was outdated and/or deprecated.

The other situation involves referencing one module from inside another module.

In the documentation, I found...

Code: Select all

global $gCms;
  if( !isset( $gCms->modules['TheModuleIWant'] ) || !isset( $gCms->modules['TheModuleIWant']['object'] ) )
    {
       return;
    }
  $themoduleiwant = $gCms->modules['TheModuleIWant']['object'];
Snooping around the CustomContent module, I found...

Code: Select all

    $module =& $this->GetModuleInstance('FrontEndUsers');
    if( !$module ) return FALSE;
I had trouble getting the first method to work, but the second one worked fine.  Again, is one of these two outdated/deprecated?

I'm just learning my way around CMSMS, so I want to make sure I learn the preferred methods the first go around...

Thanks a ton,
- Walkere

Re: Old (Deprecated?) Commands

Posted: Sun Oct 21, 2007 2:33 pm
by calguy1000

Code: Select all

$db =& $this->GetDb() 
is the preferred method of getting the database handle

and

Code: Select all

$obj =& $this->GetModuleInstance() 
is the preferred method of getting a reference to another module from within one.