Sử dụng ":" trước biến là gì?Dấu hai chấm trước một chữ trong câu lệnh SQL có ý nghĩa gì?
Ví dụ, :userId
trong mã này:
public function removeUser($userId)
{
$command = Yii::app()->db->createCommand();
$command->delete(
'tbl_project_user_assignment',
'user_id=:userId AND project_id=:projectId',
array(':userId'=>$userId,':projectId'=>$this->id));
}
Đây là PHP, mã MySQL trong khuôn khổ Yii.
Nó biểu thị biến liên kết cho các câu lệnh đã chuẩn bị. – datasage
Cảm ơn bạn. Câu trả lời của bạn đã giúp. –