11
tcnet
Re: how can i create and use xoops object handler in my module?
  • 2009/6/29 11:56

  • tcnet

  • Friend of XOOPS

  • Posts: 297

  • Since: 2006/5/12


Trabis,
Thanks very much for this explanation. I have searched for XoopsObject and module handler instruction for a long time. As far as I know this is the first understandable explanation of the module handler published here. I know you are very busy with core upgrades, your modules and your sites, so I appreciate you taking the time to publish this very informative post.

Suggestion to the moderator: This topic could be moved to the Wiki, FAQ's or at least made sticky so that it does not get lost in the forum's abyss.


12
bumciach
Re: how can i create and use xoops object handler in my module?
  • 2009/8/29 18:47

  • bumciach

  • Not too shy to talk

  • Posts: 153

  • Since: 2007/6/25


I have two related tables, which I would like to get data through XoopsPersistableObjectHandler.

class pfawlAutorHandler extends XoopsPersistableObjectHandler
{
    function 
getAutorzy($criteria=null)
    {
        
$osoba_handler xoops_getModuleHandler('osoba');
        
$this->field_link $osoba_handler->keyName;
        
$this->field_object "FKid_osoby";
        
$this->table_link $osoba_handler->table;
      
$ret $this->getByLink($criteria);
      return 
$ret;
    }
}

and my script
$autor_handler xoops_getmodulehandler('autor');
$objs $autor_handler->getAutorzy();


I can see in the logger that the SQL query is submitted correctly. Fired directly in the database returns the contents of both tables. But $objs contains the fields from only one table.
I do not know if this is possible (using getByLink method).

13
trabis
Re: how can i create and use xoops object handler in my module?
  • 2009/8/29 19:23

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


The object is populated with the object vars only.

You can create 'fake' vars for your object
$this->initVar("fieldfromothertable", XOBJ_DTYPE_INT, 0, false);



14
bumciach
Re: how can i create and use xoops object handler in my module?
  • 2009/9/1 12:41

  • bumciach

  • Not too shy to talk

  • Posts: 153

  • Since: 2007/6/25


Thanks for your reply Trabis.
Next question :) Is this way (adding 'fake' vars for object) and with XoopsModel can we do join more than the two tables?
Or better "manually" type in the SQL query for linking multiple tables and return data in a regular array without this object mapping?

Login

Username:
Password:

Lost Password? Register now!

Who's Online

61 user(s) are online (31 user(s) are browsing Support Forums)


Members: 0


Guests: 61


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits