Page 1 of 1

Proper way to reference tables of other modules?

Posted: Wed Mar 21, 2007 5:00 pm
by skypanther
What is the proper way to reference a table from another module? For example, from within the NMS module, how would I properly reference the FEU propdefn table?

I guess the following could potentially lead to problems:

SELECT * FROM ".cms_db_prefix()."module_feusers_propdefn ORDER BY prompt

I can't imagine that module table names get changed that often, certainly not by normal installs.

Tim

Re: Proper way to reference tables of other modules?

Posted: Wed Mar 21, 2007 5:09 pm
by calguy1000
That'll work, as it's in the same database.

But with FEU, the preferred method would be to use the functions in FrontendUsers.ap.php

i.e:

$feu = $this->GetModuleInstance('FrontEndUsers');
$propdefn = $feu->GetPropertyDefn('PropertyName');

Re: Proper way to reference tables of other modules?

Posted: Wed Mar 21, 2007 6:04 pm
by skypanther
Thanks. In this case, I want to get a list of field values in the name column from the FEU propdefn table. So, I don't necessarily know which 'PropertyName' to use. Perhaps I should have been more specific with my query example. I'm using:

SELECT name, prompt FROM ".cms_db_prefix()."module_feusers_propdefn where type = 0 ORDER BY prompt

Sounds like I can just use the table's name directly without too much trouble.

Thanks,
Tim