i have information sent client server in following format:
{ identifier: { value: null, public: false } } obviously value isn't null, there times when needs be, when sending on php saves "null" string during json_decode phase. when trying insert null values sql database, instead of null "null" causing strange things happen on client. (ie: displaying "null" instead of nothing).
obviously check on client "null" see no reason continuously spend additional bytes of data send text "null" client.
example:
$identifier = $json_array['identifier']; $statement = $connection->prepare("update table set v1 = :val, p1 = :pub"); $statement->bindparam(":val", $identifier['value']); $statement->bindparam(":pub", $identifier['public']); $statement->execute(); where v1 varchar value
always verify ideas.
it saves "null" string during json_decode phase.
wrong.
$json = '{ "identifier": { "value": null, "public": false } }'; $obj = json_decode($json); var_dump($obj); clearly says value null.
which, in turn, gets inserted right in mysql using php array , pdo prepared statement.
Comments
Post a Comment