From 0077a2203e0d92febabbcf186452ef47a10c13ba Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 1 Jul 2007 13:15:02 +0000 Subject: [PATCH] --- manual/new/docs/en/database-abstraction.txt | 47 ++++++++++++++++----- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/manual/new/docs/en/database-abstraction.txt b/manual/new/docs/en/database-abstraction.txt index cb98aeb53..76e738e62 100644 --- a/manual/new/docs/en/database-abstraction.txt +++ b/manual/new/docs/en/database-abstraction.txt @@ -76,6 +76,8 @@ $definition = array ( $conn->export->createTable('people', $definition, $options); + + +++ Creating foreign keys Creating the event_participants table with a foreign key: @@ -372,18 +374,41 @@ Array */ - - - - - -++ Util -+++ Using explain - ++ DataDict -+++ Getting portable type -+++ Getting database declaration -+++ Reserved keywords ++++ Introduction +Doctrine uses DataDict module internally to convert native RDBMS types to Doctrine types and the reverse. DataDict module uses two methods for the conversions: +1. getPortableDeclaration(), which is used for converting native RDBMS type declaration to portable Doctrine declaration +2. getNativeDeclaration(), which is used for converting portable Doctrine declaration to driver specific type declaration + + ++++ Getting portable declaration + +$dbh = new PDO('mysql:host=localhost;dbname=test', 'username', 'pw'); +$conn = Doctrine_Manager::getInstance()->openConnection($dbh); + +$decl = $conn->dataDict->getPortableDeclaration('VARCHAR(255)'); + +print_r($decl); +/* +array('type' => 'string', + 'length' => 255, + 'fixed' => false, + 'unsigned' => false + ); +*/ + ++++ Getting native declaration + +$dbh = new PDO('mysql:host=localhost;dbname=test', 'username', 'pw'); +$conn = Doctrine_Manager::getInstance()->openConnection($dbh); + +$portableDecl = array('type' => 'string', + 'length' => 20, + 'fixed' => true); +$nativeDecl = $conn->dataDict->getNativeDeclaration($portableDecl); + +print $nativeDecl; // CHAR(20) + ++ Drivers +++ Mysql