Hi to all!
It’s first post for me,
sorry if something is wrong.
Background:
i’m trying to create a ticketing system,
the idea is to create a table per ticket( if this idea is feel free to suggest a different solution).
I have a "ticket main table" that holds the creation time and the id of the user who created the ticket.
The "ticket main table" is managed with a model "Ticket" and basic crud actions work fine.
Problem:
the idea was to create a table ticket_id.$model->id when actionCreate() inside the controller(TicketController) is executed.
$command = Yii::app()->db->createCommand("CREATE TABLE ticket_id_".$model->id." (id INT AUTO_INCREMENT PRIMARY KEY)");
$command->queryAll()
CDbException:
CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error. The SQL statement executed was: CREATE TABLE ticket_id_37 (id INT AUTO_INCREMENT PRIMARY KEY)
Even if it says that the command has failed, the table is created.
I’ve noticed that commenting out the lines:
[indent]541 throw new CDbException(Yii::t(‘yii’,‘CDbCommand failed to execute the SQL statement: {error}’,
542 array(’{error}’=>$message)),(int)$e->getCode(),$errorInfo);[/indent]
in framework/db/CDbCommand.php
"solves" the issue…
I’m using a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=ticketing',
'emulatePrepare' => true,
'username' => 'user',
'password' => 'mypassword',
'charset' => 'utf8',
'tablePrefix'=>'tbl_ticketing_',
),
Server:
MySQL Server version: 5.1.67-0ubuntu0.11.10.1 (Ubuntu)
PHP version: 5.3.6-13 ubuntu 3.9
Yii: yii-1.1.13
Thank you all for any suggestions/help.