Old (Deprecated?) Commands

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
Walkere
Forum Members
Forum Members
Posts: 12
Joined: Sat Oct 13, 2007 11:21 pm

Old (Deprecated?) Commands

Post 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
Image
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Old (Deprecated?) Commands

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “CMSMS Core”