Re: Database Tables and Classes

From: Date: Tue, 14 Nov 2000 13:27:38 +0000
Subject: Re: Database Tables and Classes
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-4421@lists.php.net to get a copy of this message
I don't know if I'd call it wisdom, but... I'm unsure how *exactly* you'd do it in PHP (I'm new to PHP), but in Smalltalk I created an abstract class called RowAbstract (it used to be TableAbstract but I changed it). RowAbstract defined class methods for: table (returns an array of the tables used to create the row) whereClause (returns the text of a where for creating a row -- usually a join if mutiple tables are involved) columns (returns an array of the columns you want selected) database (which database name the tables are from) Each subclass of RowAbstract defined a table row with its unique parameters. To instantiate an array of rows (which is what a table is) I use something like: list := ContractRow where: nil using: anExternalDBConnection nil - since I want all rows there is no 'where' clause. anExternalDBConnection is the connection object to the database. After this, list is my array of ContractRow objects. I changed the name because the result of projections from the table is not another table, but an array of rows, each of the rows being one ContractRow (that is, a row from my Contract table). If you (or anyone else) wants more information I can email you the code so you can see exactly how it works. As long as PHP doesn't have screwy rules like Java does the translation from Smalltalk to PHP shouldn't be that difficult--at least not in an idiomatic way. LP wrote: > I am considering creating a Class, for > each of my database tables, that will perform > all sql calls for each particular table. > > Does anyone have any wisdom on this thought? > > LP > > __________________________________________________ > Do You Yahoo!? > From homework help to love advice, Yahoo! Experts has your answer. > http://experts.yahoo.com/ > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- .tom

« previous php.db (#4421) next »