Yii Framework Forum: crud problem in unix/linux type system - Yii Framework Forum

Jump to content

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

crud problem in unix/linux type system Rate Topic: -----

#1 User is offline   miu060502 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 29-December 08

Posted 29 December 2008 - 02:25 AM

followed the instructions of your tutorial about creating the first webapp, I found out there is no problem creating crud page on win platform but not on unix/linux platform . it always alerts "no primary key".
my setting inside config/main.php about db is
'db'=>array(
'username' => 'XXXX',
'password' => 'YYYYY',
'autoConnect' => true,
'persistent' => true,
'connectionString'=>'mysql:host=localhost;dbname=test;',
),
tested under XP is ok but no for both freebsd and ubuntu

0

#2 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 29 December 2008 - 02:35 AM

Should it be:
'db'=>array(
        'class'=>'CDbConnection',
        'username' => 'XXXX',
        'password' => 'YYYYY',
        'autoConnect' => true,
        'persistent' => true,
        'connectionString'=>'mysql:host=localhost;dbname=test;',
      ),

?
0

#3 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,871
  • Joined: 04-October 08
  • Location:DC, USA

Posted 29 December 2008 - 07:08 AM

What is version of MySQL on your linux? What is the execution result of the SQL "SHOW CREATE TABLE tableName" ?
0

#4 User is offline   miu060502 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 29-December 08

Posted 29 December 2008 - 01:58 PM

mysql 5.1.X.X  I forgot and newly installed into ubuntu server inside vmplayer
php 5.2.X 
show create table result:

CREATE TABLE `user` (
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(128) NOT NULL,
  `password` varchar(128) NOT NULL,
  `email` varchar(128) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

Followed jonah to add a line ,
        'class'=>'CDbConnection',
error still occurs.
0

#5 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,871
  • Joined: 04-October 08
  • Location:DC, USA

Posted 29 December 2008 - 02:01 PM

Oh, sorry, I should ask what is the output of executing SQL "SHOW COLUMNS FROM tableName" ?
0

#6 User is offline   miu060502 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 29-December 08

Posted 29 December 2008 - 02:08 PM

I have restart a new folder to redo the tutorial again but errors still occurs.  here is the log:
Stack trace:
#0 /var/www/yii/framework/db/CDbCommand.php(231): CDbCommand->queryInternal('fetch', 2)
#1 /var/www/yii/framework/db/schema/mysql/CMysqlSchema.php(165): CDbCommand->queryRow()
#2 /var/www/yii/framework/db/schema/mysql/CMysqlSchema.php(68): CMysqlSchema->findConstraints(Object(CMysqlTableSchema))
#3 /var/www/yii/framework/db/schema/CDbSchema.php(72): CMysqlSchema->createTable('user')
#4 /var/www/yii/framework/cli/commands/shell/ModelCommand.php(95): CDbSchema->getTable('user')
#5 [internal function]: ModelCommand->generateModel('/var/www/yii/fr...', Array)
#6 /var/www/yii/framework/console/CConsoleCommand.php(116): call_user_func(Array, '/var/www/yii/fr...', Array)
#7 /var/www/yii/framework/cli/commands/shell/ModelCommand.php(72): CConsoleCommand->copyFiles(Array)
#8 /var/www/yii/framework/cli/commands/ShellCommand.php(98): ModelCommand->run(Array)
#9 /var/www/yii/framework/cli/commands/ShellCommand.php(78): ShellCommand->runShell()
#10 /var/www/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run(Array)
#11 /var/www/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)
#12 /var/www/yii/framework/base/CApplication.php(146): CConsoleApplication->processRequest()
#13 /var/www/yii/framework/yiic.php(30): CApplication->run()
#14 /var/www/yii/framework/yiic(15): require_once('/var/www/yii/fr...')

and my phpinfo() shows
PDO
PDO support enabled
PDO drivers mysql

pdo_mysql
PDO Driver for MySQL, client library version 5.0.67

I doubt that the  driver doesnt support  the CActiveRecord
0

#7 User is offline   miu060502 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 29-December 08

Posted 29 December 2008 - 02:10 PM

missing log:


exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2030 This command is not supported in the prepared statement protocol yet' in /var/www/yii/framework/db/CDbCommand.php:284

0

#8 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,871
  • Joined: 04-October 08
  • Location:DC, USA

Posted 29 December 2008 - 02:17 PM

So what is the output of "SHOW COLUMNS FROM tableName" ?

Also, check this: http://www.yiiframew...#emulatePrepare

You may need to set this property to be true. This is related with PDO, not AR.
0

#9 User is offline   miu060502 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 29-December 08

Posted 29 December 2008 - 06:52 PM

thx for your help. it works now.

'db'=>array(
        'class'=>'CDbConnection',
        'emulatePrepare' => true,
        'username' => 'XXXX',
        'password' => 'YYYYY',
        'autoConnect' => true,
        'persistent' => true,
        'connectionString'=>'mysql:host=localhost;dbname=test;',
      ),
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