Location: PHPKode > projects > phpBugTracker > docs/html/dependencies.html
<HTML
><HEAD
><TITLE
>Dependencies</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.72
"><LINK
REL="HOME"
TITLE="phpBugTracker"
HREF="index.html"><LINK
REL="UP"
TITLE="Developer's Guide"
HREF="devguide.html"><LINK
REL="PREVIOUS"
TITLE="Developer's Guide"
HREF="devguide.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="docs.css"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#800080"
ALINK="#FF0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>phpBugTracker</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="devguide.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 3. Developer's Guide</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
>&nbsp;</TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="DEPENDENCIES"
>3.2. Dependencies</A
></H1
><BLOCKQUOTE
CLASS="ABSTRACT"
><DIV
CLASS="ABSTRACT"
><A
NAME="AEN232"
></A
><P
>phpBugTracker requires one external package, PHPlib, and can optionally use JpGraph.  Of course a web server and a database are also necessary.</P
></DIV
></BLOCKQUOTE
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="DEP-PHPLIB"
>3.2.1. PHPlib</A
></H2
><P
>PHPlib can be found at <A
HREF="http://phplib.sourceforge.net/"
TARGET="_top"
>http://phplib.sourceforge.net</A
>.  It provides the database abstraction layer, html templates, and session and authentication management.</P
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN238"
>3.2.1.1. Database Abstraction</A
></H3
><P
>Instead of using PHP's database functions directly, interactions are done via database objects, which extend PHPlib's <TT
CLASS="CLASSNAME"
>DB_Sql</TT
> class.</P
><P
>The global variable <TT
CLASS="VARNAME"
>$q</TT
> is available as an instance of the class <TT
CLASS="CLASSNAME"
>dbclass</TT
>.  This class adds two functions to the <TT
CLASS="CLASSNAME"
>DB_Sql</TT
> class, <TT
CLASS="FUNCTION"
>grab()</TT
> and <TT
CLASS="FUNCTION"
>grab_field()</TT
>.  If they are called with an argument, the argument is passed as a query to the database and the results are returned from that query.  If no argument is passed, they return results from the previous call to <TT
CLASS="FUNCTION"
>query()</TT
>.  Here are some examples:</P
><TABLE
BORDER="0"
BGCOLOR="#EEEEEE"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>  // Grab one field from one record in the database
  $user_email = $q-&gt;grab_field(&quot;select email from &quot;.TBL_AUTH_USER.&quot; where user_id = 1&quot;);
  echo $user_email;

  // Stuff all the fields from a user record into an array
  $user_info = $q-&gt;grab(&quot;select * from &quot;.TBL_AUTH_USER.&quot; where user_id = 1&quot;);
  echo $user_info['email'];

  // Work with a set of records
  $q-&gt;query(&quot;select * from &quot;.TBL_AUTH_USER);
  while ($row = $q-&gt;grab()) {
    echo $row['email'].'&lt;br&gt;';
  }
      </PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN250"
>3.2.1.2. Templates</A
></H3
><P
>Instead of outputting HTML from the scripts, templates are used to separate the code from the HTML.  The templates contain tokens that are replaced by the scripts with values.  The general process for using templates is as follows:</P
><TABLE
BORDER="0"
BGCOLOR="#EEEEEE"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>  // Set up the file to be used
  $t-&gt;set_file('content', 'bugdisplay.html');

  // Substitute the tokens with data
  $t-&gt;set_var(array(
    'title' =&gt; $buginfo['title'],
    'description' =&gt; $buginfo['description'],
    ....
    ));
  
  // Parse the template and print it out (inside a wrap template)
  $t-&gt;pparse('main', array('content', 'wrap', 'main');
      </PRE
></TD
></TR
></TABLE
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="devguide.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>&nbsp;</TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Developer's Guide</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="devguide.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>&nbsp;</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
Return current item: phpBugTracker