[eluser]kRON[/eluser]
Hey everyone! Just started using CI today and having a blast. There's one thing I'm bugged though and I can't really find it in the user guides.
I want to know how do you hook your custom classes with, let's say, your model classes? To be more specific, I'm trying to make my Twitter model that would cache and parse my twitter feed. Specifically, to make my life easier, I'd like to have the Twitter model return Twit
objects that contain all the data.
I'm not that versed with OOP in PHP, so this is, kinda, how I've imagined everything
Twitter model
Code:
class Twitter extends Model {
// ...
function return_latest() {
for each(...) {
// ...
$result [] = new Twit(...);
}
return $result;
}
}
Twit class
Code:
class Twit {
// ...
function Twit(...) {
$this->...
}
function get_... {
return ...
}
}
Controller
Code:
$this->load->model('Twitter');
// ...
$data['twitters'] = $this->twitter->get_latest();
// ...
View
Code:
<?php foreach ($twitters as $twit): ?>
... <?=$twit->get...();?> ...
<?php endfor; ?>
Can anyone help me explain where and how would I create the Twit class as to make it available for creating objects within the Twitter model? I hope I'm not thinking about doing this the wrong way and that something like this is possible - is there a better practice?