Answer the question
In order to leave comments, you need to log in
How to resolve Call to a member function result() error?
Hello, friends!
A friend asked me to look at the site, they say everything was fine and suddenly an error.
Fatal error: Call to a member function result() on boolean in /web/htdocs/www.site.com/home/system/application/models/auth_model.php on line 511
Here is the error line $result = $query->result();
Here is the function
function initialization_Acl()
{
ini_set("include_path",APPPATH."libraries/");
//Подклучаем зендовский загрузчик
require_once "Zend/Loader.php";
$CI =& get_instance();
$CI->db->query('SET NAMES utf8');
//Загружаем необходимые нам библиотеки ( контроль доступа, роли, ресурсы )
Zend_Loader::loadClass('Zend_Acl');
Zend_Loader::loadClass('Zend_Acl_Role');
Zend_Loader::loadClass('Zend_Acl_Resource');
//Создаём новый объект контроля доступа
$acl = new Zend_Acl();
// определяем роли
$query = $CI->db->query('SELECT * FROM `groups`');
//print_r($query);
//print "<br> --- ".$query->num_rows();
$result = $query->result();
if (is_array($result))
{
foreach ($result as $val)
{
// var_dump($val);
$acl->addRole(new Zend_Acl_Role($val->id));
$acl->deny($val->id, null);
}
}
//определяем ресурс
$query = $CI->db->query("SELECT * FROM `map` WHERE upId!=0 AND resource!=''");
//print_r($query);
$result = $query->result();
if (is_array($result))
{
foreach ($result as $val)
{
//print"<br><br> ----- ".($val->resource);
$acl->add(new Zend_Acl_Resource($val->resource));
// echo 'T: ',$val->template,"<br>";
}
}
// запрещяем какие либо действия с profile для guest'а и member'а
// $acl->deny('guest','main');
// $acl->deny('member','main');
// даем полный доступ admin'у для ресурса profile
$query = $CI->db->query("SELECT * FROM `acl`");
//print "<br> ----- ";
//print_r($query);
$result = $query->result();
if (is_array($result))
{
foreach ($result as $val)
{
// var_dump($val);
try
{
if ($val->action != '')
{
$acl->allow($val->group, $val->resource, $val->action);
// echo $val->group,'/',$val->resource,$val->action;
}
else
{
$acl->allow($val->group, $val->resource);
// echo $val->group,'/',$val->resource,'/',$val->action,"<br>";
}
}
catch(Exception $e)
{
// echo 'EX: ',$val->group,'/',$val->resource,'/',$val->action,"<br>";
}
}
}
// разрешаем member'у доступ для ресурса profile на действия index и modify
// $acl->allow('member' , 'main' , array('index','modify'));
return $acl;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question