RE: [ErrorSystem-devel] RE: RE: ErrorSystem - proposal
Status: Planning
Brought to you by:
sonicmctails
From: BrokenClock <bro...@fr...> - 2003-12-19 08:44:26
|
About classes : I haven't check the official PHP doc about them, but I ha= ve read something in a book. Well, it was a french book, so I will directly translate technical words frmm french, but I'm sure it wouldn't be the ri= ght words. Class is a fundamental concept of object programming. PHP is a *near* obj= ect programming langage. It means that it doesn't support all the features required to be a object programming langage, but must of them. In particular, it doesn't support polymorphism (I can't remeber what it is). In object programming, classes are abstract descriptions of objects. An class puts together properties and functions called, in this case, method= s of the object or the class. When you created an object, you must tell whi= ch is its class. A special method, called the builder, is automaticaly executed. The builder has the same name as the class. Deeper, you have mother-classes and daughter-classes (in french, classes = are female, so in english, it should be father and son). When you begin to describ a daughter-class, it is the same as its mother. This is heritage. Then you add or modify methods. So, beginning with a class, you should ma= ke a tree. One of the features of object programming does not support well, is the heritage of the builder method. It seems that a daughter-class doesn't inherit the builder method of its mother. As I understand it, I think thi= s is because PHP uses the name of the class to execute its builder method, = and the daughter-class has not the same name than its mother, so PHP doesn't execute the mother builder. I think that the daughter inherits the builde= r method, but PHP doesn't recognize it as a builder, but just as a method. To conclude, after this little boring lesson (I hope that there is someo= ne here that didn't know all that before, and I beg the pardon of the others (well, I asked for beginner programmers, after all)), I think it is a ver= y good idea to use class for DB Layer. But I must add that it will be so mu= ch better if we take advantage of all features of object programming, and no= t just consider class as a list of functions. I think we can make a db real object class. So the db layer should be able to simplify the connect to m= ore then one db. Well, to show, I take an example of what I mean. Imagine that we have already coded the db class, and see how we could use it. <? $MyFirstDb=3Dnew db("MySQL", "localhost", "user", "password"); //this line should create the object, set the typ as MySQL, the adress of the MySQL server, and all) //may we connect in the builder? Let's say so, or this example. So this l= ine should be suffisant to create the connection. $MyFirstDB=3D>CreateDB("ErrorSystem"); //this line should create the database "ErrorSystem" on the db server. //well, the things seems to be a little messy, and we have to make the things clear : there may be a confusion between server and db... $MySecondDb=3Dnew db("ProgresSQL", "192.168.45.12", "user", "pass"); //well, I think I don't have to explain more ?> In this case, we should be able to manipulate the first and the second db very simply, without confusing, and a very clear code. Well, I have a little work now, so tell me what you think and Have fun, guys, Stephane > -----Message d'origine----- > De : err...@li... > [mailto:err...@li...]De la part de > son...@ss... > Envoy=E9 : jeudi 18 d=E9cembre 2003 15:54 > =C0 : bro...@fr... > Cc : Jacek Olszak; ES-devel > Objet : Re: [ErrorSystem-devel] RE: RE: ErrorSystem - proposal > > > Actaully, this is what I've been coding as a class. I'm not sure if you > are familer with classes (the PHP documentation isn't very clear on the= m > either), but basically, it's a list of functions. So this class could h= ave > function a(), and function b(). Now to access it I would do something l= iek > this: > > <?php > class db { > function a() { > echo "test" > } > function b(){ echo test }; > } > > $db =3D new db > $db->a // function a > $db->b // function b > } > ?> > > In other words, classes let someone make a function list, then it gets > automatically prefixed. I don't like the idea of using MS-SQL, as it's > syntax is not very compatiable with MySQL, and I don't have a PC I coul= d > use to help develop it. If we need to support both without goes through > preg_replace hell to make them compatiable, we need to store the querys > for each database in seperate files and then every time we need to use = a > query, we'll load it from the query file. That way, we can make it work > with almost any database as all the queries could easily be changed, bu= t > it will make coding alot harder. > > > Ok. Could you planned when this db layer should work for MySQL? > > I think we can developp ES with it if it supports MySQL, and waiting = for > > the > > support of the ohers databases. > > Maybe should you use a prefix for your functions, something like udbl > > (Universal DataBase Layer), so you should have udbl_connect and > so on? or > > usql (Universal SQL Layer)? > > I think this particular feature should interessed other people, so ma= ybe > > you > > should find a way to published it more largely. > > About that, I may be able to test on Microsoft SQL Server soon (not m= y > > choice, you bet). > > > > Have fun, guys, > > > > Stephane > > > >> -----Message d'origine----- > >> De : Jacek Olszak [mailto:e-k...@wp...] > >> Envoy=E9 : jeudi 18 d=E9cembre 2003 13:07 > >> A : bro...@fr... > >> Objet : RE: RE: ErrorSystem - proposal > >> > >> > >> Dnia 17-12-2003 o godz. 14:07 BrokenClock napisal(a): > >> > I think it could be a very good idea. But I don't know how to > >> do it, and , > >> > in particular, how to test it. > >> I decide to write this class. It's very simple. It has methods > >> like connect(), executeQuery(), getResultsObject() etc. These > >> methods are similar to mysql_connect, mysql_query etc. but they > >> work on all databases. The class read from some.ini file the type > >> of database and when some of class method is invoke the class > >> decide what function to use (for example mysql_connect or > >> mssql_connect). > >> > >> > >> -------------------------------------------------- > >> 'Z=B3e zachowanie' wyrazem buntu m=B3odego pokolenia. > >> Widowisko muzyczne ju=BF do obejrzenia! > >> http://muzyka.wp.pl/imprezy.html?idn=3D799 > >> > >> > >> > >> > >> > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: IBM Linux Tutorials. > > Become an expert in LINUX or just sharpen your skills. Sign up > for IBM's > > Free Linux Tutorials. Learn everything from the bash shell to > sys admin. > > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id371&op=BFick > > _______________________________________________ > > ErrorSystem-devel mailing list > > Err...@li... > > https://lists.sourceforge.net/lists/listinfo/errorsystem-devel > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM= 's > Free Linux Tutorials. Learn everything from the bash shell to sys admi= n. > Click now! http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick > _______________________________________________ > ErrorSystem-devel mailing list > Err...@li... > https://lists.sourceforge.net/lists/listinfo/errorsystem-devel > |