PHP: Hypertext Preprocessor (original) (raw)
pg_field_is_null
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
pg_field_is_null — Test if a field is SQL NULL
Description
pg_field_is_null() tests if a field in an PgSql\Result instance is SQL NULL
or not.
Note:
This function used to be called pg_fieldisnull().
Return Values
Returns 1
if the field in the given row is SQL NULL
, 0
if not. [false](reserved.constants.php#constant.false)
is returned if the row is out of range, or upon any other error.
Changelog
Version | Description |
---|---|
8.3.0 | row is now nullable. |
8.1.0 | The result parameter expects an PgSql\Result instance now; previously, a resource was expected. |
Examples
Example #1 pg_field_is_null() example
<?php $dbconn = pg_connect("dbname=publisher") or die ("Could not connect"); <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>r</mi><mi>e</mi><mi>s</mi><mo>=</mo><mi>p</mi><msub><mi>g</mi><mi>q</mi></msub><mi>u</mi><mi>e</mi><mi>r</mi><mi>y</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">res = pg_query(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">res</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord mathnormal">p</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">q</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord mathnormal">u</span><span class="mord mathnormal" style="margin-right:0.03588em;">ery</span><span class="mopen">(</span></span></span></span>dbconn, "select * from authors where author = 'Orwell'"); if ($res) { if (pg_field_is_null($res, 0, "year") == 1) { echo "The value of the field year is null.\n"; } if (pg_field_is_null($res, 0, "year") == 0) { echo "The value of the field year is not null.\n"; } } ?>
Found A Problem?
There are no user contributed notes for this page.