[Typo3-dev] DBAL - how to do it?

"Kasper Skårhøj" kasper at typo3.com
Mon Feb 16 11:35:28 CET 2004


I see.

Thanks.



God bless

- kasper

*********** REPLY SEPARATOR  ***********

On 16-02-2004 at 11:18 Michael Zedeler wrote:

>Kasper Skårhøj wrote:
>>>Another thing: DBAL is being seen as the ability to switch databases 
>>>seamlessly. I see that part as the *least* important feature. Security 
>>>and better support for object persistence is by far the greatest
>benefits.
>> 
>> I don't know what object persistence is.
>
>Roughly speaking, object persistence means that when we fetch data from 
>the database, each row is encapsulated into an instance of a class. This 
>means that we're suddently able to manipulate data from everywhere 
>without worrying about how it is being stored.
>
>In stead of
>
><?php
>...
>$query = "SELECT * FROM fe_users WHERE age > 12 AND age < 30";
>$res = mysql(TYPO3_db,$query);
>while($row = mysql_fetch_assoc($res))  {
>	echo $row["name] . "<br>";
>}
>...
>?>
>
>I can go:
>
><?php
>...
>$person = new DataObjects_Person;
>$person->whereAdd('age > 12');
>$person->whereAdd('age < 30');
>$person->find();
>
>while ($person->fetch()) {
>     echo $person->name. "<BR>";
>}
>...
>?>
>
>(The example above is from the PEAR manual.)
>
>The variable $person is now a real object instance that can implement 
>methods that would normally be hidden in a module - inaccessible to 
>other modules. Examples of methods for a person object could be:
>
>check_password($password, $format)
>
>Check the password $password in format $format ("plaintext", "MD5" and 
>so forth).
>
>send_new_password()
>
>Sends a new passsword to the person.
>
>join_group($gid)
>
>Joins group with uid $gid.
>
>leave_group($gid)
>
>Leaves group with uid $gid.
>
>enable()/disable()
>
>Enables/disables user account.
>
>By doing this, it is much easier to reuse code provided by other 
>extensions, since you don't have to worry about how the data is being 
>stored. You simply fetch the object in question and call the method you 
>need. Thats it. PEAR takes care to put the data back into the database 
>for you.
>
>Thats what I would call object oriented programming. What we have now is 
>only object orinted on a fairly coarse-grained level where the full 
>potential isn't realized.
>
>PEAR provides everything neede to make fairly complex queries, but 
>certain really exotic things won't be possible, though. Take a look at 
>the PEAR introduction at
>
>http://pear.php.net/manual/en/package.database.db-dataobject.intro-purpose.php
>
>>>As I sketched in my previous post, the task is getting bigger as time 
>>>goes by, so I think it would be a good idea to make a descision whether 
>>>to do it or not. Since it is a fairly big change that needs many hands, 
>>>it is important that everybody agrees to go for it.
>> 
>> It doesn't need many hands, it needs a clear head that does not make one
>single mistake in the process.
>
>I agree in the case that DBAL is merely a subsystem that can switch 
>databases. If that is what you see the DBAL as, then it is fairly easy 
>to implement and also - not really worth the while. What I am aiming at 
>is an abstraction layer that provides object persistence as above and 
>security.
>
>Again: I am willing to do some real coding if this is put on the agenda 
>for an upcoming version.
>--
>velkommen til det muntre køkken!
>Dagens ret: pasta med silde-banansovs.
>Æblegrød med leverhejs til dessert.
>_______________________________________________
>Typo3-dev mailing list
>Typo3-dev at lists.netfielders.de
>http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev



God bless

- kasper
- kasper

--------------------- o ---------------------
"Mange kokke fordærver maden."
"En fugl i hånden er bedre end ti på taget."








More information about the TYPO3-dev mailing list