Jump to content


Photo

[Resolved]Problem with etomite object in functions


  • This topic is locked This topic is locked
3 replies to this topic

#1 Markioooo

Markioooo

    Etomite Forum Newbie

  • Member
  • 16 posts

Posted 07 March 2008 - 12:12 PM

Can anybody tell me how I can use this function inside a snippet? I am getting an error (Fatal error: Call to a member function dbQuery()). I have tried creating an instance of the etomite object inside the snippet (maybe that will work if I destroy the object at the end of the function somehow?).

function getActiveKeyword($cid, $kid) {

$tbl = $etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix'];
$sql = "SELECT * FROM ".$tbl."keyword_xref WHERE content_id = ".$cid." AND keyword_id = ".$kid;
$rs = $etomite->dbQuery($sql);
$row = $etomite->fetchRow($rs);
$keyword_id = $row['keyword_id'];
return (isset($keyword_id))?"V":"-";
}

#2 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 07 March 2008 - 12:18 PM

add $etomite as a global variable within the function like this:

function getActiveKeyword($cid, $kid) {
global $etomite;

$tbl = $etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix'];
$sql = "SELECT * FROM ".$tbl."keyword_xref WHERE content_id = ".$cid." AND keyword_id = ".$kid;
$rs = $etomite->dbQuery($sql);
$row = $etomite->fetchRow($rs);
$keyword_id = $row['keyword_id'];
return (isset($keyword_id))?"V":"-";
}



#3 Markioooo

Markioooo

    Etomite Forum Newbie

  • Member
  • 16 posts

Posted 07 March 2008 - 12:25 PM

Great, that solved my problem! Thanks for your (extremely fast) reply! :Applause:

Edited by Markioooo, 07 March 2008 - 12:26 PM.


#4 Dean

Dean

    Loves Etomite Forums!

  • Admin
  • 4,787 posts

Posted 07 March 2008 - 04:01 PM

Support Issue Resolved!

The issue this topic was opened for has been resolved, and we look forward to helping you in the future. If you need further assistance, please open a new topic.

This topic will now be marked as Resolved. If you are satisfied with the support provided here at Etomite (or just appreciate the service we provide), you may want to make a donation to help cover forum and server costs in order to help this quality support continue. If you wish to donate, click Here




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users