Hot answers tagged

4

$row contains inserted data with PK. So $row->id is id of the saved data. So you can do public static function CreateMail($userid, $title, $state = 1) { $maildata['userid'] = $userid; $maildata['title'] = $title; $maildata['state'] = $state; $row=JTable::...


4

Try using the postSaveHook method which allows the controller to access model data after it has been saved. public function postSaveHook($model, $validData) { $item = $model->getItem(); $my_new_group_id = $item->get('id'); }


3

Class JTable is created to work strictly on database object. Table object should create,modify,delete,check data in database. It can be used in many models, helpers, modules. Single model some times have to use multiple tables and it can happen in many models. If you use JTable you don't have to rewrite SQL in every model just to retrieve or modify a single ...


3

I assume you have 2 tables and you want to display a list of items from table 1 but add also some data from table 2 (like the total sum) for each item. If you want to use default Joomla functionality you have to get the total sum in your list query for the first table. This can be done with the help of subselects (MySQL subqueries). You won't be able to use ...


3

You can just execute it in the same way than a simple query. db->setQuery($my_big_query); $row = $db->loadObject(); Of course, it would be very difficult to translate the SQL statement to build it with Query API $query->select(...)->from(...). It is better to just handle the query with a big string, avoiding PHP performance bottlenecks. ...


2

The filter fields list is a configuration option for ordering purposes, it's a white list of field names that are permitted for usage in queries, so apparently you can use a.field1 for instance as query specific. So in your view, you write something like this: <?php echo JHtml::_('grid.sort', 'COM_MYCOMPONENT_NAME', 'name', $listDirn, $listOrder); ?> ...


2

I don't see where in your code you are outputting the object that you mentioned, normally the query produced by getListQuery should result in an array. I'm presuming that object is an example of one that might be contained within the array? If so then I would replace your group concat as follows $query->select('GROUP_CONCAT(cast(concat(tma.filename,\'|\...


2

In the most generic way, you can write a query to load the articles in a list. Or, you can work with the article model. You can check how it works in a content module or in content component: mod_articles_latest modules/mod_articles_latest/helper.php // Get an instance of the generic articles model $model = JModelLegacy::getInstance('Articles', '...


2

Mea culpa, I had to add the name of the group: $form->setFieldAttribute('test', 'country', 'US', 'personal');


2

By default, each http request is independent. You have to send all parameters again in each call. Alternatively, if your client can keep session cookies, then you can store server-side variables in user session to keep an state between http requests. $session = JFactory::getSession(); $session->set('myId', $myId); ... $session = JFactory::getSession(); $...


1

It appears you are submitting the from without executing the validation. Using jQuery, you could listen for the form submit event, check validation and submit the form if it passes. At the top of your PHP file add the following to load the jQuery library: JHtml::_('jquery.framework'); Add the below JS to the page inside a script tag: (function($) { ...


1

I suspect in the context this is being used, you might want to put ignore_request to true? I believe ContentModelArticles::getItems calls ContentModelArticles::populateState (through ContentModelArticles::getListQuery which in turn call ContentModelArticles::getState) which in turn run the code $value = $app->input->get('limit', $app->get('...


1

GROUP_CONCAT is a performance killer. Not to mention that in your query it is possible that it will join rows before it will filter them. So will waste a lot of memory and cpu time on bigger data sets. I would remove this: $query->select('GROUP_CONCAT(cast(concat(tma.filename,\', \',tma.filepath)AS char) SEPARATOR \', \') AS attachments') -...


1

The problem is solved. On Joomla 3.5 the PDO driver does not return an id. This is discussed and will be solved: https://github.com/joomla/joomla-cms/issues/9534


1

To get the last insertId use: $newID = $row->insertId(); Here is the documentation You have to call it just after $store = $row->store();


1

On Linux the best you can do is work out the last modified time of a certain file by using filetime (http://php.net/filemtime). So to work out the Joomla installation date you could run filetime on a file that is not likely to have been edited /components/index.html. You could use the same principle for extensions by doing : filetime('/components/com_foo/...


1

Even though this is an old post. I wanted to post one of the solutions that helped me. JLoader::import('group', JPATH_ADMINISTRATOR.'/components/com_users/models'); $groupModel = JModelLegacy::getInstance( 'Group', 'UsersModel' ); $groupModel->save($group); $groupId = $groupModel->getState('group.id');


Only top voted, non community-wiki answers of a minimum length are eligible