Commit abb56d4f authored by zYne's avatar zYne

Docs updated

parent 99e81586
...@@ -18,7 +18,7 @@ $coll = $q->select('u.name, u.age, e.address') ...@@ -18,7 +18,7 @@ $coll = $q->select('u.name, u.age, e.address')
// find all users, user email and user phonenumbers // find all users, user email and user phonenumbers
$coll = $q->from('FROM User u') $coll = $q->from('FROM User u')
->leftJoin('u.Email e') ->innerJoin('u.Email e')
->leftJoin('u.Phonenumber p') ->innerJoin('u.Phonenumber p')
->execute(); ->execute();
?> ?>
...@@ -5,4 +5,8 @@ $q = new Doctrine_Query(); ...@@ -5,4 +5,8 @@ $q = new Doctrine_Query();
// initalizing a new Doctrine_Query (using custom connection parameter) // initalizing a new Doctrine_Query (using custom connection parameter)
// here $conn is an instance of Doctrine_Connection // here $conn is an instance of Doctrine_Connection
$q = new Doctrine_Query($conn); $q = new Doctrine_Query($conn);
// an example using the create method
// here we simple fetch all users
$users = Doctrine_Query::create()->from('User')->execute();
?> ?>
<?php <?php
$q = new Doctrine_Query();
// find all users, sort by name descending // find all users, sort by name descending
$coll = $conn->query("FROM User ORDER BY User.name DESC"); $users = $q->from('User u')->orderby('u.name DESC');
// find all users sort by name ascending // find all users sort by name ascending
$coll = $conn->query("FROM User ORDER BY User.name ASC"); $users = $q->from('User u')->orderby('u.name ASC');
// or
$coll = $conn->query("FROM User ORDER BY User.name");
// find all users and their emails, sort by email address // find all users and their emails, sort by email address in ascending order
$coll = $conn->query("FROM User, User.Email ORDER BY User.Email.address"); $users = $q->from('User u')->leftJoin('u.Email e')->orderby('e.address');
// find all users and their emails, sort by user name and email address // find all users and their emails, sort by user name and email address
$coll = $conn->query("FROM User, User.Email ORDER BY User.name, User.Email.address"); $users = $q->from('User u')->leftJoin('u.Email e')
->addOrderby('u.name')->addOrderby('e.address');
?> ?>
<?php <?php
/**
$str = " $str = "
The following examples should give a hint of how DQL is converted into SQL. The following examples should give a hint of how DQL is converted into SQL.
The classes used in here are the same as in chapter 14.1 (Users and groups are both entities etc). The classes used in here are the same as in chapter 14.1 (Users and groups are both entities etc).
...@@ -52,4 +53,5 @@ foreach($e as $line) { ...@@ -52,4 +53,5 @@ foreach($e as $line) {
} }
} }
renderQueries($str); renderQueries($str);
*/
?> ?>
...@@ -3,7 +3,7 @@ The FROM clause indicates the component or components from which to retrieve rec ...@@ -3,7 +3,7 @@ The FROM clause indicates the component or components from which to retrieve rec
If you name more than one component, you are performing a join. If you name more than one component, you are performing a join.
For each table specified, you can optionally specify an alias. Doctrine_Query offers easy to use For each table specified, you can optionally specify an alias. Doctrine_Query offers easy to use
methods such as from(), addFrom(), leftJoin() and innerJoin() for managing the FROM part of your DQL query. methods such as from(), addFrom(), leftJoin() and innerJoin() for managing the FROM part of your DQL query.
<br \><br \>
<?php <?php
renderCode("<?php renderCode("<?php
// find all users // find all users
...@@ -15,4 +15,5 @@ renderCode("<?php ...@@ -15,4 +15,5 @@ renderCode("<?php
\$coll = \$q->select('u.name')->('User u'); \$coll = \$q->select('u.name')->('User u');
?>"); ?>");
?> ?> <br \><br \>
The following example shows how to use leftJoin and innerJoin methods: <br \><br \>
<?php ?>
DQL (Doctrine Query Language) is a object query language which allows DQL (Doctrine Query Language) is a object query language which allows
you to find objects. DQL understands things like object relationships, polymorphism and you to find objects. DQL understands things like object relationships, polymorphism and
inheritance (including column aggregation inheritance). inheritance (including column aggregation inheritance).
For more info about DQL see the actual DQL chapter.
<br \><br \> <br \><br \>
So instead of writing lots of SQL inner and outer joins, unions and subselects yourself, Doctrine_Query along with Doctrine_Expression provide an easy-to-use wrapper for writing DQL queries. Creating a new
you can write simple DQL queries where relationships are being referenced with dot-notation. query object can be done by either using the new operator or by calling create method. The create method exists for allowing easy
<br \><br \> method call chaining.
You can execute DQL queries with Doctrine_Connection::query() method.
...@@ -92,261 +92,256 @@ function array2path($array, $path = '') { ...@@ -92,261 +92,256 @@ function array2path($array, $path = '') {
return $arrayValues; return $arrayValues;
} }
$menu = array("Getting started" => $menu = array('Getting started' =>
array( array(
"Requirements", 'Requirements',
"Installation", 'Installation',
"Compiling", 'Compiling',
"Starting new project", 'Starting new project',
"Setting table definition" => array( 'Setting table definition' => array(
"Introduction", 'Introduction',
"Table and class naming", 'Table and class naming',
"Field(Column) naming", 'Field(Column) naming',
"Data types and lengths", 'Data types and lengths',
"Constraints and validators", 'Constraints and validators',
"Default values", 'Default values',
"Enum emulation", 'Enum emulation',
), ),
"Record identifiers" => array( 'Record identifiers' => array(
"Introduction", 'Introduction',
"Autoincremented", 'Autoincremented',
"Natural", 'Natural',
"Composite", 'Composite',
"Sequential") 'Sequential')
), ),
"Connection management" => 'Connection management' =>
array( array(
"Opening a new connection", 'Opening a new connection',
"Lazy-connecting to database", 'Lazy-connecting to database',
"Managing connections", 'Managing connections',
"Connection-component binding" 'Connection-component binding'
), ),
"Schema reference" => 'Schema reference' =>
array( array(
"Data types" => array( 'Data types' => array(
"Introduction", 'Introduction',
"Type modifiers", 'Type modifiers',
"Boolean", 'Boolean',
"Integer", 'Integer',
"Float", 'Float',
"String", 'String',
"Array", 'Array',
"Object", 'Object',
"Blob", 'Blob',
"Clob", 'Clob',
"Timestamp", 'Timestamp',
"Time", 'Time',
"Date", 'Date',
"Enum", 'Enum',
"Gzip", 'Gzip',
), ),
"Column attributes" => array( 'Column attributes' => array(
"Introduction", 'Introduction',
"Primary", 'Primary',
"Autoincrement", 'Autoincrement',
"Default", 'Default',
"Zerofill", 'Zerofill',
"Collation", 'Collation',
"Charset", 'Charset',
"Unsigned", 'Unsigned',
"Fixed", 'Fixed',
"Enum", 'Enum',
"Unique", 'Unique',
"Nospace", 'Nospace',
"Notblank", 'Notblank',
"Notnull", 'Notnull',
"Email", 'Email',
"Date", 'Date',
"Range", 'Range',
"Numeric", 'Numeric',
"Regexp", 'Regexp',
"Ip", 'Ip',
"Usstate", 'Usstate',
), ),
"Identifiers" => array( 'Identifiers' => array(
"Introduction", 'Introduction',
"Autoincremented", 'Autoincremented',
"Natural", 'Natural',
"Composite", 'Composite',
"Sequential") 'Sequential')
), ),
"Basic Components" => 'Basic Components' =>
array( array(
"Manager" 'Manager'
=> array("Introduction", => array('Introduction',
"Opening a new connection", 'Opening a new connection',
"Managing connections"), 'Managing connections'),
"Record" 'Record'
=> array("Introduction", => array('Introduction',
"Creating new records", 'Creating new records',
"Retrieving existing records", 'Retrieving existing records',
"Accessing properties", 'Accessing properties',
"Updating records", 'Updating records',
"Deleting records", 'Deleting records',
"Getting record state", 'Getting record state',
"Getting object copy", 'Getting object copy',
"Serializing", 'Serializing',
"Checking Existence", 'Checking Existence',
"Callbacks"), 'Callbacks'),
"Connection" 'Connection'
=> array("Introduction", => array('Introduction',
"Available drivers", 'Available drivers',
"Getting a table object", 'Getting a table object',
"Flushing the connection", 'Flushing the connection',
"Querying the database", 'Querying the database',
"Getting connection state"), 'Getting connection state'),
"Collection" 'Collection'
=> array("Introduction", => array('Introduction',
"Accessing elements", 'Accessing elements',
"Adding new elements", 'Adding new elements',
"Getting collection count", 'Getting collection count',
"Saving the collection", 'Saving the collection',
"Deleting collection", 'Deleting collection',
//"Fetching strategies", //'Fetching strategies',
"Key mapping", 'Key mapping',
"Loading related records", 'Loading related records',
"Collection expanding", 'Collection expanding',
), ),
"Table" => array("Introduction", 'Table' => array('Introduction',
"Getting table information", 'Getting table information',
"Finder methods", 'Finder methods',
"Custom table classes", 'Custom table classes',
"Custom finders", 'Custom finders',
"Getting relation objects"), 'Getting relation objects'),
"Query" => array("Introduction", 'Query' => array('Introduction',
"FROM - selecting tables", 'FROM - selecting tables',
"LIMIT and OFFSET - limiting the query results", 'LIMIT and OFFSET - limiting the query results',
"WHERE - setting query conditions", 'WHERE - setting query conditions',
"ORDER BY - sorting query results", 'HAVING conditions',
//"Fetching strategies", 'ORDER BY - sorting query results',
//"Lazy property fetching", ),
"Method overloading", 'RawSql' => array(
"Relation operators", 'Introduction',
"Bound parameters", 'Using SQL',
"Aggregate functions", 'Adding components',
"DQL - SQL conversion"), 'Method overloading'),
"RawSql" => array( 'Db' => array(
"Introduction", 'Introduction',
"Using SQL", 'Connecting to a database',
"Adding components", 'Using event listeners',
"Method overloading"), 'Chaining listeners'),
"Db" => array(
"Introduction",
"Connecting to a database",
"Using event listeners",
"Chaining listeners"),
/** /**
"Statement - <font color='red'>UNDER CONSTRUCTION</font>" => array("Introduction", 'Statement - <font color='red'>UNDER CONSTRUCTION</font>' => array('Introduction',
"Setting parameters", 'Setting parameters',
"Getting parameters", 'Getting parameters',
"Getting row count", 'Getting row count',
"Executing the statement"), 'Executing the statement'),
*/ */
"Exceptions" => array( 'Exceptions' => array(
"Overview", 'Overview',
"List of exceptions" 'List of exceptions'
) )
), ),
"Mapping object relations" => 'Mapping object relations' =>
array( array(
"Introduction", 'Introduction',
"Composites and aggregates", 'Composites and aggregates',
"Relation aliases", 'Relation aliases',
"Foreign key associations" => array( 'Foreign key associations' => array(
"One-to-One", 'One-to-One',
"One-to-Many, Many-to-One", 'One-to-Many, Many-to-One',
"Tree structure"), 'Tree structure'),
"Join table associations" => array( 'Join table associations' => array(
"One-to-One", 'One-to-One',
"One-to-Many, Many-to-One", 'One-to-Many, Many-to-One',
"Many-to-Many", 'Many-to-Many',
"Self-referencing"), 'Self-referencing'),
"Dealing with relations" => array( 'Dealing with relations' => array(
"Creating related records", 'Creating related records',
"Retrieving related records", 'Retrieving related records',
"Updating related records", 'Updating related records',
"Deleting related records", 'Deleting related records',
"Working with associations"), 'Working with associations'),
"Inheritance" => 'Inheritance' =>
array("One table many classes", array('One table many classes',
"One table one class", 'One table one class',
"Column aggregation" 'Column aggregation'
), ),
), ),
"Configuration" => 'Configuration' =>
array( array(
"Introduction", 'Introduction',
"Levels of configuration", 'Levels of configuration',
"Setting attributes" => array( 'Setting attributes' => array(
"Portability", 'Portability',
"Identifier quoting", 'Identifier quoting',
"Table creation", 'Table creation',
"Fetching strategy", 'Fetching strategy',
"Batch size", 'Batch size',
"Session lockmode", 'Session lockmode',
"Event listener", 'Event listener',
"Validation", 'Validation',
"Offset collection limit" 'Offset collection limit'
) )
), ),
"Advanced components" => array( 'Advanced components' => array(
"Eventlisteners" => 'Eventlisteners' =>
array( array(
"Introduction", 'Introduction',
"Creating new listener", 'Creating new listener',
"List of events", 'List of events',
"Listening events", 'Listening events',
"Chaining", 'Chaining',
"AccessorInvoker", 'AccessorInvoker',
"Creating a logger", 'Creating a logger',
), ),
"Validators" => array( 'Validators' => array(
"Introduction", 'Introduction',
"More Validation", 'More Validation',
"Valid or Not Valid", 'Valid or Not Valid',
"List of predefined validators" 'List of predefined validators'
), ),
"View" => array( 'View' => array(
"Intoduction", 'Intoduction',
"Managing views", 'Managing views',
"Using views" 'Using views'
), ),
"Cache" => array( 'Cache' => array(
"Introduction", 'Introduction',
"Query cache"), 'Query cache'),
"Locking Manager" => array( 'Locking Manager' => array(
"Introduction", 'Introduction',
"Examples", 'Examples',
"Planned", 'Planned',
"Technical Details", 'Technical Details',
"Maintainer"), 'Maintainer'),
/** /**
"Debugger" => array( 'Debugger' => array(
"Introduction", 'Introduction',
"Debugging actions"), 'Debugging actions'),
"Library" => array( 'Library' => array(
"Introduction", 'Introduction',
"Using library functions"), 'Using library functions'),
"Iterator" => array( 'Iterator' => array(
"Introduction", 'Introduction',
"BatchIterator", 'BatchIterator',
"ExpandableIterator", 'ExpandableIterator',
"OffsetIterator") 'OffsetIterator')
*/ */
), ),
"DQL (Doctrine Query Language)" => 'DQL (Doctrine Query Language)' =>
array( array(
'Introduction', 'Introduction',
...@@ -386,154 +381,154 @@ $menu = array("Getting started" => ...@@ -386,154 +381,154 @@ $menu = array("Getting started" =>
'Examples', 'Examples',
'BNF'), 'BNF'),
"Transactions" => array( 'Transactions' => array(
"Introduction", 'Introduction',
"Unit of work", 'Unit of work',
"Nesting", 'Nesting',
"Savepoints", 'Savepoints',
"Locking strategies" => 'Locking strategies' =>
array("Pessimistic locking", array('Pessimistic locking',
"Optimistic locking"), 'Optimistic locking'),
"Lock modes", 'Lock modes',
"Isolation levels", 'Isolation levels',
"Deadlocks", 'Deadlocks',
), ),
"Native SQL" => array( 'Native SQL' => array(
"Scalar queries", 'Scalar queries',
"Component queries", 'Component queries',
"Fetching multiple components", 'Fetching multiple components',
), ),
/** /**
"Developer components" => array( 'Developer components' => array(
"DataDict" => array( 'DataDict' => array(
"Introduction", 'Introduction',
"Usage" 'Usage'
), ),
"IndexGenerator" => 'IndexGenerator' =>
array( array(
"Introduction", 'Introduction',
"Usage"), 'Usage'),
"Relation" => array( 'Relation' => array(
"Introduction", 'Introduction',
"Types of relations", 'Types of relations',
), ),
"Null" => array( 'Null' => array(
"Introduction", 'Introduction',
"Extremely fast null value checking" 'Extremely fast null value checking'
), ),
"Access" => array( 'Access' => array(
"Introduction", 'Introduction',
"Usage" 'Usage'
), ),
"Configurable" => array( 'Configurable' => array(
"Introduction", 'Introduction',
"Usage" 'Usage'
), ),
), ),
*/ */
/** /**
"Improving performance" => array( 'Improving performance' => array(
"Introduction", 'Introduction',
"Data types" => 'Data types' =>
array( array(
"Enum", 'Enum',
), ),
"Primary keys" => array( 'Primary keys' => array(
"When to use surrogate primary keys", 'When to use surrogate primary keys',
), ),
"Constraints" => array( 'Constraints' => array(
"General tips", 'General tips',
"Foreign keys", 'Foreign keys',
"Triggers", 'Triggers',
), ),
"Data manipulation" => array( 'Data manipulation' => array(
"INSERT queries", 'INSERT queries',
"UPDATE queries", 'UPDATE queries',
"DELETE queries", 'DELETE queries',
), ),
"Indexes" => array( 'Indexes' => array(
"General tips", 'General tips',
"Using compound indexes", 'Using compound indexes',
), ),
"Transactions" => array( 'Transactions' => array(
"General tips", 'General tips',
"Locks", 'Locks',
"Isolation", 'Isolation',
), ),
"Data fetching" => array( 'Data fetching' => array(
"General tips", 'General tips',
), ),
"Normalization" => array( 'Normalization' => array(
), ),
"Caching" => array( 'Caching' => array(
"General tips" 'General tips'
), ),
"Performance monitoring" => array( "Using the database profiler") 'Performance monitoring' => array( 'Using the database profiler')
), ),
*/ */
"Connection modules" => array( 'Connection modules' => array(
"Export" => array("Introduction", 'Export' => array('Introduction',
"Creating new table", 'Creating new table',
"Altering table" 'Altering table'
), ),
"Import" => array("Introduction", 'Import' => array('Introduction',
"Getting table info", 'Getting table info',
"Getting foreign key info", 'Getting foreign key info',
"Getting view info", 'Getting view info',
), ),
"Util" => array("Using explain"), 'Util' => array('Using explain'),
"DataDict" => array("Getting portable type", 'DataDict' => array('Getting portable type',
"Getting database declaration", 'Getting database declaration',
"Reserved keywords"), 'Reserved keywords'),
), ),
"Technology" => array( 'Technology' => array(
"Architecture", 'Architecture',
"Design patterns used", 'Design patterns used',
"Speed", 'Speed',
"Internal optimizations" => 'Internal optimizations' =>
array("DELETE", array('DELETE',
"INSERT", 'INSERT',
"UPDATE"), 'UPDATE'),
), ),
"Real world examples" => array("User management system","Forum application","Album lister"), 'Real world examples' => array('User management system','Forum application','Album lister'),
"Coding standards" => array( 'Coding standards' => array(
"Overview" => 'Overview' =>
array( array(
"Scope", 'Scope',
"Goals" 'Goals'
), ),
"PHP File Formatting" => array( 'PHP File Formatting' => array(
"General", 'General',
"Indentation", 'Indentation',
"Maximum line length", 'Maximum line length',
"Line termination" 'Line termination'
), ),
"Naming Conventions" => array( 'Naming Conventions' => array(
"Classes", 'Classes',
"Interfaces", 'Interfaces',
"Filenames", 'Filenames',
"Functions and methods", 'Functions and methods',
"Variables", 'Variables',
"Constants", 'Constants',
"Record columns", 'Record columns',
), ),
"Coding Style" => array( 'Coding Style' => array(
"PHP code demarcation", 'PHP code demarcation',
"Strings", 'Strings',
"Arrays", 'Arrays',
"Classes", 'Classes',
"Functions and methods", 'Functions and methods',
"Control statements", 'Control statements',
"Inline documentation" 'Inline documentation'
), ),
) )
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment