From abb56d4fd9632a82eb6571a14be51ce524c924d5 Mon Sep 17 00:00:00 2001 From: zYne Date: Fri, 15 Dec 2006 22:31:28 +0000 Subject: [PATCH] Docs updated --- ...ents - Query - FROM - selecting tables.php | 4 +- ...asic Components - Query - Introduction.php | 4 + ...ery - ORDER BY - sorting query results.php | 17 +- ...ponents - Query - DQL - SQL conversion.php | 2 + ...ents - Query - FROM - selecting tables.php | 5 +- ...asic Components - Query - Introduction.php | 11 +- manual/documentation.php | 639 +++++++++--------- 7 files changed, 342 insertions(+), 340 deletions(-) diff --git a/manual/codes/Basic Components - Query - FROM - selecting tables.php b/manual/codes/Basic Components - Query - FROM - selecting tables.php index e96445523..484a24f09 100644 --- a/manual/codes/Basic Components - Query - FROM - selecting tables.php +++ b/manual/codes/Basic Components - Query - FROM - selecting tables.php @@ -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(); ?> diff --git a/manual/codes/Basic Components - Query - Introduction.php b/manual/codes/Basic Components - Query - Introduction.php index 33c72b34c..218466fa7 100644 --- a/manual/codes/Basic Components - Query - Introduction.php +++ b/manual/codes/Basic Components - Query - Introduction.php @@ -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(); ?> diff --git a/manual/codes/Basic Components - Query - ORDER BY - sorting query results.php b/manual/codes/Basic Components - Query - ORDER BY - sorting query results.php index 627c7cecc..beaa5e092 100644 --- a/manual/codes/Basic Components - Query - ORDER BY - sorting query results.php +++ b/manual/codes/Basic Components - Query - ORDER BY - sorting query results.php @@ -1,21 +1,20 @@ 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"); +$users = $q->from('User u')->orderby('u.name ASC'); -// or +// find all users and their emails, sort by email address in ascending order -$coll = $conn->query("FROM User ORDER BY User.name"); - -// find all users and their emails, sort by email address - -$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'); ?> diff --git a/manual/docs/Basic Components - Query - DQL - SQL conversion.php b/manual/docs/Basic Components - Query - DQL - SQL conversion.php index 89a69c7a2..58592aada 100644 --- a/manual/docs/Basic Components - Query - DQL - SQL conversion.php +++ b/manual/docs/Basic Components - Query - DQL - SQL conversion.php @@ -1,4 +1,5 @@ diff --git a/manual/docs/Basic Components - Query - FROM - selecting tables.php b/manual/docs/Basic Components - Query - FROM - selecting tables.php index 3cc55e884..0b6a273c8 100644 --- a/manual/docs/Basic Components - Query - FROM - selecting tables.php +++ b/manual/docs/Basic Components - Query - FROM - selecting tables.php @@ -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. - +

select('u.name')->('User u'); ?>"); -?> +?>

+The following example shows how to use leftJoin and innerJoin methods:

diff --git a/manual/docs/Basic Components - Query - Introduction.php b/manual/docs/Basic Components - Query - Introduction.php index 20315cd01..a798f91b7 100644 --- a/manual/docs/Basic Components - Query - Introduction.php +++ b/manual/docs/Basic Components - Query - Introduction.php @@ -1,8 +1,9 @@ + 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). +inheritance (including column aggregation inheritance). +For more info about DQL see the actual DQL chapter.

-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. -

-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. diff --git a/manual/documentation.php b/manual/documentation.php index bd08829ec..aa0e1ddb9 100644 --- a/manual/documentation.php +++ b/manual/documentation.php @@ -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", + '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") + 'Record identifiers' => array( + 'Introduction', + 'Autoincremented', + 'Natural', + 'Composite', + 'Sequential') ), - "Connection management" => + '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", + '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", + '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") + 'Identifiers' => array( + 'Introduction', + 'Autoincremented', + 'Natural', + 'Composite', + 'Sequential') ), - "Basic Components" => + '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"), + '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", + '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"), + '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"), + '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 - UNDER CONSTRUCTION" => array("Introduction", - "Setting parameters", - "Getting parameters", - "Getting row count", - "Executing the statement"), + 'Statement - UNDER CONSTRUCTION' => 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"), + '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" + '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" => + '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", + '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" + 'Validators' => array( + 'Introduction', + 'More Validation', + 'Valid or Not Valid', + 'List of predefined validators' ), - "View" => array( - "Intoduction", - "Managing views", - "Using views" + 'View' => array( + 'Intoduction', + 'Managing views', + 'Using views' ), - "Cache" => array( - "Introduction", - "Query cache"), + 'Cache' => array( + 'Introduction', + 'Query cache'), - "Locking Manager" => array( - "Introduction", - "Examples", - "Planned", - "Technical Details", - "Maintainer"), + '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" + 'Connection modules' => array( + 'Export' => array('Introduction', + 'Creating new table', + 'Altering table' ), - "Import" => array("Introduction", - "Getting table info", - "Getting foreign key info", - "Getting view info", + '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"), + 'Util' => array('Using explain'), + 'DataDict' => array('Getting portable type', + 'Getting database declaration', + 'Reserved keywords'), ), - "Technology" => array( - "Architecture", - "Design patterns used", - "Speed", - "Internal optimizations" => + 'Technology' => array( + 'Architecture', + 'Design patterns used', + 'Speed', + 'Internal optimizations' => - array("DELETE", - "INSERT", - "UPDATE"), + array('DELETE', + 'INSERT', + '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( - "Overview" => + 'Coding standards' => array( + 'Overview' => array( - "Scope", - "Goals" + 'Scope', + 'Goals' ), - "PHP File Formatting" => array( - "General", - "Indentation", - "Maximum line length", - "Line termination" + 'PHP File Formatting' => array( + 'General', + 'Indentation', + 'Maximum line length', + 'Line termination' ), - "Naming Conventions" => array( - "Classes", - "Interfaces", - "Filenames", - "Functions and methods", - "Variables", - "Constants", - "Record columns", + '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" + 'Coding Style' => array( + 'PHP code demarcation', + 'Strings', + 'Arrays', + 'Classes', + 'Functions and methods', + 'Control statements', + 'Inline documentation' ), ) );