Answer the question
In order to leave comments, you need to log in
How to select an ActiveRecord object if the class has its own arguments in Yii2?
There is a class
/**
* В таблице есть только одно поле - id
* @property integer $id
*/
class Spider extends ActiveRecord
{
private $name; // это дополнительный аргумент, которого нет в таблице
public function __construct($name = null)
{
$this->name = $name;
}
}
// Не удалится, так как $spider не является объектом ActiveRecord
// Там есть добавленный аргумент $name;
$spider->delete();
Answer the question
In order to leave comments, you need to log in
How is it not? Quite is, if you correctly solved the issue with namespace.
The only question is that delete only acts on existing records in the database, that is, in fact, it executes the DELETE FROM `table` WHERE `id`=:id query.
But since this is isNewRecord, there is nothing to delete there.
You need to explain the task in more detail - what do you store in this table and object and what are you going to delete?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question