classes.php, the first class, called PersistentObject, takes care of all the database INSERTs and SELECTs so you don't have to worry about them.
Adding a field is as easy as adding it to the database table (album in your case) then adding two classes to classes.php (or class-album.php in the upcoming version...) to get and set the field. Check out the methods like getTitle and getDesc in the Album class to see how to do that.
Thank you for replying so quickly! I've now found a function:
/**
Here I changed the SELECT by including year='2006'.
Is that OK?
Now the insertion:
/**
$col";} else {
// Save the existing object (updates only) based on the existing id.
if (empty($this->updates)) {
return true;
} else {
$sql = "UPDATE " . prefix($this->table) . " SET";
$i = 0;
foreach ($this->updates as $col => $value) {
if ($i > 0) $sql .= ",";
$sql .= " `$col` = '". mysql_escape_string($value) . "'";
$this->data[$col] = $value;
$i++;
}
$sql .= " WHERE id=" . $this->id . ";";
$success = query($sql);
if ($success == false || mysql_affected_rows() != 1) { return false; }
$this->updates = array();
}
}
return true;
}
Where can I put the year='2006' tag? It may be static.
Thanks
Moritz
Geez... much easier to put this in classes.php, like I was saying. You [i]don't need to touch the SQL code,[/i] zenphoto is programmed right, and the database model is [i]good[/i], trust me. What you wrote above won't even work, so don't continue going that direction...
To select/insert based on your "key" you just need to modify [b][i]one line[/i][/b] to the album class:
Find:
$new = parent:ersistentObject('albums', array('folder' => $this->name));
Change to:
$new = parent:ersistentObject('albums', array('folder' => $this->name, 'year' => '2006'));
You're modifying the set of unique keys used to find records in the database. Just add an item to the array defining a new unique key. Note that all the albums you want to select/modify have to have the year as 2006. If you want to pull 'year' from the user and put it in there, it's easy too, just use a $_GET['year'] variable and pass it through the query string...
Look, zenphoto is clean, don't mess it up with SQL hacks, use the elegant (admittedly undocumented) structure already in place ;-)