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

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

WBOY
Release: 2016-06-06 20:20:09
Original
1669 people have browsed it

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

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

回复内容:

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

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

<code>$customer = new Customer();

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

$customer->save();</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template