本文概述
- 更新行
- 删除行
// Inserting data with a raw SQL statement$sql= 'INSERT INTO 'company'('name', 'year') VALUES ('srcmini', 2010)';
$success = $connection->
execute($sql);
// With placeholders$sql= 'INSERT INTO 'company'('name', 'year') VALUES (?, ?)';
$success = $connection->
execute($sql, ['javatoint', 2010, ]);
// Generating dynamically the necessary SQL$success = $connection->
insert('company', ['srcmini', 2010, ], ['name', 'year', ], );
【Phalcon数据库操作(插入/更新/删除行)】输出
文章图片
更新行
// Updating data with a raw SQL statement$sql= 'UPDATE 'company' SET 'name' = 'srcmini' WHERE 'id' = 101';
$success = $connection->
execute($sql);
// With placeholders$sql= 'UPDATE 'company' SET 'name' = ? WHERE 'id' = ?';
$success = $connection->
execute($sql, ['srcmini', 101, ]);
// Generating dynamically the necessary SQL (another syntax)$success = $connection->
updateAsDict('company', ['name' =>
'New srcmini', ], 'id = 101' // Warning! In this case values are not escaped);
输出
文章图片
删除行
// Deleting data with a raw SQL statement$sql= 'DELETE 'company' WHERE 'id' = 101';
$success = $connection->
execute($sql);
// With placeholders$sql= 'DELETE 'company' WHERE 'id' = ?';
$success = $connection->
execute($sql, [101]);
// Generating dynamically the necessary SQL$success = $connection->
delete('company', 'id = ?', [101, ]);
推荐阅读
- Phalcon图片
- Phalcon第一个例子
- Phalcon表单用法例子
- Phalcon Cookie管理
- 跨站请求伪造(CSRF)保护
- Phalcon连接到数据库
- Phalcon配置详解
- Perl While循环
- Android测试(Espresso 自动化测试)