Added data type code examples
This commit is contained in:
parent
9257eefee5
commit
4b9b61aad2
@ -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
|
||||||
|
@ -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);
|
||||||
|
?>
|
@ -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);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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'");
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
7
manual/codes/Schema reference - Data types - Array.php
Normal file
7
manual/codes/Schema reference - Data types - Array.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('arraytest', 'array', 10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - Blob.php
Normal file
7
manual/codes/Schema reference - Data types - Blob.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('blobtest', 'blob');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - Boolean.php
Normal file
7
manual/codes/Schema reference - Data types - Boolean.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('booltest', 'boolean');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - Clob.php
Normal file
7
manual/codes/Schema reference - Data types - Clob.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('clobtest', 'clob');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - Date.php
Normal file
7
manual/codes/Schema reference - Data types - Date.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('datetest', 'date');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
14
manual/codes/Schema reference - Data types - Enum.php
Normal file
14
manual/codes/Schema reference - Data types - Enum.php
Normal 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'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - Float.php
Normal file
7
manual/codes/Schema reference - Data types - Float.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('floattest', 'float');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - Gzip.php
Normal file
7
manual/codes/Schema reference - Data types - Gzip.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('gziptest', 'gzip');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - Integer.php
Normal file
7
manual/codes/Schema reference - Data types - Integer.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('integertest', 'integer', 4, array('unsigned' => true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - Object.php
Normal file
7
manual/codes/Schema reference - Data types - Object.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('objecttest', 'object');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - String.php
Normal file
7
manual/codes/Schema reference - Data types - String.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('stringtest', 'string', 200, array('fixed' => true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
manual/codes/Schema reference - Data types - Time.php
Normal file
7
manual/codes/Schema reference - Data types - Time.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('timetest', 'time');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class Test extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn('timestamptest', 'timestamp');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user