Forums

PHP

This topic is locked

PHPLib abstraction layer in DWMX

Posted 03 May 2002 00:42:06
1
has voted
03 May 2002 00:42:06 Dylan Marks posted:
I haven't actually had a chance to check out the sort of code that DW MX outputs for PHP, but am certainly happy that it is now supported. I've always used Ultradev as my glorified text editor for writing PHP.

I don't know how many of you here are familiar with PHPLib, and database abstraction classes, but they are a means of placing database-specific PHP code into a class definition that can be easily changed.
So if I'm currently using MySQL and want to switch my database to PostgreSQL, I merely have to change the class I'm using, and not have to go through pages of MySQL specific code.

You can read more about it here:
www.devshed.com/Server_Side/PHP/Class/page1.html

Anyhow, all of this to say that I would think something such as PHPLib would have been the perfect coding practice for DW MX. Clean concise code, simple to switch between database models, etc, etc.

My question: does anyone have an idea as to the difficulty in writing my own extension that would allow for such an abstraction layer?

If not, then I suppose Dreamweaver will continue to be a text editor (with albeit fantastic new color highlighting).
<font face='Arial'></font id='Arial'>

Replies

Replied 03 May 2002 12:46:49
03 May 2002 12:46:49 Tim Green replied:
DB Abstraction layers have already been used quite successfully with UltraDev 4 and the PHAkT PHP Server model.

In that case, the abstraction library used is ADODB, which in many ways is far superior (in my opinion) to PHPLib.

Why didn't MM use these libraries? Well, it's a technicality really, but if they were to use a 3rd party class library, they would have to support it. Which isn't really on.

Following from Interakt's public announcements of PHAkT 2 and ImpAKT 2 PHP Server Models for DWMX (bringing the PHP Server Model count to 3), I publicly declared that I would only be supporting the native DWMX server model.

Of course, this means filling in the gaps, and making the DWMX PHP Server Model a complete tool for every PHP developer.

To this end I have committed to the development of a database abstraction system for DWMX, so that PHP users aren't limited by MySQL databases.

At the moment, this is all very much in the planning stages, but there will be an announcement soon, for a mailing list regarding this project should you wish to participate.

I have also submitted a project application at www.sourceforge.net, as I am committed to making this an Open Source solution, relevant to everyone.

All the best

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 03 May 2002 16:23:17
03 May 2002 16:23:17 Dylan Marks replied:
Thanks for your reply, Tim. What you've talked about sounds really exciting. I would be interested in participating; I've never written an extension before, but since I've been using others for so long, it's about time I give back.

You're right that ADODB is another sort of abstraction, but as I understood it, a slower one than using the PHP specific commands. Perhaps the main reason I like PHPLib (or more exactly the DB_Sql class, which is the only thing I use from the library) is that it cuts down on typing for me.

For example to print out a quick list of names:

<pre id=code><font face=courier size=2 id=code>$sql="Select name from competitors";

$db=new DB_Sql();
$db-&gt;Debug=1; //turn on debugging

$db-&gt;query($sql);
while ($db-&gt;next_record()) {
$db-&gt;p("name";
}
</font id=code></pre id=code>

Behind the scenes, since I'm using MySql, the class uses the optimized MySql specific functions. But I could easily switch to a PostgreSQL version of the class and use those optimized functions. Using ADODB would really limit your abilities, because ADODB doesn't support wonderful functions like mysql_insert_id() to retrieve the last record inserted.

I'm not quite sure exactly how everything works behind the scenes in Dreamweaver though. Would somehow integrating this sort of class with Dreamweaver require it to be another 'server model'?

If so, then I agree, there is enough fragmentation for extension developers already.<font face='Arial'></font id='Arial'><font face='Times New Roman'></font id='Times New Roman'>
Replied 03 May 2002 23:29:53
03 May 2002 23:29:53 Waldo Smeets replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>I have also submitted a project application at www.sourceforge.net, as I am committed to making this an Open Source solution, relevant to everyone.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

This is getting interesting Tim. Can you tell me more about it. And how/why should it be better/different from what InterAkt is doing for example?

I'm very curious...

Waldo Smeets -- www.UDzone.com Co-Founder
------------------------------------------
UDzone.com: The site for Macromedia
Dreamweaver UltraDev Developers!
Replied 05 May 2002 00:21:59
05 May 2002 00:21:59 Tim Green replied:
Dylan,

The methods you describe are virtually identical to the ADODB method, you really should take a look at their site, as the way that ADODB works, it uses the native PHP commands for the specific database also.

Your example, as far as ADODB is concerned would read:-

$sql="Select name from competitors";
$rsName = $conn-&gt;Execute($sql) or DIE($conn-&gt;ErrorMsg()); // $conn being a connection include file
while (!$rsName-&gt;EOF) {
echo $rsName-&gt;Fields("name";
}

The other added advantages with ADODB (which have thus far NOT been exploited by PHAkT) are Recordset Paging, Cached Recordsets and Limited Recordsets. There is far far more too. More info at php.weblogs.com/ADODB



Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 05 May 2002 00:33:39
05 May 2002 00:33:39 Tim Green replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>

This is getting interesting Tim. Can you tell me more about it. And how/why should it be better/different from what InterAkt is doing for example?

I'm very curious...
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

OK. The project is now registered at Sourceforge. You can find the project site at phpmxdb.sourceforge.net

This project is fully adopting an Open Source licence, using the same licence type combination that the ADODB libraries have adopted. So, what does this mean? Well basically, the intellectual property rights are fully covered, but developers wishing to use the code for the creation of free or commercial extensions, are completely free to do so, provided that they make mention of the PHPMXDB project.

So why do this?
The answer to that one is quite simple. This is to allow ALL extension developers, the ability to take advantage of the system without having to worry about royalties, or anything like that. They are free to use/modify the code, provided that they give a clear indication as to where the code originated.

As some of you might not appreciate, when creating extensions, from time to time, it is necessary to rework some existing code, to obtain the functionality that you need. Under a purely commercial license you would have to pay for that privelidge. Under the GPL, you could freely modify the code, but you could not distribute it, without the consent of the author (at least that is my interpretation of it, correct me if I'm wrong). The problem with the GPL though, is that if you decide to develop a commercial extension, then you can't use the code. At all. Which could cause problems for many.

Now, onto the project. PHPMXDB is winning the support of extension developers who want to build extensions for the PHP Server Model, but who have been deterred for the simple reason that each new PHAkT release has broken something. This has unfortunately made PHP extensions rather high maintenance, which is understandable.

The project, as envisioned will use the ADODB libraries (as did PHAkT) to provide database independance to the native PHP Server Model in DWMX.

It's still early days yet, but we are winning support. It is our belief that concentrating on the development and enhancement of the native DWMX PHP Server Model, all developers will have a stable foundation to build on, that will ultimately bring the end user the ultimate in functionality and felxibility (not to mention better support).

If anyone has any specific questions, then please don't hesitate to post here.

All the best

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 05 May 2002 10:38:23
05 May 2002 10:38:23 Waldo Smeets replied:
So this means that you first will develop a solid conceptual PHP model and then turn it into DWMX extensions? But then how will it remain DWMX compatible? How does it compare to PHAkt (other than that it's promised to be more solid)?

Waldo Smeets -- www.UDzone.com Co-Founder
------------------------------------------
UDzone.com: The site for Macromedia
Dreamweaver UltraDev Developers!
Replied 05 May 2002 22:06:40
05 May 2002 22:06:40 Tim Green replied:
Well Waldo,

This project does not mean the development of a new PHP Server Model. That would be ludicrous, as then there would be 4 PHP Server Models.

No, instead, this project is looking to add the database independence to DWMX <u>without</u> re-inventing the wheel.

Instead, what we will be doing will be filling in the gaps, and providing a new connection method, and the code necessary to make the existing behaviors Database independant.

Compatability won't be an issue with DWMX. My hope is that on the surface, the only difference you, or any other developer will notice, is that there is an different connection to use, as when using the existing behaviors it will insert the db independant code instead (when using the db independant connection).

This will be done without touching any of the DWMX standard files, so that if DB independance isn't important to you, then you will still be able to use the MySQL Connection and your behaviors as before.

It's difficult to compare to PHAkT, as the project hasn't released any files yet, but the general aim is to use the fact that this will be built onto the existing PHP Server Model in DWMX, which will be a solid and stable core, and therefore offer a much greater degree of stability.

What this brings with it, is the security of knowing that all behaviors developed by 3rd parties will remain functional. This has been one of the problems with PHAkT, in that they cannot guarantee that a new release of PHAkT won't break existing behaviors. In fact, the reality is, that this has often happened (I think Tom Muck has had to update his Horizontal Looper behavior 5 or 6 times for this very reason).

Ultimately, this lack of stability across versions has meant that PHP users have been deprived of great extensions by people like Tom Muck and Massimo Foti, whom are now backing this project.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 05 May 2002 22:19:15
05 May 2002 22:19:15 Waldo Smeets replied:
Thanks for the explanation Tim. Even though I lack the technological skills I understand what the goal is: achieve database independancy without modifying any existing Dreamweaver MX extensions. Cool!

Waldo Smeets -- www.UDzone.com Co-Founder
------------------------------------------
UDzone.com: The site for Macromedia
Dreamweaver UltraDev Developers!
Replied 07 May 2002 02:19:52
07 May 2002 02:19:52 Dylan Marks replied:
You're right, Tim. ADOdb is most certainly a better library, and I'm converted. I'll definitely use this one for the next site I do.

Heh. I think I was getting ADOdb mixed up with something else.

Thanks for the info!


Reply to this topic