close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

example code

Thread began 9/24/2009 11:32 am by p_bywater389214 | Last modified 9/26/2009 12:09 am by anonymous | 867 views | 6 replies |

p_bywater389214

example code

Hi,

I'm wondering if you are able to provide (or if there is any already out there somewhere) example php code which the web assist extensions generate?

I would only be interested in seeing a bit as I don't even know if it is OOP or procedural. How much code is 'on-page' Vs in classes hidden away?

It would be good to see the sort of code generated (for example) on a add_product.php form page. How would the INSERT transaction look?

Hope that makes sense!
Phil

Sign in to reply to this post

tom92909Beta Tester

Filename: example_insert.php

php:
<?php require_once('Connections/db.php'); ?>

<?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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "add")) {
  
$insertSQL sprintf("INSERT INTO my_table (`number`, name) VALUES (%s, %s)",
                       
GetSQLValueString($_POST['number'], "int"),
                       
GetSQLValueString($_POST['name'], "text"));

  
mysql_select_db($database_db$db);
  
$Result1 mysql_query($insertSQL$db) or die(mysql_error());

  
$insertGoTo "example_insert.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>my page</title>
</head>

<body>

<form method="POST"  action="<?php echo $editFormAction?>" name="add">
<p align="center">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="right"><b><font face="Verdana">Number:</font></b></div></td>
    <td>&nbsp;</td>      
    <td><input type="text" name="number" size="8"></td>
  </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
  <tr>
    <td><div align="right"><b><font face="Verdana">Name:</font></b></div></td>
    <td>&nbsp;</td>      
    <td><input type="text" name="name" size="25"></td>
  </tr>
</table>
</div><br />
<div align="center">
  <input type="hidden" name="MM_insert" value="add">
  <input name="Submit" type="submit" id="Submit" value="Save">&nbsp;&nbsp;&nbsp;<input name="Reset" type="reset" value="Reset">
  </p>
</div>
</form>
</body>
</html>
Sign in to reply to this post

Eric Mittman

As you can see from the posted code example the code is mostly procedural with very little object oriented. The exception to this though would be our eCart tool which is very object oriented. Most of the eCart code you would see would rely on methods for the various objects to complete the processing. The classes and methods are defined in the include files that are available in the eCart directly where they can be read and edited.

Sign in to reply to this post

p_bywater389214

re:

Thanks guys, and thanks Eric for the explanation.

I have another question which relates to web assist files placed in your site folder when using the extensions. I actually signed up for the subscription plan the other day and and it looks like the include files are placed in directories at your site root, named after the extension you use.

Is there a way to define where all extension includes are placed? I.e can specify /includes/ as the place where all web assist folders are created?

e.g. /includes/WA_DataAssist/

Sign in to reply to this post

Eric Mittman

There is no supported way to update the include files like this. However since included files are referenced with standard include and require once statements you could change the locations of the files so long as you make sure you update any of the include file statements that reference that file. This is not something I would suggest though as it will likely be more trouble than it is worth. On the upside since it is server side code that is in the includes you do not have to worry so much about users visiting the page directly or anything like that.

Sign in to reply to this post

p_bywater389214

I tried moving the WA includes into a /includes/ folder at the root and updated all import paths. this worked fine and I can maybe continue doing this where possible.

If I then try to amend the scripts (i.e change a forms design) things break a bit but I expected that.

I'm quite fussy about keeping a neat and tidy directory structure hence wanting everything in an includes folder!
Also, if presenting the site to other developers to work on it looks more professional.

I think being able to specify a directory for all WA extension includes would be a VERY useful feature (and not too difficult?). Any chance of this being considered for future releases?

Sign in to reply to this post

anonymous

A couple of people have actually put that idea on the WebAssist wish list.

I would recommend, however, not moving the folders in the meantime. I am a lot like you about trying to keep in neat and tidy, but I found this actually (if you're not super careful) will lead to more problems. It's also nice when you update a page such as a Universal Email page, it is easier just to find the one folder and send the update rather than navigate through a folder hierarchy.

But yes, I do, as well, think it would be cool if maybe all the WebAssist stuff in the future would get added to the "includes" directory.

Cheers,

Brian

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...