原生操作
$sql = "select * from b2b2c_shop where mobile=18812101090";
$a= $this->getReadConnection()->fetchAll($sql);
$sql = 'update ' . $this->getSource() . ' set field_status = 1 where shop_id = ' . $_SESSION['shop_id'] .' and field_id = '.$v;
$this->getReadConnection()->execute($sql);
#原生
// 使用原始SQL语句插入数据
$sql = 'INSERT INTO `robots`(`name`, `year`) VALUES ('Astro Boy', 1952)';
$success = $connection->execute($sql);
// 占位符
$sql = 'INSERT INTO `robots`(`name`, `year`) VALUES (?, ?)';
$success = $connection->execute(
$sql,
[
'Astro Boy',
1952,
]
);
// 动态生成必要的SQL
$success = $connection->insert(
'robots',
[
'Astro Boy',
1952,
],
[
'name',
'year',
],
);
// 动态生成必要的SQL(另一种语法)
$success = $connection->insertAsDict(
'robots',
[
'name' => 'Astro Boy',
'year' => 1952,
]
);
// 使用原始SQL语句更新数据
$sql = 'UPDATE `robots` SET `name` = 'Astro boy' WHERE `id` = 101';
$success = $connection->execute($sql);
// 占位符
$sql = 'UPDATE `robots` SET `name` = ? WHERE `id` = ?';
$success = $connection->execute(
$sql,
[
'Astro Boy',
101,
]
);
// 动态生成必要的SQL
$success = $connection->update(
'robots',
[
'name',
],
[
'New Astro Boy',
],
'id = 101' // 警告!在这种情况下,值不会被转义
);
// 动态生成必要的SQL(另一种语