开发者

(PHP + PDO + Sqlite3) How to check query returned is null?

开发者 https://www.devze.com 2023-03-30 17:21 出处:网络
as shown above may i know is there a way to check a return query is null? which means it contains zero value.

as shown above may i know is there a way to check a return query is null? which means it contains zero value.

I have the following sql query statements:

$result_number_country_malware = $db->query("SELECT sum(download_hits) as total_hits from date1_dcerpc; ");

so how do i check whether $result开发者_Python百科_number_country_malware is null? This is a PDO object, hence i can't use normal operators to check.

thanks for any help in advance!


fetchColumn for SELECT statements, rowCount for UPDATE, DELETE and INSERT statements.


did you try $result_number_country_malware->count() ?

it would be similar to mysql_num_rows($result); if its 0 it is null, that being said..

if($result_number_country_malware->count()){ NOT NULL } else { NULL }

I am not a PDO expert by any means, but i use doctrine and this seems very similar.

0

精彩评论

暂无评论...
验证码 换一张
取 消