Here's my code:
class Photograph extends DatabaseObject {
protected static $table_name="photographs";
protected static $db_fields=array('id', 'filename', 'type', 'size', 'caption','album_id');
public $id;
public $filename;
public $type;
public $size;
public $caption;
//public $album_id;
protected static $album_id;
private $temp_path;
protected $upload_dir="images";
Now, when I use this function below on another page like '$photos = Photograph::find_by_album();'
I get an sql error that says: 'Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=' at line 1'
public static function find_by_album($album_id='')
{
return self::find_by_sql("SELECT * FROM ".self::$table_name."WHERE album_id = ".self::$album_id."");
}
Basically, what I would to happen is to get all values saved in the database from the $table_name where $album_id entered by the user is equivalent to the album_id found in the database. You may find this problem simple, but unfortunately, I am not able to find a solution. Any ideas please? Thanks in advance. :)
EDIT:
Following Mr. Elias Ootegem,
I have modified the code and it now looks like
public static function find_by_album($album_id='')
{ return self::find_by_sql("SELECT * FROM ".self::$table_name." WHERE album_id = ".$album_id."");
}
However, I still get the same error. I tried using this code:
public static function find_by_album()
{ return self::find_by_sql("SELECT * FROM ".self::$table_name." WHERE album_id = ".$album_id."");
}
Now another error comes up which says: Undefined variable: album_id
Any other ideas?
Super::$taticto provide the database if you love static that much).