Yii Framework Forum: Problem To Create Tables In Mysql - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem To Create Tables In Mysql CDbCommand Failed to prepare the SQL Statement

#1 User is offline   JDAMX 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 08-May 13

Posted 09 May 2013 - 09:18 AM

Hi, I'm new in this forum and in Yii Framework, so I'm following the Jeffrey Winesett's book, so I did like the book said to connect to MySQL and create the tables and everything goes right, but my problem is in my own app. I'm trying to create my first app in Yii, but at the moment of create table I have the next error:

***************************************************************************************************

Apply the above migrations? (yes|no) [no]:yes
*** applying m130508_175146_creacion_tabla_usuarios
> create table tbl_usuarios ...exception 'CDbException' with message 'CDbCom
mand failed to execute the SQL statement: CDbCommand failed to prepare the SQL s
tatement: SQLSTATE[HY000]: General error: 1 near "ENGINE": syntax error. The SQL
statement executed was: CREATE TABLE 'tbl_usuarios' (
"id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
"nombre" varchar(255) NOT NULL,
"correo" varchar(255) NOT NULL,
"password" varchar(255) NOT NULL,
"activo" INT(11) DEFAULT 1,
"idempresa" INT(11) NOT NULL
) ENGINE=InnoDB' in D:\Dropbox\www\EF30\yii\framework\db\CDbCommand.php:357
Stack trace:

********************************************************************************************************

The migration file's code is:

********************************************************************************************************

class m130508_175146_creacion_tabla_usuarios extends CDbMigration
{
public function up()
{
$columns = array(
'id'=>'pk',
'nombre'=>'string NOT NULL',
'correo'=>'string NOT NULL',
'password'=>'string NOT NULL',
'activo'=>'INT(11) DEFAULT 1',
'idempresa'=>'INT(11) NOT NULL',
);
$this->createTable('tbl_usuarios',$columns,'ENGINE=InnoDB');
}

public function down()
{
$this->dropTable('tbl_usuarios');
}

/*
// Use safeUp/safeDown to do migration with transaction
public function safeUp()
{
}

public function safeDown()
{
}
*/
}

*******************************************************************************************************

I hope someone can help me, my time is running and I really want to lear to use Yii Framework,,,,

thanks in advanced
0

#2 User is offline   JDAMX 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 08-May 13

Posted 09 May 2013 - 10:42 AM

Hi All

I'll find the solution, in fact, there was something I did not, you have to configure console.php to work with MySQL, same that you do in main.php file in dp component,,,

Thanks
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users