Recent Blog Posts
Blogs ยป Archive for March 11th, 2004
Code Reuse in CF - Part One
…posted by davidjmedlock:
Well, in about 7 hours I’m going to be on a plane to Salt Lake City, Utah for my first snowboarding trip. I’ve never been snowboarding or skiiing, so this should be interesting. I just hope I don’t break any important members. (I can live with a broken leg. A broken arm might impede my ability to code, though, and I don’t think worker’s comp will cover it.)
Anyway, before I leave Nashville for the weekend, I wanted to post a brief blog on code reuse. I asked a while back what you all wanted to see in my blogs and articles and one reply was that you’d like to see something about creating custom tags. So, here you go. This will be a pretty brief description of how to create a simple tag, but I think you’ll get the point, and I’ll write more on it when I get back.
First of all, any CFM file can be a custom tag. Try the following exercise. Create a file called “customtag.cfm”. Inside that custom tag, do this:
#Attributes.Hello#
Save it to …
A taste of projects to come with PHP5
Just drawing attention to some interesting projects written specifically for PHP5.
First up is cowiki which, despite being only on release 0.3.x, has already proved a hit and powers the phpCommunity site. The code is very well organised, packed with patterns and it’s clear the author knows Java. There doesn’t seem to any reliance on other PHP libraries so wheels are getting re-invented but, as such, it makes an interesting study for anyone looking for tips on how to put PHP5’s new features into use. It’s a little too Java inspired for my taste for example there’s a base class “Object” - for thoughts on those lines read PHP Application Design Concerns. Each to their own of course and perhaps having some additional abstractions built in helps while PHP5 itself is still a moving target.
Another two interesting projects can be found over at http://www.phpdb.org.
First is Creole, a database abstraction library written specifically for PHP5 and modelled after Java’s JDBC. This will definately pull a Java crowd and the code is, again, very well organised. Here’s a sample of connecting performing a query;
$dsn = “mysql://dbuser:dbpass@localhost/testdb”;
$conn = Creole::getConnection($dsn);
$rs = $conn->executeQuery(”SELECT id, name FROM users”);
while($rs->next()) {
echo $rs->getString(”name”) …
Sponsored Links
SitePoint Marketplace
Buy and sell Websites, templates, domain names, hosting, graphics and more.
Download sample chapters of any of our popular books.




