如果rowcount为零,则为pdo

I want to run a python script if the dans_code doesn't exist. i use the following code for this:

$dbh = new PDO("pgsql:host=localhost;dbname=import", $user, $pass);
$stmt = $dbh->prepare("SELECT dans_code from import where dans_code = ':code'");
$stmt->bindParam(':code', $dans);
$stmt->execute();

if($stmt->rowCount() == 0)
{
exec("C:\\Python34\\python.exe code.py $dans");
}

but when i run the script also the variables that exist in my database trigger the if statement. How is this possible? i m using a postgresdatabase I have this code from this question

Thanks

Wrap off quotes form your placeholder just use

$stmt = $dbh->prepare("SELECT dans_code from import where dans_code = :code");

Other wise your where become where dans_code='".'$dane'."' and you always get 0 result