[eluser]neverstop[/eluser]
Now i'm not understanding anything =/.
Doesn't CI create its own constructor when i instanciate a class without one? As java does? O read the documentation of how create my own library and there's no constructor on the examples.
Well i still fighting here to understand the CI and changed my code and it worked! Take a look:
Code:
<?php
class Main extends Controller
{
function __construct()
{
parent::Controller();
}
function index()
{
$this->load->library("Artigos");
$val["title"] = "Altus :: Evoluçao em Automaçao";
$val["articles"] = Artigos::showArticles();
$this->load->view("mainview", $val);
}
}
?>
and
Code:
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);
}
Now my BIG question, my class Artigos doesn't need to extend another class right? I dont need to create a constructor to my class but i could if necessary right?
In my code above i called the funcion showArticles() as a static function ok? I know it worked but i'm confuse...because the documentation explain in a different way =/