I tried to use this way, but the result is not complete column name.
class VMaterial extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'v_material';
}
/**
* @inheritdoc$primaryKey
*/
public static function primaryKey()
{
return "id";
}
RESULT :
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'i' in 'where clause' The SQL being executed was: SELECT * FROM
v_material
WHEREi
='8'
There are two ways to fix your problem:
class VMaterial extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'v_material';
}
/**
* @inheritdoc$primaryKey
*/
public static function primaryKey()
{
return ["id"];
}
}
or
class VMaterial extends \yii\db\ActiveRecord
{
public $primaryKey = "id";
/**
* @inheritdoc
*/
public static function tableName()
{
return 'v_material';
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With