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
This commit is contained in:
parent
50defa4fbf
commit
851e09f471
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
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);
|
||||
}
|
||||
}
|
||||
?>
|
@ -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:
|
||||
<code type="bash">
|
||||
svn co http://doctrine.pengus.net/svn/trunk .
|
||||
</code>
|
||||
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
|
||||
|
||||
|
@ -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 <a href="http://www.martinfowler.com/eaaCatalog/activeRecord.html">Active Record pattern</a>.
|
||||
<br \><br \>
|
||||
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.
|
||||
<br \><br \>
|
||||
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:
|
||||
|
||||
<code type="php">
|
||||
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);
|
||||
}
|
||||
}
|
||||
</code>
|
||||
|
||||
We now have a user model that supports basic CRUD opperations!
|
||||
|
@ -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.
|
@ -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:
|
||||
|
||||
<code type='php'>
|
||||
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user