This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/includes/jpgraph/docs/chunkhtml/ch13s04.html

36 lines
3.4 KiB
HTML
Raw Normal View History

2011-05-28 09:51:52 +00:00
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Reading data from a database</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch13.html" title="Chapter 13. Getting hold of the data to be displayed"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Reading data from a database</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 13. Getting hold of the data to be displayed</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Reading data from a database"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2538964"></a>Reading data from a database</h2></div></div></div>
<p>Since there are so many databases and so many ways to organize data in tables it
is impossible to give generic examples. Instead we point out some common pitfalls
when gathering data from a database.</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p>Make sure the data is valid numeric data. It is a common mistake to
read <code class="code">NULL</code> (or empty strings "") values and try to plot
them. Beware that the PHP function <code class="code">empty()</code> also will return
true for 0 and "0" values so it is not enough to just test with
<code class="code">empty()</code> since this will also remove all values that
happens to be valid 0 values. To avoid this use the following modified
empty method.</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">function empty0($aValue){
if ( !is_numeric(trim($aValue)) )
return empty($aValue);
return false;
}</span></pre></td></tr></table></div><p>
</p>
</li><li class="listitem">
<p>Some databases (e.g. MySQL) returns a column with decimal type values
as string in a SELECT statement which normally is handled by automatic
conversion in PHP but since PHP has different interpretation of "0.00"
and 0.00 in respect to what is interpreted as empty or not this needs to
be carefully handled.</p>
</li></ul></div><p>
</p>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="ch13.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>