Use Zend_Db to replace propel and doctring data abstraction layer (1)
'2017. 0.0.1 ', 'username' => 'root', 'password' => 'sa', 'dbname' => 'test'); $ dbh = Zend_Db :: factory ('pdo _ mysql', $ params); Zend_Db_Table: setdefaadapter adapter ($ dbh ); // set the default adapter for all Zend_Db_Table objects. // you only need one Db object and one adapter object. // no-mvc mode is used here if it is a standard zend application // even the adapter does not require ZEND_CONSOLE to complete the work class Albums extends Zend_Db_Table {}# you can do nothing to directly use the Zend_Db_Table # method crud... // Next let's assume that the connected database has a music list named albums $ albums = new Albums (); echo "test get the data from test. from MySQL-5.5.m6
"; // The result set returned by rs is a default Zend_Db_Table_Row object foreach ($ albums-> fetchAll () as $ row) {echo"". Htmlspecialchars ($ row-> id)." ". htmlspecialchars ($ row-> artist)."'s ". htmlspecialchars ($ row-> title ).".
\ N "; $ row-> save ();}/** 1 student friend's, she came to my concert. 2 Huang Xiaoyu's is not that simple. 3. 4 Wang Feng's spring. 5 Paolo Nutine 'ssunny Side Up.6 Andre attack' sHeligoland. 7 Beatles 'simage. 8 Beatles 'shey Jude.9 Faye Wong-"you Faye Wong so I Faye Wong"'s red beans, because of love. 10 Johnny depp's arrival in London. * /// now we can modify the tenth data record to change London to the green fariy // It is easy to modify the row data: you only need to modify the class attributes according to the general method. call the save () method to save the changed result to the data table. // There are many ways to do this, such as declaring a new // Zend_Db_Statement, but I like the simple method $ row = $ albums-> fetchRow ('Id = "10 "'); $ row-> title = 'The Green Fairy, I like UK-London style'; $ row-> save ();/** test get The data from test. albums from MySQL-5.5.m61 Zhang Xueyou's coming to my concert. 2 Huang Xiaoyu's is not that simple. 3. 4 Wang Feng's spring. 5 Paolo Nutine 'ssunny Side Up.6 Andre attack' sHeligoland. 7 Beatles 'simage. 8 Beatles 'shey Jude.9 Faye Wong-"you Faye Wong so I Faye Wong"'s red beans, because of love. 10 Johnny Depp' sThe Green Fairy, I like UK-London style. * **/$ row = $ albums-> find ('3'); $ row [0]-> title = "Chrysanthemum's Summer"; // note: row itself is a Zend_Db_Table_RowSet set $ row [0]-> save (); # However, the set is an array mapped to a single element or a row object has save () method // more and more like simple things such as VIM such as PHP Python // There is only one thing to note. you cannot modify the ID. this will throw an exception at the DB level/*** test get the data from test. albums from MySQL-5.5.m61 Zhang Xueyou's coming to my concert. 2 Huang Xiaoyu's is not that simple. 3. the summer of Jiu Shi's chrysanthemum. 4 Wang Feng's spring. 5 Paolo Nutine 'ssunny Side Up.6 Andre attack' sHeligoland. 7 Beatles 'simage. 8 Beatles 'shey Jude.9 Faye Wong-"you Faye Wong so I Faye Wong"'s red beans, because of love. 10 Johnny Depp' sThe Green Fairy, I like UK-London style **/