Привет, создал модель...с помощью генератора.
Не получается получить данные.
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "{{%users}}".
*
* @property integer $id
* @property string $login
* @property string $password
* @property string $last_login
* @property string $name
* @property string $lastname
* @property integer $vk_id
* @property string $datereg
* @property string $sex
* @property string $status
* @property string $birthday
* @property string $crop
* @property integer $isactive
* @property string $activation_code
*/
class Users extends \yii\db\ActiveRecord
{
private $user;
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Comments the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%users}}';
}
/**
* @return array primary key of the table
**/
public static function primaryKey()
{
return array('id');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['login', 'password', 'name', 'lastname', 'status', 'birthday', 'crop', 'isactive', 'activation_code'], 'required'],
[['last_login', 'datereg', 'birthday'], 'safe'],
[['vk_id', 'isactive'], 'integer'],
[['sex', 'status', 'crop', 'activation_code'], 'string'],
[['login', 'password'], 'string', 'max' => 40],
[['name', 'lastname'], 'string', 'max' => 15]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'login' => 'Login',
'password' => 'Password',
'last_login' => 'Last Login',
'name' => 'Name',
'lastname' => 'Lastname',
'vk_id' => 'Vk ID',
'datereg' => 'Datereg',
'sex' => 'Sex',
'status' => 'Status',
'birthday' => 'Birthday',
'crop' => 'Crop',
'isactive' => 'Isactive',
'activation_code' => 'Activation Code',
];
}
public static function findByUsername($username)
{
$this->user = Users::find()->where(['name' => $username])->one();
var_dump($this->user);
}
}