Dreamweaver vs Homemade Classes

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Arocity
Forum Newbie
Posts: 15
Joined: Tue Jun 10, 2008 8:30 am
Location: Washington, DC

Dreamweaver vs Homemade Classes

Post by Arocity »

I recently started developing a site for my company using Dreamweaver. Of course we're using a MySQL db, so I found a really good db class to use for all my querying. Like most of these types of classes, its OO, so it's something like $db->get_var(the query) to get one value or just $db->get_results(the query) to get multiple rows and I just refer to each value in a foreach.

I've used Dreamweaver for a while but I just started dabbing in the built-in database functions. I successfully connected and started playing around and adding recordsets, but I really don't see the advantage of using it. Anybody run into problems using a DB class? Or any advantages of using Dreamweavers fancy smancy functions?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Dreamweaver vs Homemade Classes

Post by pickle »

Using a database class has done nothing but good for me. It cleans up the code a bit & makes it easy to change between databases.

I've never used the Dreamweaver built-in functions so I can't definitively speak to their quality. However, I'd imagine they were built to be useful to as wide a set of people as possible, so there may be some extra functionality you don't need or some optimizations that could be done.

If you're not comfortable building your own database class, use the built-in Dreamweaver code - it's better than raw database functions.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Dreamweaver vs Homemade Classes

Post by superdezign »

I haven't used DW in a long time, but last I remember, it only provided pre-written code, like a mysql_connect() and a mysql_select_db() call. I'd suggest using a database wrapper class over DW's auto-built stuff.
User avatar
Arocity
Forum Newbie
Posts: 15
Joined: Tue Jun 10, 2008 8:30 am
Location: Washington, DC

Re: Dreamweaver vs Homemade Classes

Post by Arocity »

I'm already currently using a database class (EzSQL for anyone interested). I just wondered if it was worth the trouble of migrating to DW's tools instead of staying with my class. One of the benefits I did see with DW is that you can get a recordset back using test data. It lets you create "filters" by setting column values to different variables(URL parameters, form vars, session vars, cookies, server values, or entered values). I attached the DW-generated code for a simple query.

Code: Select all

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
 
$colname_Recordset1 = "-1";
if (isset($_SERVER['em_id'])) {
  $colname_Recordset1 = $_SERVER['em_id'];
}
mysql_select_db($database_OneStop, $OneStop);
$query_Recordset1 = sprintf("SELECT * FROM employees WHERE em_id = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $OneStop) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Dreamweaver vs Homemade Classes

Post by superdezign »

DW's tools seem more geared towards those with little programming experience, and handles a lot of the work for you. That usually means that the flexibility of using them is limited. But if it's easier for you, then go for it.
User avatar
Arocity
Forum Newbie
Posts: 15
Joined: Tue Jun 10, 2008 8:30 am
Location: Washington, DC

Re: Dreamweaver vs Homemade Classes

Post by Arocity »

Nah. It doesn't get any easier than EzSQL. [No] Pun intended.
Post Reply