没有合适的资源?快使用搜索试试~ 我知道了~
Doctrine ORM for PHP
需积分: 5 0 下载量 52 浏览量
2023-04-06
11:36:01
上传
评论
收藏 2.37MB PDF 举报
温馨提示
试读
407页
Doctrine ORM for PHP
资源推荐
资源详情
资源评论
Doctrine ORM for PHP
Guide to Doctrine for PHP
Doctrine 1.0
License: Creative Commons Attribution-Share Alike 3.0 Unported License
Version: manual-1.0-en-2009-02-25
Table of Contents
Introduction .................................................................................................... 13
What is Doctrine? .................................................................................................... 13
What is an ORM? ..................................................................................................... 13
What is the Problem?............................................................................................... 13
Minimum Requirements .......................................................................................... 14
Basic Overview ........................................................................................................ 14
Doctrine Explained .................................................................................................. 15
Key Concepts ........................................................................................................... 16
Further Reading ...................................................................................................... 17
Conclusion ............................................................................................................... 17
Getting Started ............................................................................................... 18
Checking Requirements........................................................................................... 18
Installing.................................................................................................................. 18
Sandbox .............................................................................................................................. 19
SVN..................................................................................................................................... 19
Installing......................................................................................................................................... 19
Updating ......................................................................................................................................... 20
SVN Externals .................................................................................................................... 20
PEAR Installer .................................................................................................................... 20
Download Pear Package ..................................................................................................... 20
Implementing........................................................................................................... 21
Including Doctrine Libraries .............................................................................................. 21
Require Doctrine Base Class .............................................................................................. 21
Register Autoloader............................................................................................................ 22
Autoloading Explained.................................................................................................................... 22
Bootstrap File ..................................................................................................................... 23
Test Script .......................................................................................................................... 23
Conclusion ............................................................................................................... 24
Introduction to Connections........................................................................... 25
DSN, the Data Source Name ................................................................................... 25
Examples ............................................................................................................................ 27
Opening New Connections ...................................................................................... 27
Lazy Database Connecting ...................................................................................... 28
Testing your Connection.......................................................................................... 28
Conclusion ............................................................................................................... 29
Configuration .................................................................................................. 31
Levels of Configuration............................................................................................ 31
Portability ................................................................................................................ 32
Portability Mode Attributes................................................................................................ 32
Examples ............................................................................................................................ 33
Table of Contents ii
-----------------
Brought to you by
Identifier quoting..................................................................................................... 33
Exporting ................................................................................................................. 34
Naming convention attributes ................................................................................. 35
Index name format ............................................................................................................. 35
Sequence name format....................................................................................................... 36
Table name format ............................................................................................................. 36
Database name format ....................................................................................................... 36
Validation attributes........................................................................................................... 36
Validation mode constants ................................................................................................. 37
Examples ............................................................................................................................ 37
Optional String Syntax ............................................................................................ 37
Conclusion ............................................................................................................... 38
Connections .................................................................................................... 39
Introduction ............................................................................................................. 39
Opening Connections............................................................................................... 39
Retrieve Connections............................................................................................... 39
Current Connection ................................................................................................. 40
Change Current Connection .................................................................................... 40
Iterating Connections .............................................................................................. 40
Get Connection Name.............................................................................................. 40
Close Connection ..................................................................................................... 41
Get All Connections ................................................................................................. 41
Count Connections................................................................................................... 42
Creating and Dropping Database ............................................................................ 42
Conclusion ............................................................................................................... 43
Introduction to Models ................................................................................... 44
Introduction ............................................................................................................. 44
Generating Models .................................................................................................. 44
Existing Databases ............................................................................................................. 45
Making the first import................................................................................................................... 45
Schema Files ...................................................................................................................... 49
Manually Writing Models ........................................................................................ 51
Autoloading Models ................................................................................................. 51
Conservative....................................................................................................................... 51
Aggressive .......................................................................................................................... 52
Conclusion ............................................................................................................... 53
Defining Models .............................................................................................. 54
Columns ................................................................................................................... 54
Column aliases.................................................................................................................... 54
Default values..................................................................................................................... 55
Data types........................................................................................................................... 56
Introduction .................................................................................................................................... 56
Type modifiers ................................................................................................................................ 57
Boolean ........................................................................................................................................... 57
Integer ............................................................................................................................................ 58
Float................................................................................................................................................ 59
Decimal........................................................................................................................................... 59
String .............................................................................................................................................. 60
Array ............................................................................................................................................... 60
Object ............................................................................................................................................. 61
Blob................................................................................................................................................. 61
Clob................................................................................................................................................. 62
Timestamp ...................................................................................................................................... 62
Table of Contents iii
-----------------
Brought to you by
Time ................................................................................................................................................ 63
Date ................................................................................................................................................ 63
Enum............................................................................................................................................... 64
Gzip................................................................................................................................................. 65
Examples ............................................................................................................................ 65
Relationships ........................................................................................................... 68
Introduction........................................................................................................................ 68
Foreign Key Associations ................................................................................................... 73
One to One...................................................................................................................................... 73
One to Many and Many to One ....................................................................................................... 74
Tree Structure ................................................................................................................................ 76
Join Table Associations....................................................................................................... 77
Many to Many ................................................................................................................................. 77
Self Referencing (Nest Relations) .................................................................................................. 81
Non-Equal Nest Relations ............................................................................................................................ 81
Equal Nest Relations .................................................................................................................................... 82
Foreign Key Constraints..................................................................................................... 85
Introduction .................................................................................................................................... 85
Integrity Actions ............................................................................................................................. 87
Indexes..................................................................................................................... 88
Introduction........................................................................................................................ 88
Adding indexes ................................................................................................................... 89
Index options ...................................................................................................................... 90
Special indexes................................................................................................................... 91
Checks ..................................................................................................................... 92
Table Options........................................................................................................... 93
Transitive Persistence ............................................................................................. 94
Application-Level Cascades................................................................................................ 95
Save Cascades ................................................................................................................................ 95
Delete Cascades.............................................................................................................................. 95
Database-Level Cascades ................................................................................................... 96
Conclusion ............................................................................................................... 97
Working with Models ...................................................................................... 98
Define Test Schema ................................................................................................. 98
Dealing with Relations........................................................................................... 102
Creating Related Records ................................................................................................ 102
Retrieving Related Records.............................................................................................. 105
Updating Related Records................................................................................................ 105
Deleting Related Records................................................................................................. 106
Working with Related Records......................................................................................... 107
Testing the Existence of a Relation .............................................................................................. 107
Many-to-Many Relations ........................................................................................ 108
Creating a New Link......................................................................................................... 108
Deleting a Link ................................................................................................................. 108
Fetching Objects.................................................................................................... 110
Sample Queries ................................................................................................................ 112
Field Lazy Loading ........................................................................................................... 119
Arrays and Objects ................................................................................................ 120
To Array............................................................................................................................ 120
From Array ....................................................................................................................... 120
Synchronize With Array.................................................................................................... 121
Overriding the Constructor ................................................................................... 122
Conclusion ............................................................................................................. 122
DQL (Doctrine Query Language) .................................................................. 123
Introduction ........................................................................................................... 123
Table of Contents iv
-----------------
Brought to you by
SELECT queries..................................................................................................... 125
DISTINCT keyword........................................................................................................... 130
Aggregate values.............................................................................................................. 130
UPDATE queries .................................................................................................... 131
DELETE Queries.................................................................................................... 132
FROM clause ......................................................................................................... 133
JOIN syntax............................................................................................................ 134
ON keyword...................................................................................................................... 135
WITH keyword.................................................................................................................. 136
INDEXBY keyword................................................................................................. 137
WHERE clause....................................................................................................... 138
Conditional expressions......................................................................................... 139
Literals ............................................................................................................................. 139
Input parameters.............................................................................................................. 141
Operators and operator precedence ................................................................................ 143
In expressions................................................................................................................... 143
Like Expressions............................................................................................................... 144
Exists Expressions............................................................................................................ 145
All and Any Expressions ................................................................................................... 147
Subqueries........................................................................................................................ 148
Functional Expressions.......................................................................................... 150
String functions ................................................................................................................ 150
Arithmetic functions ......................................................................................................... 152
Subqueries............................................................................................................. 152
Introduction...................................................................................................................... 152
Comparisons using subqueries......................................................................................... 152
GROUP BY, HAVING clauses................................................................................. 153
ORDER BY clause .................................................................................................. 156
Introduction...................................................................................................................... 156
Sorting by an aggregate value ......................................................................................... 157
Using random order ......................................................................................................... 157
LIMIT and OFFSET clauses................................................................................... 158
Driver Portability.............................................................................................................. 158
The limit-subquery-algorithm........................................................................................... 159
Named Queries ...................................................................................................... 160
Creating a Named Query.................................................................................................. 161
Accessing Named Query................................................................................................... 161
Executing a Named Query................................................................................................ 162
Cross-Accessing Named Query ........................................................................................ 162
BNF........................................................................................................................ 162
Magic Finders........................................................................................................ 166
Debugging Queries ................................................................................................ 167
Conclusion ............................................................................................................. 168
Component Overview .................................................................................... 169
Manager................................................................................................................. 169
Retrieving Connections .................................................................................................... 169
Connection............................................................................................................. 170
Available Drivers .............................................................................................................. 170
Creating Connections ....................................................................................................... 170
Flushing the Connection .................................................................................................. 171
Table ...................................................................................................................... 171
Getting a Table Object...................................................................................................... 171
Getting Column Information............................................................................................. 172
Table of Contents v
-----------------
Brought to you by
剩余406页未读,继续阅读
资源评论
淡定的茶
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功