109 public function __construct($host, $database, $username, $password, $table=
'getid3_cache')
112 if (!function_exists(
'mysql_pconnect')) {
117 $this->connection = mysql_pconnect($host, $username, $password);
118 if (!$this->connection) {
119 throw new DefaultException(
'mysql_pconnect() failed - check permissions and spelling.');
123 if (!mysql_select_db($database, $this->connection)) {
128 $this->table = $table;
135 if ($this->cursor = mysql_query(
"SELECT `value` FROM `".mysql_real_escape_string($this->table).
"` WHERE (`filename` = '".mysql_real_escape_string(
GetId3Core::VERSION).
"') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection)) {
136 list(
$version) = mysql_fetch_array($this->cursor);
142 parent::__construct();
150 $this->cursor = mysql_query(
"DELETE FROM `".mysql_real_escape_string($this->table).
"`", $this->connection);
169 $this->cursor = mysql_query(
"SELECT `value` FROM `".mysql_real_escape_string($this->table).
"` WHERE (`filename` = '".mysql_real_escape_string(
$filename).
"') AND (`filesize` = '".mysql_real_escape_string($filesize).
"') AND (`filetime` = '".mysql_real_escape_string($filetime).
"')", $this->connection);
170 if (mysql_num_rows($this->cursor) > 0) {
172 list(
$result) = mysql_fetch_array($this->cursor);
174 return unserialize(base64_decode(
$result));
183 $this->cursor = mysql_query(
"INSERT INTO `".mysql_real_escape_string($this->table).
"` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('".mysql_real_escape_string(
$filename).
"', '".mysql_real_escape_string($filesize).
"', '".mysql_real_escape_string($filetime).
"', '".mysql_real_escape_string(
time()).
"', '".mysql_real_escape_string(base64_encode(serialize($analysis))).
"')", $this->connection);
196 $this->cursor = mysql_query(
"CREATE TABLE IF NOT EXISTS `".mysql_real_escape_string($this->table).
"` ( 197 `filename` VARCHAR(255) NOT NULL DEFAULT '', 198 `filesize` INT(11) NOT NULL DEFAULT '0', 199 `filetime` INT(11) NOT NULL DEFAULT '0', 200 `analyzetime` INT(11) NOT NULL DEFAULT '0', 201 `value` TEXT NOT NULL, 202 PRIMARY KEY (`filename`,`filesize`,`filetime`)) ENGINE=MyISAM", $this->connection);
203 echo mysql_error($this->connection);
create_table($drop=false)
private: (re)create sql table
GetId3() by James Heinrich info@getid3.org //.
clear_cache()
public: clear cache
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
__construct($host, $database, $username, $password, $table='getid3_cache')
public: constructor - see top of this file for cache type and cache_options
analyze($filename)
public: analyze file