[file] yii-dblayer.pdf [notes] ### 3 abstraction -> making things simpler by hiding complexity - also hiding boilerplate -> faster code writing abstraction allows to structure code differently -> reuse of code and MVC separation also DB agnostic, good for things like CMS and other open source software Abstraction can help writing more secure code, mainly SQL injection ### 4 - DAO = Connection, plain SQL and low level abstraction for insert, update, delete - QB = building SQL from PHP code - AR = Mapping an Object in PHP to a table in the DB in Yii layers are build on top of each other, higher can not function without lower. Command, Connection, ... is used by Query, Query and ActiveQuery are even tightly coupled, as AQ extends Q. TODO read about ORM vs. AR ### 5 uses PDO in the background. why PDO? connect to different DBMS through same interface why not PDO directly? -> master/slave, yii config, service locator, events, ... ### 6 Other things this layer has that PDO has not ### 7 ### 8 Query builder recognized subquery. Like this example. same in select, from, join, where, union. ### 9 - call a function instead of creating strings 1. easier 2. lower risk of SQL injection - create query with default values in one place - adjustments in other places ### 11 ### 18 common interface is used by dataprovider and translated to system specific commands. NoSQL system specific commands are added. Because of the design of AR relations, return a query, we can declare relations between SQL and NoSQL ### 19 Somethimes abstraction is not flexibile enough. ### 20 Jobs: ask me \smiley