I want to call a function from model inside controller
my model : httpdocs/components/com_storemanager/models/searchmanager.php
<?php
/**
* @version CVS: 1.0.2
* @package Com_storemanager
* @author LYT
* @copyright 2017 LYT
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
jimport('joomla.application.component.modellist');
/**
* Methods supporting a list of storemanager records.
*
* @since 1.6
*/
class storemanagerModelSearchmanager extends JModelItem
{
function __construct() {
parent::__construct ();
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*
*/
public function managerList($name)
{
$db = JFactory::getDBO();
$query = $db->getQuery(true)
->select($db->qn("title"))
->from($db->qn("jos_storemanager_manager"))
->where($db->quoteName('manager') . ' LIKE '. $db->quote('\''.$name.'.%\''));
return $db->setQuery($query)->loadObjectList();
}
}
I did try this inside my controller : /httpdocs/components/com_storemanager/controller.php
function searchmanager()
{
$jinput = JFactory::getApplication()->input;
$name = $jinput->get('name');
$managers = $this->getModel( 'Searchmanager' , 'Model' )->managerList($name);
foreach($managers as $manager)
{
echo '<br><h3>'.$manger->title . '</h3>';
}
exit;
}
but no result;
I tried all solutions
require_once JPATH_COMPONENT_SITE.'/models/searchmanager.php';
$tags_model = JModelLegacy::getInstance( 'Searchmanager', 'searchmanager' );
$tags_model->managerList($name);
Not working
$model = $this->getModel() ;
$articles = $model->managerList($name);
This one too not working
->where("LOCATE(" . $db->q($name) . ", manager) = 1");
To help you debug, use theenqueueMessage()
lines from joomla.stackexchange.com/a/24161/12352jos_
with#__
.