Chức năng printXml ($ input) {echo''; print_r (htmlentities (đầu vào)); tiếng vang ";} Sau đó, bạn có thể thiết lập các dump_options $ mảng: $ dump_options = array ('đầu ra' = 'printXml'); Tham số thứ ba dumpDatabase () cho phương pháp những gì bạn muốn bán phá giá cấu trúc, dữ liệu trong các bảng, hoặc cả hai. Điều này được định nghĩa với một hằng số các tùy chọn có sẵn là: | Chapter 1 function printXml input echo pre print_r htmlentities input echo pre Then you can set the dump_options array dump_options array output printXml The third parameter to dumpDatabase tells the method what you want dumped the structure the data in the tables or both. This is defined with a constant where the available options are MDB2_SCHEMA_DUMP_STRUCTURE MDB2_SCHEMA_DUMP_CONTENT MDB2SCHEMADUMPALL As the API docs say the getDefinitionFromDatabase method is an attempt to figure out the definition directly from the database and sometimes it may require some manual work to make the definition exactly as you want. Switching your RDBMS Suppose you decide to move your application from using a MySQL database back end to SQLite or simply want to test how portable your application is . You can have MDB2_Schema do the database structure and data transition for you. Let s say you ve created your database dump as shown above and you have your file. All you need now is a new DSN to connect to SQLite one method call to parse the XML file and extract the database definition from it and a method call to create the new database. dsn2 sqlite schema2 MDB2_Schema factory dsn2 definition schema2- parseDatabaseDefinitionFile schema2- createDatabase definition 49 MDB2 For this simple type of transition you don t necessary need the XML file and can work with only the database definition array. The whole transition can be done in one line assuming you have your two Schema instances ready schema2- createDatabase schema- getDefinitionFromDatabase Summary In this chapter you were presented with an introduction to the MDB2 database abstraction layer. You saw the challenges faced with database abstraction and how they are handled in MDB2. You learned how to install MDB2 instantiate an MDB2 object and use some of the most common methods. You also learned how MDB2 is built with extensibility in mind and about the existing modules. There were also a few examples of how you