Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Fixed parse/build errors in db docs
Browse files Browse the repository at this point in the history
- Also cleaned up some formatting
  • Loading branch information
weierophinney committed Mar 2, 2012
1 parent b8c1461 commit 0b4a4fd
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 167 deletions.
4 changes: 2 additions & 2 deletions documentation/manual/en/manual.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -781,9 +781,9 @@
</xi:fallback>
</xi:include>

<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module_specs/Zend_Db-TableDataGateway.xml" parse="xml">
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module_specs/Zend_Db-TableGateway.xml" parse="xml">
<xi:fallback>
<xi:include href="../en/module_specs/Zend_Db-TableDataGateway.xml" parse="xml"/>
<xi:include href="../en/module_specs/Zend_Db-TableGateway.xml" parse="xml"/>
</xi:fallback>
</xi:include>
</chapter>
Expand Down
177 changes: 94 additions & 83 deletions documentation/manual/en/module_specs/Zend_Db-Sql.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="zend.db.tablegateway"><info><title>Zend\Db\TableGateway</title></info>
<section xmlns="http://docbook.org/ns/docbook" version="5.0"
xml:id="zend.db.sql">
<info><title>Zend\Db\Sql</title></info>

<para>
Zend\Db\Sql is a abstraction layer for building vendor and driver specific queries.
Zend\Db\Sql is capable of preparing a Zend\Db\Adapter Statement object, but is also
capable of producing SQL strings.
</para>

<section xml:id="zend.db.sql.primary"><info><title>Primary Objects: Select, Insert, Update, Delete, Where</title></info>
<section xml:id="zend.db.sql.primary">
<info><title>Primary Objects: Select, Insert, Update, Delete, Where</title></info>

<para>
The primary objects that to interact with are:
Expand All @@ -19,21 +22,25 @@
Zend\Db\Sql\Select - SELECT abstraction
</para>
</listitem>

<listitem>
<para>
Zend\Db\Sql\Insert - INSERT abstraction
</para>
</listitem>

<listitem>
<para>
Zend\Db\Sql\Update - UPDATE abstraction
</para>
</listitem>

<listitem>
<para>
Zend\Db\Sql\Delete - DELETE abstraction
</para>
</listitem>

<listitem>
<para>
Zend\Db\Sql\Where - WHERE abstraction to be used with Select, Update and Delete
Expand Down Expand Up @@ -118,10 +125,10 @@
}
]]></programlisting>

</section>

<section xml:id="zend.db.sql.where"><info><title>Where, Predicates and the Fluent Interface</title></info>
<section xml:id="zend.db.sql.where">
<info><title>Where, Predicates and the Fluent Interface</title></info>

<para>
The Zend\Db\Sql\Where object is where much of the focus of getting
Expand All @@ -138,15 +145,16 @@
</para>

<para>
Built-In Predicates
Between - Check if an identifier is between two values - Zend\Db\Sql\Predicate\Between
In - Check if an identifier is in an array of values - Zend\Db\Sql\Predicate\In
IsNotNull - Check if an identifier is not null -= Zend\Db\Sql\Predicate\IsNotNull
IsNull - Check if an identifier is null - Zend\Db\Sql\Predicate\IsNull
Like - Check if an identifier matches a SQL LIKE expression value - Zend\Db\Sql\Predicate\Like
Literal - Use an SQL fragment exactly as typed, using ? as parameter interpoation - Zend\Db\Sql\Predicate\Literal
Operator - Check how a particular value compares to another value, possible operators (=, !=, >, <, >=, <=) - Zend\Db\Sql\Predicate\Operator
PredicateSet - A nested set of additional Predicates that will be inside a SQL nest - Zend\Db\Sql\Predicate\PredicateSet
Built-In Predicates Between - Check if an identifier is between two values -
Zend\Db\Sql\Predicate\Between In - Check if an identifier is in an array of values -
Zend\Db\Sql\Predicate\In IsNotNull - Check if an identifier is not null -=
Zend\Db\Sql\Predicate\IsNotNull IsNull - Check if an identifier is null -
Zend\Db\Sql\Predicate\IsNull Like - Check if an identifier matches a SQL LIKE expression
value - Zend\Db\Sql\Predicate\Like Literal - Use an SQL fragment exactly as typed, using
? as parameter interpoation - Zend\Db\Sql\Predicate\Literal Operator - Check how a
particular value compares to another value, possible operators (=, !=, &gt;, &lt;,
&gt;=, &lt;=) - Zend\Db\Sql\Predicate\Operator PredicateSet - A nested set of additional
Predicates that will be inside a SQL nest - Zend\Db\Sql\Predicate\PredicateSet.
</para>

<para>
Expand All @@ -155,95 +163,98 @@
</para>

<programlisting language="php"><![CDATA[
$where = new Zend\Db\Sql\Where();
$where->like('name', 'Ralph%')
->OR->NEST->greaterThanOrEqualTo('age', 30)->AND->lessThanOrEqualTo('age', 50)->UNNEST;
$where = new Zend\Db\Sql\Where();
$where->like('name', 'Ralph%')
->OR
->NEST
->greaterThanOrEqualTo('age', 30)
->AND
->lessThanOrEqualTo('age', 50)
->UNNEST;
]]></programlisting>

<para>
This API is possible due to Zend\Db\Sql\Where\Predicate, who's interface looks like this:
</para>

<programlisting language="php"><![CDATA[
class Zend\Db\Sql\Where\Predicate
public $OR;
public $AND;
public $NEST;
public $UNNSET;
public function nest();
public function setUnnest(Predicate $predicate);
public function unnest();
public function equalTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function lessThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function greaterThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function lessThanOrEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function greaterThanOrEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function like($identifier, $like);
public function literal($literal, $parameter);
public function isNull($identifier);
public function isNotNull($identifier);
public function in($identifier, array $valueSet = array());
public function between($identifier, $minValue, $maxValue);
}
class Zend\Db\Sql\Where\Predicate
{
public $OR;
public $AND;
public $NEST;
public $UNNSET;
public function nest();
public function setUnnest(Predicate $predicate);
public function unnest();
public function equalTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function lessThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function greaterThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function lessThanOrEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function greaterThanOrEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE);
public function like($identifier, $like);
public function literal($literal, $parameter);
public function isNull($identifier);
public function isNotNull($identifier);
public function in($identifier, array $valueSet = array());
public function between($identifier, $minValue, $maxValue);
}
]]></programlisting>
</section>

<section xml:id="zend.db.sql.examples">
<info><title>Examples</title></info>

<section xml:id="zend.db.sql.examples"><info><title>Examples</title></info>
<section xml:id="zend.db.sql.examples.complex-where">
<info><title>Complex Where</title></info>

<section xml:id="zend.db.sql.examples.complex-where"><info><title>Complex Where</title></info>
<programlisting language="php"><![CDATA[
$where = new Zend\Db\Sql\Where();
$where->equalTo('id', 1)->OR->equalTo('id', 2);
echo $where->getSqlString() // WHERE "id" = '1' OR "id" = '2'
$where = new Zend\Db\Sql\Where();
$where->like('name', 'Ralph%')
->OR->NEST->greaterThanOrEqualTo('age', 30)->AND->lessThanOrEqualTo('age', 50)->UNNEST;
echo $where->getSqlString() // WHERE "name" LIKE 'Ralph%' OR ("age" >= '30' AND "age" <= '50')
$where = new Zend\Db\Sql\Where();
$where->equalTo('id', 1)->OR->equalTo('id', 2);
echo $where->getSqlString() // WHERE "id" = '1' OR "id" = '2'
$where = new Zend\Db\Sql\Where();
$where->like('name', 'Ralph%')
->OR
->NEST
->greaterThanOrEqualTo('age', 30)
->AND
->lessThanOrEqualTo('age', 50)
->UNNEST;
echo $where->getSqlString() // WHERE "name" LIKE 'Ralph%' OR ("age" >= '30' AND "age" <= '50')
]]></programlisting>

</section>

<section xml:id="zend.db.sql.examples.select"><info><title>Select Prepare</title></info>
<programlisting language="php"><![CDATA[
use Zend\Db\Sql\Select,
Zend\Db\ResultSet\ResultSet;
// instntiate select object
$select = new Select;
$select->from('artist')
->join('album', 'artist.id = album.artist_id')
->where->like('artist.name', 'Foo%');
// create a statement to use
$statment = $adapter->createStatement();
// prepare statement with $select
$select->prepareStatement($adapter, $statment);
// instantiate a result set for result-as-object iteration
$resultSet = new ResultSet();
$resultSet->setDataSource($statment->execute());
$albums = array();
foreach ($resultSet as $row) {
$albums[] = $row->title;
}
]]></programlisting>
</section>

</section>

</section>



<section xml:id="zend.db.sql.examples.select">
<info><title>Select Prepare</title></info>

<programlisting language="php"><![CDATA[
use Zend\Db\Sql\Select,
Zend\Db\ResultSet\ResultSet;
// instantiate select object
$select = new Select;
$select->from('artist')
->join('album', 'artist.id = album.artist_id')
->where->like('artist.name', 'Foo%');
// create a statement to use
$statment = $adapter->createStatement();
// prepare statement with $select
$select->prepareStatement($adapter, $statment);
// instantiate a result set for result-as-object iteration
$resultSet = new ResultSet();
$resultSet->setDataSource($statment->execute());
$albums = array();
foreach ($resultSet as $row) {
$albums[] = $row->title;
}
]]></programlisting>
</section>
</section>
</section>
Loading

0 comments on commit 0b4a4fd

Please sign in to comment.