Công nghệ thông tin
Overview of Components - Sơ lược về Com | Overview of Components - Sơ lược về Com |
|
|
|
| 23/11/2007 | ||||||||||
Trang 6 / 8 Database Class HandlersFrom Mambo ManualIn Mambo we provide a special class that relieves the developer of a lot of low level database work on tables. This special class is called mosDBTable and will have already been declared for you. You don't use this class directly. In Object Oriented Programming (OOP) terms it's called an Abstract Class. We use this class to derive a new class which we will call mosInOut. Create a file called mrx_inout.class.phpin the / /components/com_mrx_inout directory. Copy the following code into it and then we'll look at what is happening in this file. 1: <?php /* $Id: components.xml,v 1.6 2004/08/23 16:19:44 rcastley Exp $ */ Line 18: This line shows us the syntax for deriving a class in PHP. This tells PHP to create a class called mosInOut based on the existing class mosDBTable. Our class will 'inherit' all the properties and methods in the mosDBTable class. We could redefine all of them if we wanted to, but most have been written generically so that you don't. Only functions that work on information peculiar to your database table will be required to be 'overrided' (for example, the 'check' method). Line 19−36: All the comments in these lines are written in a format that an application called phpDocumentor can parse. We'll talk about this at the end of this book. In between the comments are a number of class variable declarations. What variables do I declare? That's easy. Declare a variable for each field in your database table. Make sure all the variables match the field names. Also make sure you set each variable to null otherwise problems will arise in some versions of 4.1.x of PHP. Lines 41−44: We need to create a class constructor method. This MUST be the same name as the class (you will often get errors or experience unusual behaviour if you forget). Line 43: To complete the construction of your class, you invoke the base class's constructor, passing it the name of your table, the primary key of your table and the database connector. Tin mới hơn:
Tin cũ hơn:
|
||||||||||
| Liên kết Webs |
| Why's luyenkim.net |
| Woman Calendar |
| Cà phê chiều thứ 7 |
| Từ điển LạcViệt Online |
| Kulkul's world |
| www.xahoihoctap.net |
| www.paper.edu.cn |
| Học tiếng Anh online |
| Danh bạ ĐT cố định |
| Online dictionary |
| Tivi Online |
| - - - - - - - |
| Tin thể thao |
| Dân trí |
| Tiền phong |
| Người lao động |
| - - - - - - - |