[plug] Advocacy request, reference guide, PHP/MySQL

Leon Brooks leonb at bounce.networx.net.au
Tue Nov 16 15:09:11 WST 1999


Oliver White wrote:
> I'm negotiating with a friend in Sydney about some work. The project
> involves putting a reference guide on the web - a job for Zope/PHP,
> mySQL and linux, it would seem. They're an NT shop right now, but it
> would seem that an open source solution would be much cheaper and
> reliable.

> The main question I want to be prepared for is "What about
> administration costs?". Can anyone help me out with cost comparisons?
> (Did somebody say Total Cost of Ownership?)

Plug in the ext3 file system (rpmfind.net runs on it) plus backup
regularly in case a disk goes too fast and *all* of the bits slide off
the edge and onto the casing... beyond that, your administration should
basically amount to the usual editorial stuff, which would be about the
same (except for downtime due to crashes and invasion by self-righteous
crackers offended by your content) no matter what system you use.

Bear in mind that MySQL costs $US200 unless they install it themselves
(e.g. plug in a Mandrake 6.1) but is circa 3x as fast as PostGreSQL,
which is free (and IMHO much *easier* to use as it come close to being
faithful in (e.g.) transactions, whereas MySQL doesn't even try).

Further comment on maintenance, I've never had to maintain either
PostGreSQL or MySQL as I've never had one of mine break, other than as
part of a total disk crash (smoked the disk in one case, power failure
while writing got the root directory, several home blocks and a chunk of
the bitmap in the other case), which equals fresh install. Both have
utilities for scraping off their data in semi-portable text form.

It's not too hard to write a simple interface layer so PHP can use
either (see attached), although you have to be very general in your use
of fields (e.g. can't use PostGreSQL's SQL-92-compliant CONSTRAINT
attribute on a field because MySQL doesn't do that; can't use MySQL's
AUTOINCREMENT attribute because nothing else supprts that; need to use
two different pieces of SQL to create a table structured after another
table, and so on).

Oracle, it ain't. (-:
-------------- next part --------------
<?php
# MySQL wrapper
# establish a connection to the database server
# $database parameter is used by other systems (e.g. PostGreSQL) but not here
function db_connect ($host, $database) {
	return mysql_connect ($host);
}

# close something opened by db_connect() - usually not needed but done
# for completeness and "just in case"
function db_close ($conhandle) {
	return mysql_close ($conhandle);
}

# do a SQL query
# other systems ignore $database here
function db_query ($conhandle, $database, $query) {
	return mysql_db_query ($database, $query, $conhandle);
}

# return number of rows which resulted from a query
function db_rows ($qryhandle) {
	return mysql_num_rows ($qryhandle);
}

# fetch row as an object, $row is ignored in mysql, but is always supplied
# by YakBak as an index to the correct row number (0, 1, 2, etc) for those
# databases which require it.
function db_fetchrow ($qryhandle, $row) {
	return mysql_fetch_object ($qryhandle);
}

# free the memory used by a query result
function db_free ($qryhandle) {
	return mysql_free_result ($qryhandle);
}

# return an error string about the last action on this connection
function db_error ($conhandle) {
	return mysql_error ($conhandle);
}
?>


More information about the plug mailing list