Read record from Fabrik List from External Script

Status
Not open for further replies.

pastvne

Bruce Decker
I've been experimenting with a script to read a Fabrik List from a external script. I've been able to get this to work:

JModel::addIncludePath(JPATH_SITE . '/components/com_fabrik/models');
$listModel = JModel::getInstance('List', 'FabrikFEModel');

$listModel->setId(37);
$data = $listModel->getData();
var_dump($data);

I $data is a array of 10 records from list 37. But, now I'd like to be able to read specific record from this list. Actually, I'd like to issue a query against this list and return a object containing the record's data. I can do this directly with PHP and MySQL but I'd really like to read using the Fabrik API so that if I attempt to read a record excluded by prefilter, I'd be able to tell.

I've looked through the /models/list.php and I see getData but it is unclear to me if there is a way to issue a query against this list using the Fabrik API. Any advice would be greatly appreciated.
 
If you know the rowid you can use

PHP:
$listModel->getRow($rowid);

Depending on the format of the data you want there's a couple of optional additional parameters you can pass into getRow():

PHP:
/**
* Get a row of data from the table
*
* [USER=20939]param[/USER]   int   $id        id
* [USER=20939]param[/USER]   bool  $format    the data
* [USER=20939]param[/USER]   bool  $loadJoin  load the rows joined data @since 2.0.5 (used in J Content plugin)
*
* @return  objectrow
*/
 
public function getRow($id, $format = false, $loadJoin = false)
 
Exactly what I needed. I'm going to add this to the Common PHP Tasks wiki.
Thanks Rob!
-BD
 
  • Like
Reactions: rob
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top