Home >Backend Development >PHP Tutorial >yii2 数据库插入操作怎么传入一个数组

yii2 数据库插入操作怎么传入一个数组

WBOY
WBOYOriginal
2016-06-06 20:20:091670browse

怎么才能像tp那样save()后面传入数组就可以插入 跟新了...

<code>$customer = new Customer();
$customer->name = 'Qiang';
$customer->save();</code>

回复内容:

怎么才能像tp那样save()后面传入数组就可以插入 跟新了...

<code>$customer = new Customer();
$customer->name = 'Qiang';
$customer->save();</code>

<code>$customer = new Customer();

$customer->setAttributes(['name' => 'Qiang']);

$customer->save();</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn