i’m a portuguese student and i’m trying to implement a web application for game’s management.
structure for table game
game
(
idGame
int(11) NOT NULL AUTO_INCREMENT,
name
varchar(75) NOT NULL,
primaryScreen
blob NOT NULL,
game_content
blob NOT NULL,
category
varchar(45) NOT NULL,
platform
varchar(45) NOT NULL,
device
varchar(45) NOT NULL,
description
varchar(250) NOT NULL,
funcionalities
varchar(150) NOT NULL,
PRIMARY KEY (idGame
)
)
screen
(
idScreen
int(11) NOT NULL AUTO_INCREMENT,
id_Game
int(11) NOT NULL,
image
longblob NOT NULL,
PRIMARY KEY (idScreen
),
KEY id_Game
(id_Game
)
)
i have read a yii tutorial of how to upload a file to a bolb in a database http://www.yiiframework.com/wiki/95/saving-files-to-a-blob-field-in-the-database
the only diference is that in the function before save i only want to keep the content of file (can i do this or do i have to keep file name, file extension…) so i do like this in model:
public function beforeSave()
{
if($file=CUploadedFile::getInstance($this,‘game_uploaded’))
{
// $this->file_name=$file->name;
//$this->file_type=$file->type;
//$this->file_size=$file->size;
$this->game_content=file_get_contents($file->tempName);
//$file->saveAs(‘path/to/uploads’);
}
if($file=CUploadedFile::getInstance($this,‘primscreen’))
{
//$this->file_name=$file->name;
//$this->file_type=$file->type;
//$this->file_size=$file->size;
$this->primaryScreen=file_get_contents($file->tempName);
//$file->saveAs(‘path/to/uploads’);
}
return parent::beforeSave();
}
but when i try i have this error:
PDOStatement::execute(): MySQL server has gone away
could someone help me please? i appreciate any sugestion. thanks