Thanks for your suggestion.
There's particularly a point that is making me crazy and that's about how a new Photo should be created:
I need a method to get all the user photo. I put that method in the user class (is this correct??):
function getPhotos(){
SELECT * from userphoto where idUser = ...
//at this point, I have to build the object photo, but how?
while ($res = $result->fetch_array()){
//here I can get the IDPhoto, since i retrieve it from the DB (the link (url) to the foto is in the DB and the file has uploaded)
$photo = new Photo ($res['IDPhoto'] $res[url], $res['caption'])
//
}
IDPhoto is a primary key in the userphoto table
if upload is a method of the Photo class, how can I use it, since there can't be a Photo yet?
By using upload as a static method?
BUT, for example, when a user, uploads a photo (if the upload has success) the photo can't have a IDPhoto,
because it gets (or should get) that ID ONLY after a successful update AND after an INSERT into a DB.
So, a constructor like this:
new Photo ($IDPhoto,$url, $caption)
in the case of an upload does not work, I think.
It is this that is making me crazy...