• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

How do i get the internal_id of a joomla fabrik list element in php?

Bodaggnmo

New Member
I have build a joomla Fabrik list with several Elements. Column 1: ID Column 2: Name Column 3: Age

Some users are able to edit the list Elements, so i have changed the normal save button, to a button which executes a php script in the Background. This calls me, which user is logged in and has edited something. I was able to get the logged in joomla user in php, but now i Need also the ID, which is the internal_id from the joomla list in php.

<Code>


```php
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
jimport( 'joomla.user.user');
jimport( 'joomla.session.session');
jimport( 'joomla.user.authentication');
// now get user object and 3 example user variables
$user = JFactory::getUser();
$jid = $user->id;
$jname = $user->username;
$jguest = $user->guest;
</Code>

This is the Code to get the logged in user in the backup_cmd.php file. But now i need some ideas for the internal_id.
 
I managed to get some id, but it is not the row id, which is also in the URL of the element.

defined('_JEXEC') or die();
$db = JFactory::getDbo();
$ids = JRequest::getVar('rowid', array());

$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo $rowid = $row->id;
}

if i dump the Array it is:

array(1) { [0]=> object(stdClass)#30 (4) { ["id"]=> string(3) "103" ["option"]=> string(6) "joomla" ["params"]=> string(51) "{"mediaversion":"7e7b9e46a0af027e9eb2cddb645d4a1c"}" ["enabled"]=> string(1) "1" } }

There is no row id in it..
 
Why don't to take the email plugin of form PHP to email you and use the log plugin with compare, to see what has changed?
 
I need the rowid in php, because php script reffers to a cmd file, which executes another program called "PTC Integrity". There the cmd script writes in automatically the user and also the rowid should be written there because of a security System for the database Version.. so i Need the row id in php

If the user Edits one record, i made a button which calls the php file:
window.open("http://localhost:9090/cdb/cdb/backup_cmd.php",height=100,width=100)

When he is editing the record, the rowid is part of the URL:
http://localhost:9090/cdb/administrator/index.php?option=com_fabrik&task=form.view&formid=10&rowid=1

But it also doesn't work to ask for rowid in the backup_cmd.php
 
Last edited:
Results in the same error message..

define('_JEXEC', 1);
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', 'D:/XAMPP/htdocs/cdb');
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';

$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
jimport( 'joomla.user.user');
jimport( 'joomla.session.session');
jimport( 'joomla.user.authentication');
// now get user object and 3 example user variables
$user = JFactory::getUser();
$jid = $user->id;
$jname = $user->username;
$jguest = $user->guest;
echo $jname;

$db = JFactory::getDBO();
$row_id=$formModel->getElementData('master_table___PMT_id',true);
$row_id=is_array($row_id) ? $row_id[0] : $row_id;

Do i Need any other Code to connect? This is my full Code to fetch the user and try to fetch the id
 
I think there is another Problem. Every User has different records, so the last Expression seems to be right, i Need the column "master_table___PMT_id", which is the internal id and not the rowid
 
Hi, I don't really understand, what you are trying t do. If you create a new submit button on form, you should get the id on edit. The 'id' is not created before submit.
Please try the log plugin (form PHP) to get emailed when changes made on an edited record. (Compare data)

Cheers,
Bianka
 
I try to explain it clearly again.
I created a List with several records.

Colums of the List:
master_table___PMT_id: this is the internal id of the list
master_table___Name: the Name of a Groupmember
master_table___Age: Age of the Groupmember
master_table___function: Function of the Groupmember

I have adminstrator rights so i can see every record in this list, but the other users see only records of their Group. They are allowed to make changes or add a new record.
The records are presented on a Website in my firm for every employee, so it is important, that he knows which Version of the database he is working on.
That's why i Need a clear Version System.
In order to track changes, I have to transfer the username (works) and the PMT_id (doesn't work) in PHP. In PHP the two values should be transferred to other systems, which are responsible for the versioning of the database (works). Therefore it is mandatory to transfer the PMT_id in addition to the username. An e-mail notification cannot replace this function. Everything should be fully automated.

Therefore I created a button as an element with the property "submit" and the JavaScript plugin window.open(backup_cmd.php)
In this backup_cmd.php the query of the logged in user already works.

define('_JEXEC', 1);
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', 'D:/XAMPP/htdocs/cdb');
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';

$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
jimport( 'joomla.user.user');
jimport( 'joomla.session.session');
jimport( 'joomla.user.authentication');
// now get user object and 3 example user variables
$user = JFactory::getUser();
$jid = $user->id;
$jname = $user->username;
$jguest = $user->guest;
echo $jname;





All codes i tried so far for the master_table___PMT_id column didnt work..
 
I'm still not clear what you are trying to do. Are you trying to store each edit to a row as a new row in the same table, with an incrementing version number? Or store the original values (pre-edit) in a new row in a separate table, again with a version number, so you have an edit history? Or something else?

Whichever, I suspect you'll need a form PHP plugin to do it.

-- hugh
 
Sorry, you all have been right. The Logs Plugin is exactly that, what i needed.
The CSV file is generated and filled in with username and id, what i wanted to get. But also there appears everytime an error message in joomla when i click on "save".

1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1

This happens only, when i fill in the templae message in the logs form:
"{$my->username}" " {master_table___PMT_id}"

But the data is written correctly in the file.
 
There is an error in your SQL syntax. You should post your script, to figure out, what is wrong.
 
Puh, i'm trying to find out, in which script the error is. I have many scripts there..
the error occurs right after clicking save on the view with the Elements of the form
 
Don't set "Record in DB" to no, you can't undo it in form's setup (you can by "hacking" the Fabrik core table in the DB but you must know what you are doing).
An error "...the right syntax to use near ')' " is no connection error but a syntax error.
You can enable Fabrik debug in Fabrik Options settings and then append &fabrikdebug=1 to your URL to get some more informations.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top