php yii表中包含空格的列名

php yii表中包含空格的列名,php,sql-server,model,yii,centos,Php,Sql Server,Model,Yii,Centos,我试图从mssql中的一个表中建模一个类。列名有空格,我无法删除空格或以任何方式操纵列名。我不知道如何将此合并到yii中 在admin.php中,我有 <?php print_r($model); $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'components-grid', 'dataProvider'=>$model->search(), 'filter'=

我试图从mssql中的一个表中建模一个类。列名有空格,我无法删除空格或以任何方式操纵列名。我不知道如何将此合并到yii中

在admin.php中,我有

    <?php 
print_r($model);
$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'components-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'No_',
        'Description',
        "Original Asset Number",
        'Flag',
        array(
            'class'=>'CButtonColumn',
        ),
    ),
)); ?>
使用Gii时apache日志中出现错误

[Tue Sep 18 10:51:22 2012] [error] [client 172.16.0.85] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /opt/dam/yii-1.1.12.b600af/framework/db/CDbCommand.php on line 497, referer: http://portal-test/dam/index.php?r=gii/model

列必须以“名称:类型:标签”的格式指定,其中“类型”和“标签”是可选的

您将收到错误,因为空格正在破坏格式

只需在列中添加“Name:”

代码的修改版本:

 $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'components-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'Name:No_',
        'Name:Description',
        "Name:Original Asset Number",
        'Name:Flag',
        array(
            'class'=>'CButtonColumn',
        ),
    ),
)); ?>

现在应该可以了。

您是否尝试过使用Gii自动创建模型?它不起作用,所以我手动创建。ajax一直在运行,没有响应我没有收到任何错误我只是从来没有收到响应。我的表名是xxx Geo Limited\$Fixed Asset
/**
     * Manages all models.
     */
    public function actionAdmin()
    {

        $model=new FixedAsset('search');
        //exit("help2");
        $model->unsetAttributes();  // clear any default values
        if(isset($_GET['FixedAsset']))
            $model->attributes=$_GET['FixedAsset'];

        $this->render('admin',array(
                'model'=>$model,
        ));
    }

    /**
     * Returns the data model based on the primary key given in the GET variable.
     * If the data model is not found, an HTTP exception will be raised.
     * @param integer the ID of the model to be loaded
     */
    public function loadModel($id)
    {
        $model=FixedAsset::model()->findByPk($id);
        if($model===null)
            throw new CHttpException(404,'The requested page does not exist.');
        return $model;
    }
[Tue Sep 18 10:51:22 2012] [error] [client 172.16.0.85] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /opt/dam/yii-1.1.12.b600af/framework/db/CDbCommand.php on line 497, referer: http://portal-test/dam/index.php?r=gii/model
 $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'components-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'Name:No_',
        'Name:Description',
        "Name:Original Asset Number",
        'Name:Flag',
        array(
            'class'=>'CButtonColumn',
        ),
    ),
)); ?>