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