sql - PHP PDO fetch null -


How do you check that the column value is zero or not? Example code:

  $ db = DBCxn :: getCxn (); $ Sql ​​= "Choose exercise_id, author_id, submissions, result, submission_time, subliations, total_ratings_over the left over submissions submit submissions.exercise_id = submission_ratings.exercise_id WHERE id =: id"; $ St = $ db- & gt; Ready ($ sql); $ St-> gt; BindParam (": id", $ this-> ID, PDO :: PARAM_INT); $ St- & gt; Executed (); $ Line = $ st- & gt; get receive (); $ This- & gt; Total_reiting_wot = $ line ['total_reiting_wot']; If ($ this-> total_rating_votes == null) // It does not seem to work, even if there is no record in the submission ???? {...}  

When you are connected to the database,

PDO :: setAttribute (PDO :: ATTR_ORACLE_NULLS, $ option)

Where $ option is one of the one, to control that PDO faucet and How to handle empty strings PDO :: NULL_NATURAL: No conversion.

  • PDO :: NULL_EMPTY_STRING: The empty string has been converted into a tap.
  • PDO :: NULL_TO_STRING: NULL is converted to empty string.

  • Comments