1
0
mirror of synced 2024-12-13 06:46:03 +03:00

Added connection & collection introductions + first code examples for Doctrine_View

This commit is contained in:
zYne 2006-08-30 22:43:11 +00:00
parent 77a69bc57e
commit 3b8b1a4e88
4 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,15 @@
<?php
$conn = Doctrine_Manager::getInstance()
->openConnection(new PDO("dsn","username","password");
$query = new Doctrine_Query($conn);
$query->from('User.Phonenumber')->limit(20);
$view = new Doctrine_View($query, 'MyView');
// creating a database view
$view->create();
// dropping the view from the database
$view->drop();
?>

View File

@ -0,0 +1,13 @@
<?php
$conn = Doctrine_Manager::getInstance()
->openConnection(new PDO("dsn","username","password"));
$query = new Doctrine_Query($conn);
$query->from('User.Phonenumber')->limit(20);
// hook the query into appropriate view
$view = new Doctrine_View($query, 'MyView');
// now fetch the data from the view
$coll = $view->execute();
?>

View File

@ -1,9 +1,18 @@
<?php
$coll = new Doctrine_Collection('User');
$conn = Doctrine_Manager::getInstance()
->openConnection(new PDO("dsn", "username", "pw"));
// initalizing a new collection
$users = new Doctrine_Collection($conn->getTable('User'));
// alternative (propably easier)
$users = new Doctrine_Collection('User');
// adding some data
$coll[0]->name = 'Arnold';
$coll[1]->name = 'Somebody';
// finally save it!
$coll->save();
?>