Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

SQL 'select' query where parameter is NULL

$
0
0
Hi,

is it possible to run a SELECT query where the parameter is NULL?
I am trying the following but it does not work for me:
$connection=Yii::app()->db;
		
$sql = "SELECT id, categoryName FROM categories WHERE parentId=:parentId";
		
$command=$connection->createCommand($sql);

$parentId = NULL;		

$command->bindParam(":parentId",$parentId,PDO::PARAM_INT);
		
print_r($command->queryAll());



I also tried the following without any luck:
$command->bindParam(":parentId",$parentId,PDO::PARAM_NULL);

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>