Your opinion needed
| From: | Ryan A | Date: | Thu, 15 May 2003 09:13:31 +0000 |
| Subject: | Your opinion needed | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-147676@lists.php.net to get a copy of this message | ||
Hi,
I have just started working with Dreamweaver MX -> PHP/MySql and need your
opinion.
The advanage of using DWMX with PHP/MySql is of course speed, I can write
scripts to insert/delete/edit etc in seconds and they execute perfectly with
or without magic_quotes or globals, this would normally take me an hour or
more, those headaches are taken away from me *BUT*
for every little operation (insert/delete etc) it writes around double or
more of what I would normally write (bloatware...?)
My question is....do you think it is worth it? or should i go back to
writing everything by hand in its codeview/notepad/some editor??
Most of you guys are more experienced than me in PHP so.....your opinion
needed.
To give you an example of what i mean here is the code that was generated
for me to do a simple insert into 2 fields of a table, the database/php etc
is on my local win2000 machine, not on the web.
<?php require_once('Connections/test.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'"
: "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) .
"'" :
"NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'"
: "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue :
$theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) &&
($HTTP_POST_VARS["MM_insert"]
== "form1")) {
$insertSQL = sprintf("INSERT INTO countries (country_code, country_name)
VALUES (%s, %s)",
GetSQLValueString($HTTP_POST_VARS['country_code'],
"text"),
GetSQLValueString($HTTP_POST_VARS['country_name'],
"text"));
mysql_select_db($database_test, $test);
$Result1 = mysql_query($insertSQL, $test) or die(mysql_error());
$insertGoTo = "countries.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
Kindly reply.
Cheers,
-Ryan.