[eluser]neverstop[/eluser]
Hello i'm developing a site and choose CI to do it. I'm doing just fine and solved all problems i had except this one. I'll post the error:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Main::$Artigos
Filename: controllers/main.php
Line Number: 13
Fatal error: Call to a member function showArticles() on a non-object in C:\Wamp\www\system\application\controllers\main.php on line 13
My main.php is:
Code:
<?php
class Main extends Controller
{
function Main()
{
parent::Controller();
}
function index()
{
$this->load->library('Artigos');
$val["title"] = "Altus :: Evoluçao em Automaçao";
$val["articles"] = $this->Artigos->showArticles();
$this->load->view('mainview', $val);
}
}
?>
As you can see i created a new library and put it in the /libraries folder. Well it is working fine, at least CI load it with success ...and i'm sure about this because when i change its name i receive an error at the screen as expected.
My library file is:
Code:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Artigos
{
function showArticles()
{
$query = $this->db->query("SELECT * FROM artigos");
$articles = "";
foreach ($query->result() as $row)
{
$articles .= "<p><b>";
$articles .= $row->date . " · ";
$articles .= "<a href=\"#\">" . $row->name . "</a></b><br>";
$content_complete = $row->content;
$content_edited = html_entity_decode(substr($content_complete, 0, 120));
$last_position = strrpos($content_edited, " ");
$articles .= substr($content_edited, 0, $last_position) . " ...</p>";
}
return($articles);
}
function _paginationArticles($num_rows)
{
$this->load->library("pagination");
$config["full_tag_open"] = "<div id=\"article_pagination\">";
$config["full_tag_close"] = "</div>";
$config["total_rows"] = $num_rows;
$config["first_link"] = "Inicial";
$config['last_link'] = "Final";
$config["per_page"] = 10;
$config["num_links"] = 9;
$this->pagination->initialize($config);
return($this->pagination->create_links());
//$pagination = $this->_paginationArticles($query->num_rows());
}
}
?>
I need to configure something on CI? I read the documentation to create my own libraries and everything seems to be correct. Help me please, i don't know what to do now =/