无法添加/更新用户(虽然可以列出并删除它们)

I did

yiic shell "/path/to/my/app"

model *

crud users

I cannot add or update users. I can list them, and delete them. Also I thought I was supposed to see the primary keys.

CREATE TABLE IF NOT EXISTS `users` (
  `user_id` int(11) NOT NULL auto_increment,
  `user_username` varchar(25) collate latin1_general_ci NOT NULL,
  `user_username_clean` varchar(25) collate latin1_general_ci NOT NULL,
  `user_password` varchar(64) collate latin1_general_ci NOT NULL,
  `user_register_time` int(11) NOT NULL,
  `user_code` varchar(15) collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`user_id`)
) ENGINE=InnoDB;

Probable reason could be DB username/password which you have provided in config/main.php doesn't have access to modify database. Just making a guess, post more details about the issue to better understand it.

It looks like the suggestion about database permissions above was the answer, but just a friendly note: the newer versions of Yii have a new visual (GUI) CRUD generator called "Gii". Check out the instructions here, it's much nicer than yiic and may solve some problems creating CRUD code:

http://www.yiiframework.com/doc/guide/quickstart.first-app#generating-crud-code

Patch to enable non-integer primary keys

--- yii-1.1.5.r2654/framework/cli/views/webapp/protected/config/main.php    2010-11-14 20:35:42.000000000 +0000
+++ yii-1.1.5.r2654/framework/cli/views/webapp/protected/config/main.php    2010-12-09 16:59:01.783001000 +0000
@@ -42,4 +42,5 @@
                '/'=>'/view',
                '//'=>'/',
+               '//'=>'/',
                '/'=>'/',
            ),

--- yii-1.1.5.r2654/framework/gii/generators/crud/templates/default/controller.php  2010-11-14 20:35:45.000000000 +0000
+++ yii-1.1.5.r2654/framework/gii/generators/crud/templates/default/controller.php  2010-12-09 16:47:54.053001002 +0000
@@ -163,5 +163,5 @@
    public function loadModel($id)
    {
-       $model=modelClass; ?>::model()->findByPk((int)$id);
+       $model=modelClass; ?>::model()->findByPk($id);
        if($model===null)
            throw new CHttpException(404,'The requested page does not exist.');

--- yii-1.1.5.r2654/framework/gii/GiiModule.php 2010-11-14 20:35:45.000000000 +0000
+++ yii-1.1.5.r2654/framework/gii/GiiModule.php 2010-12-09 16:49:22.183001002 +0000
@@ -53,4 +53,5 @@
  *             'gii/'=>'gii/',
  *             'gii//'=>'gii//',
+ *             '//'=>'/',
  *             ...other rules...
  *         ),

The problem is while generating function loadModel in appController.php

The generator creates the function loadModel like this:

public function loadModel($id)
{
    $model=App::model()->findByPk((int)$id);   //  <- Error Line 
    if($model===null)
        throw new CHttpException(404,'The requested page does not exist.');
    return $model;
}

And the correct loadModel function is as follows:

public function loadModel($id)
{
    $model=App::model()->findByPk($id);   //  <- Fixed Line
    if($model===null)
        throw new CHttpException(404,'The requested page does not exist.');
    return $model;
}

I hope to have helped better understand the problem and correct them in the package without touching the Original of the generator, as it should appear in YII updates own correction.