What does it mean to use “:” before a variable ?
For example, :userId in this code:
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));
}
This is PHP,MySQL code in Yii framework.
The colon is a common character that indicates a placeholder for a variable value in a SQL statement. In this case, the those placeholders are getting replaced by the value of
userIdandproject_idat runtime. This is great for avoiding SQL injection vulnerabilities.