1
0
mirror of synced 2025-01-20 15:31:40 +03:00

Added data type code examples

This commit is contained in:
zYne 2006-12-03 23:40:32 +00:00
parent 9257eefee5
commit 4b9b61aad2
18 changed files with 114 additions and 32 deletions

View File

@ -5,7 +5,7 @@ $coll = $q->from("FROM Group");
// find all users and user emails // find all users and user emails
$coll = $q->from("FROM User.Email"); $coll = $q->from("FROM User u LEFT JOIN u.Email e");
// find all users and user emails with only user name and // find all users and user emails with only user name and
// age + email address loaded // age + email address loaded

View File

@ -0,0 +1,8 @@
<?php
// initalizing a new Doctrine_Query (using the current connection)
$q = new Doctrine_Query();
// initalizing a new Doctrine_Query (using custom connection parameter)
// here $conn is an instance of Doctrine_Connection
$q = new Doctrine_Query($conn);
?>

View File

@ -1,11 +1,13 @@
<?php <?php
// find the first ten users and their emails // find the first ten users and associated emails
$coll = $conn->query("FROM User, User.Email LIMIT 10"); $q = new Doctrine_Query();
$coll = $q->from('User u LEFT JOIN u.Email e')->limit(10);
// find the first ten users starting from the user number 5 // find the first ten users starting from the user number 5
$coll = $conn->query("FROM User LIMIT 10 OFFSET 5"); $coll = $q->from('User u')->limit(10)->offset(5);
?> ?>

View File

@ -1,12 +1,12 @@
<?php <?php
$query->from("User:Email"); $query->from('User u')->innerJoin('u.Email e');
$query->execute(); $query->execute();
// executed SQL query: // executed SQL query:
// SELECT ... FROM user INNER JOIN email ON ... // SELECT ... FROM user INNER JOIN email ON ...
$query->from("User.Email"); $query->from('User u')->leftJoin('u.Email e');
$query->execute(); $query->execute();

View File

@ -1,27 +1 @@
<?php
// find all groups where the group primary key is bigger than 10
$coll = $conn->query("FROM Group WHERE Group.id > 10");
// find all users where users where user name matches a regular expression,
// REGEXP keyword must be supported by the underlying database
$coll = $conn->query("FROM User WHERE User.name REGEXP '[ad]'");
// find all users and their associated emails where SOME of the users phonenumbers
// (the association between user and phonenumber tables is Many-To-Many) starts with 123
$coll = $conn->query("FROM User, User.Email WHERE User.Phonenumber.phonenumber LIKE '123%'");
// multiple conditions
$coll = $conn->query("FROM User WHERE User.name LIKE '%Jack%' && User.Email.address LIKE '%@drinkmore.info'");
// nesting conditions
$coll = $conn->query("FROM User WHERE (User.name LIKE '%Jack%' || User.name LIKE '%John%') && User.Email.address LIKE '%@drinkmore.info'");
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('arraytest', 'array', 10000);
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('blobtest', 'blob');
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('booltest', 'boolean');
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('clobtest', 'clob');
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('datetest', 'date');
}
}
?>

View File

@ -0,0 +1,14 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('enumtest', 'enum', 4,
array(
'values' => array(
'php',
'java',
'python'
)
);
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('floattest', 'float');
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('gziptest', 'gzip');
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('integertest', 'integer', 4, array('unsigned' => true);
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('objecttest', 'object');
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('stringtest', 'string', 200, array('fixed' => true));
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('timetest', 'time');
}
}
?>

View File

@ -0,0 +1,7 @@
<?php
class Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('timestamptest', 'timestamp');
}
}
?>