public function rules()
{
return array(
array('name','uniqueIdAndName',),
);
}
public function uniqueIdAndName($attribute,$params=array())
{
if(!$this->hasErrors())
{
$params['criteria']=array(
'condition'=>'id=:id',
'params'=>array(':id'=>$this->id),
);
$validator=CValidator::createValidator('unique',$this,$attribute,$params);
$validator->validate($this,array($attribute));
}
}
//получить друзей
$resp = $VK->api('friends.get', array('uid'=>'150317299'));
> create table {{%account}} ...Exception 'yii\db\Exception' with message 'SQ LSTATE[42S01]: Base table or view already exists: 1050 Table 'account' already e xists
The SQL being executed was: CREATE TABLE `account` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` int(11),
`provider` varchar(255) NOT NULL,
`client_id` varchar(255) NOT NULL,
`properties` text
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'
in /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/db/Schema.php:595
Error Info:
Array
(
[0] => 42S01
[1] => 1050
[2] => Table 'account' already exists
)
Stack trace:
#0 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/db/Command.php(779): yii\db\S chema->convertException(Object(PDOException), 'CREATE TABLE `a...')
#1 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/db/Migration.php(248): yii\db \Command->execute()
#2 /var/www/admin/www/mpro.com/vendor/dektrium/yii2-user/migrations/m140403_1740 25_create_account_table.php(28): yii\db\Migration->createTable('{{%account}}', A rray, 'CHARACTER SET u...')
#3 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/console/controllers/BaseMigra teController.php(492): m140403_174025_create_account_table->up()
#4 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/console/controllers/BaseMigra teController.php(129): yii\console\controllers\BaseMigrateController->migrateUp( 'm140403_174025_...')
#5 [internal function]: yii\console\controllers\BaseMigrateController->actionUp( 0)
#6 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/base/InlineAction.php(55): ca ll_user_func_array(Array, Array)
#7 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/base/Controller.php(151): yii \base\InlineAction->runWithParams(Array)
#8 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/console/Controller.php(91): y ii\base\Controller->runAction('up', Array)
#9 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/base/Module.php(455): yii\con sole\Controller->runAction('up', Array)
#10 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/console/Application.php(161) : yii\base\Module->runAction('migrate/up', Array)
#11 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/console/Application.php(137) : yii\console\Application->runAction('migrate/up', Array)
#12 /var/www/admin/www/mpro.com/vendor/yiisoft/yii2/base/Application.php(375): y ii\console\Application->handleRequest(Object(yii\console\Request))
#13 /var/www/admin/www/mpro.com/yii(23): yii\base\Application->run()
#14 {main}