Allow HTML code in JRequest

use html

If you need to get HTML code from JRequest then you need to use special parameter:

JREQUEST_ALLOWHTML

Example (Joomla! 1.6.x-3.x) ↓

$value = JRequest::getVar( 'field_name', '', 'post', 'string', JREQUEST_ALLOWHTML );

Note ↓

      JREQUEST_NOTRIM – prevents trimming of whitespace
      JREQUEST_ALLOWRAW – bypasses filtering
      JREQUEST_ALLOWHTML – allows most HTML. If this is not passed in, HTML is stripped out by default.

Continue reading Allow HTML code in JRequest

How to get last insert id after insert in Joomla database?

Get last id
Joomla solution for get last insert ID after insert a new row in J! database:

$db->insertid();

Example ↓

$query = $db->getQuery(true);
$query->insert('#__test_table');
$query->set('`user_id`='.(int)$uid);
$db->setQuery($query);
$db->query();
$last_id = $db->insertid();

In native PHP ↓
Object oriented style

$last_id = $mysqli->insert_id;

Continue reading How to get last insert id after insert in Joomla database?