[plug] Database advice - Newbie

Onno Benschop onno at itmaze.com.au
Tue Jun 24 11:59:39 WST 2003


On Tue, 2003-06-24 at 11:43, James Devenish wrote:
> In message <1056418022.1025.33.camel at latte.internal.itmaze.com.au>
> on Tue, Jun 24, 2003 at 09:27:02AM +0800, Onno Benschop wrote:
> > Being someone who uses only PHP to do database work, I can tell you that
> > I've not seen any issues with trustworthiness and I must confess that
> > getting something working in PHP is trivial.
> 
> I must be missing something. I've found (and perhaps because my
> experiences are coloured by what it was like when working with DBs under
> PHP in 1999/2000) that I can act like a "d*mb bl*nde" when using JDBC
> and the consequences are correct all round (incl. the back end, which I
> don't directly touch with my Java code). With PHP, I find I have to "set
> the scene" and really cross-check what's going on (have been bitten
> repeatedly). Also, some of my early JDBC experience included a query
> construction "kit" (if I can call it that) which was really smooth
> compared to trying to manipulate SQL queries. I especially don't like
> constructing SQL text queries with PHP (is there another way?).

Now I'm missing something.

I' not sure what you're asking here, probably because I'm not familiar
with JDBC because I swore-off Java as another evil ploy to introduce OOP
into my life :-)

A simple Hello World in PHP would look like this:

<?
	$dbHost = "mysql_host" ;
	$dbUser = "mysql_user" ;
	$dbPass = "mysql_password" ;
	$dbFile = "my_database" ;

	mysql_pconnect($dbHost, $dbUser, $dbPass) ;
	mysql_select_db($dbFile) ;

	$select = "SELECT * FROM my_table";
	$dbResult = mysql_query($select) ;

	while ($row = mysql_fetch_array($dbResult)) {
		echo implode("\t",$row)."\n" ;
	}
?>

(Yes, there is error checking missing and we don't do anything other
than output the raw data.)

Given this, what does it look like in JDBC?

Onno Benschop 

Connected via Optus B3 from S33:37'33" - E115:07'30" (Dunsborough, WA)
-- 
()/)/)()        ..ASCII for Onno.. 
|>>?            ..EBCDIC for Onno.. 
--- -. -. ---   ..Morse for Onno.. 

Proudly supported by Skipper Trucks, Highway1, Concept AV, Sony Central, Dalcon
ITmaze   -   ABN: 56 178 057 063   -  ph: 04 1219 8888   -   onno at itmaze.com.au



More information about the plug mailing list