Hello everybody,
The example below should demonstrate quite clearly my issue.
Assuming that I have in my DB the following table :
Code:
CREATE TABLE `users` (
`userid` INT NOT NULL,
`username` VARCHAR( 50 ) NOT NULL,
`avatar1` INT, -- ID of the 1st avatar picture or NULL
`avatar2` INT, -- ID of the 2nd avatar picture or NULL
`avatar3` INT -- ... (3 pictures max allowed)
) ;
(I know, this is
not how it should be, but sometimes, reality isn't.)
So I'd like to access my avatar data as an array :
PHP Code:
<?php
// After getting a row
if (count($myRow->avatar) > 0)
$this->view->avatar = new Avatar($myRow->avatar[0]) ;
This is just an example. The abstraction I'd like to create should be far more complicated. The point is : how does one create, access et write trough some abstraction of the real DB ? What are the good practices ? Where am I supposed to write the logic that stands between Model and Controller ?
I already found
those two tutorials, and they seem quite interesting.
I'm looking forward to any other suggestions !
Regards
elvex