Azure SQL Server;Yii活动记录


Azure SQL Server & Yii Active Record

我在Windows Azure中有一个SQL数据库,在本地机器上有Yii应用程序。我使用PHP 5.4.9和php_pdo_sqlsrv_54_nts.dll驱动程序。

Main.php:

'db'=>array(
        'connectionString' => 'sqlsrv:Server=tcp:MYSERVER.database.windows.net,1433;Database=MYDB;',
        'username' => 'admin',
        'password' => 'pass',
        'charset' => 'utf8',
    ),

当我尝试连接到SQL Server时,Yii抛出以下异常:

CDbCommand failed to execute the SQL statement: SQLSTATE[42S02]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'sys.extended_properties'.. The SQL statement executed was: SELECT t1.*, columnproperty(object_id(t1.table_schema+'.'+t1.table_name), t1.column_name, 'IsIdentity') AS IsIdentity, CONVERT(VARCHAR, t2.value) AS Comment FROM [INFORMATION_SCHEMA].[COLUMNS] AS t1 LEFT OUTER JOIN sys.extended_properties AS t2 ON t1.ORDINAL_POSITION = t2.minor_id AND object_name(t2.major_id) = t1.TABLE_NAME AND t2.class=1 AND t2.class_desc='OBJECT_OR_COLUMN' AND t2.name='MS_Description' WHERE t1.TABLE_NAME='users' AND t1.TABLE_SCHEMA='dbo'

它以Gii形式显示,或以简单的<?php echo User::model()->findAllByPk(1)->email;?>字符串显示在页面上。

我做错了什么?

UPD:User.php

class User extends CActiveRecord {
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }
    public function tableName()
    {
        return 'users';
    }
    public function rules()
    {
        return array(
            array('email, password', 'required')
        );
    }
    public function attributeLabels()
    {
        return array(
            'id' => 'ID',
            'email' => 'Email'
        );
    }
}

users仅包含idemailpassword字段。

这个代码有效!

$connection=Yii::app()->db;
$sql = "INSERT INTO users (email, password) VALUES ('regs@kamenskynik.name', 'example')";
$command=$connection->createCommand($sql);
$some = $command->execute();

如何将SQLSRV与Yii活动记录一起使用?

问题出现在https://github.com/yiisoft/yii/blob/master/framework/db/schema/mssql/CMssqlSchema.php#L294.

我应该为这个应用程序编写自己的方案。