<?php
/**
* @version 2.6.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
jimport('joomla.application.component.model');
// import the Joomla modellist library
jimport('joomla.application.component.modellist');
class KmModelKm extends JModelList {
/**
* Items total
* @var integer
*/
var $_total = null;
/**
* Pagination object
* @var object
*/
var $_pagination = null;
public function getFullSearchListLv1() {
$db = JFactory::getDbo();
$sql1 = "SELECT
cate.id,
cate. NAME,
cate.parent
FROM
tb_k2_categories AS cate
WHERE cate.id != 1
AND cate.id != 2
AND parent = 0
order by ordering ASC
";
$db->setQuery($sql1);
$list1 = $db->loadObjectList();
return $list1;
}
public function getKMSearchList() {
$kw = JRequest::getVar('keyword');
$db = JFactory::getDbo();
$sql = "SELECT
tb_k2_categories.name
, tb_k2_categories.description
, tb_k2_items.title
, tb_k2_items.introtext
FROM tb_k2_items
LEFT JOIN tb_k2_categories ON tb_k2_items.catid = tb_k2_categories.id
WHERE tb_k2_items.title LIKE '%".$kw."%'
OR tb_k2_categories.description LIKE '%".$kw."%'
OR tb_k2_items.introtext LIKE '%".$kw."%'
OR tb_k2_categories.name LIKE '%".$kw."%'
ORDER BY tb_k2_categories.id";
}
}
ปล. function ที่น่าลอง
get_defined_functions() - Returns an array of all defined functions
get_defined_constants() - Returns an associative array with the names of all the constants and their values
<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.tabstate');
if (!JFactory::getUser()->authorise('core.manage', 'com_banners'))
{
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Execute the task.
$controller = JControllerLegacy::getInstance('Banners');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();