From 851e09f471e18e9953c3d8503017a3dc3cce1d85 Mon Sep 17 00:00:00 2001 From: meus Date: Wed, 28 Mar 2007 21:21:03 +0000 Subject: [PATCH] Fixed the Starting new Project page. Added a list of clients. Wrote a very simple introduction to Import. Fixed some formating in Making the first import --- ...Getting started - Starting new project.php | 13 -------- .../docs/Getting started - Installation.php | 9 +++-- ...Getting started - Starting new project.php | 33 +++++++++++++++---- ...with existing databases - Introduction.php | 3 ++ ...ng databases - Making the first import.php | 9 ++--- 5 files changed, 41 insertions(+), 26 deletions(-) delete mode 100644 manual/codes/Getting started - Starting new project.php create mode 100644 manual/docs/Getting started - Working with existing databases - Introduction.php diff --git a/manual/codes/Getting started - Starting new project.php b/manual/codes/Getting started - Starting new project.php deleted file mode 100644 index 5cda71396..000000000 --- a/manual/codes/Getting started - Starting new project.php +++ /dev/null @@ -1,13 +0,0 @@ -hasColumn("name","string",30); - $this->hasColumn("username","string",20); - $this->hasColumn("password","string",16); - $this->hasColumn("created","integer",11); - } -} -?> diff --git a/manual/docs/Getting started - Installation.php b/manual/docs/Getting started - Installation.php index ef496684d..03f477082 100644 --- a/manual/docs/Getting started - Installation.php +++ b/manual/docs/Getting started - Installation.php @@ -2,9 +2,14 @@ The installation of doctrine is very easy. Just get the latest revision of Doctr You need a SVN(Subversion) client for downloading Doctrine. -To check out Doctrine using the **svn** command line tool in the current directory use: +In order to check out Doctrine in the current directory using the **svn** command line tool use the following code: svn co http://doctrine.pengus.net/svn/trunk . -Do check out using a GUI based tool like [http://tortoisesvn.tigris.org/ TortoiseSVN] simply use the http://doctrine.pengus.net/svn/trunk in the the path field. No username or password is neccesary. + +If you do not have a SVN client, chose one from the list below. Find the **Checkout** option and enter http://doctrine.pengus.net/svn/trunk in the **path** or **repository url** parameter. There is no need for a username or password to check out Doctrine. + +* [http://tortoisesvn.tigris.org/ TortoiseSVN] a Windows application that integrates into Windows Explorer +* [http://www.apple.com/downloads/macosx/development_tools/svnx.html svnx] a Mac OS X GUI svn application +* Eclipse has SVN integration through the [http://subclipse.tigris.org/ subeclipse] plugin diff --git a/manual/docs/Getting started - Starting new project.php b/manual/docs/Getting started - Starting new project.php index a291b2f46..4a79bb105 100644 --- a/manual/docs/Getting started - Starting new project.php +++ b/manual/docs/Getting started - Starting new project.php @@ -1,10 +1,29 @@ Doctrine_Record is the basic component of every doctrine-based project. There should be atleast one Doctrine_Record for each of your database tables. -Doctrine_Record follows Active Record pattern. -

-Doctrine auto-creates database tables and always adds a primary key column named 'id' to tables that doesn't have any primary keys specified. Only thing you need to for creating database tables -is defining a class which extends Doctrine_Record and setting a setTableDefinition method with hasColumn() method calls. -

-Consider we want to create a database table called 'user' with columns id(primary key), name, username, password and created. You only need couple of lines of code -to create a simple up-and-running model. +Doctrine_Record follows the [http://www.martinfowler.com/eaaCatalog/activeRecord.html Active Record pattern] +Doctrine auto-creates database tables and always adds a primary key column named 'id' to tables that doesn't have any primary keys specified. Only thing you need to for creating database tables is defining a class which extends Doctrine_Record and setting a setTableDefinition method with hasColumn() method calls. + +An short example: + +We want to create a database table called 'user' with columns id(primary key), name, username, password and created. Provided that you have already installed Doctrine these few lines of code are all you need: + + +require_once('lib/Doctrine.php'); + +spl_autoload_register(array('Doctrine', 'autoload')); + +class User extends Doctrine_Record { + public function setTableDefinition() { + // set 'user' table columns, note that + // id column is always auto-created + + $this->hasColumn("name","string",30); + $this->hasColumn("username","string",20); + $this->hasColumn("password","string",16); + $this->hasColumn("created","integer",11); + } +} + + +We now have a user model that supports basic CRUD opperations! diff --git a/manual/docs/Getting started - Working with existing databases - Introduction.php b/manual/docs/Getting started - Working with existing databases - Introduction.php new file mode 100644 index 000000000..c6c70882f --- /dev/null +++ b/manual/docs/Getting started - Working with existing databases - Introduction.php @@ -0,0 +1,3 @@ +A common case when looking for ORM tools like Doctrine is that the database and the code that access it is growing large/complex. A more substantial tool is needed then manual SQL code. + +Doctrine has support for generating Doctrine_Record classes from your existing database. There is no need for you to manually write all the Doctrine_Record classes for your domain model. diff --git a/manual/docs/Getting started - Working with existing databases - Making the first import.php b/manual/docs/Getting started - Working with existing databases - Making the first import.php index bf2d0284b..60e41226a 100644 --- a/manual/docs/Getting started - Working with existing databases - Making the first import.php +++ b/manual/docs/Getting started - Working with existing databases - Making the first import.php @@ -2,16 +2,16 @@ Let's consider we have a mysql database called test with a single table called ' The file table has been created with the following sql statement: -CREATE TABLE file ( - id INT AUTO_INCREMENT NOT NULL, +{{CREATE TABLE file ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL, name VARCHAR(150), size BIGINT, modified BIGINT, type VARCHAR(10), content TEXT, path TEXT, - PRIMARY KEY(id)) - + PRIMARY KEY(id))}} + Now we would like to convert it into Doctrine record class. It can be achieved easily with the following code snippet: @@ -39,6 +39,7 @@ class File extends Doctrine_Record { $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, + 'unsigned' > true, 'autoincrement' => true)); $this->hasColumn('name', 'string', 150); $this->hasColumn('size', 'integer', 8);