Added connection & collection introductions + first code examples for Doctrine_View
This commit is contained in:
parent
77a69bc57e
commit
3b8b1a4e88
@ -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();
|
||||||
|
?>
|
@ -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();
|
||||||
|
?>
|
@ -1,9 +1,18 @@
|
|||||||
<?php
|
<?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[0]->name = 'Arnold';
|
||||||
|
|
||||||
$coll[1]->name = 'Somebody';
|
$coll[1]->name = 'Somebody';
|
||||||
|
|
||||||
|
// finally save it!
|
||||||
$coll->save();
|
$coll->save();
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user