Location: PHPKode > scripts > PHP or Java Class Code Generator > php-or-java-class-code-generator/programtemplates/template_php5_code_generator.html
<?php
/*
 CODE GENERATED BY: GRAFXSOFTWARE CODE GENERATOR
 http://www.grafxsoftware.com
====================================== 
 CLASS MADE BY: {AUTHOR}
 DATE: {DATE}
 PROJECT: {PROJECT_NAME}
 PHP: version 5.x
======================================
*/

/*

${CLASSVAR}=new {NAME}();
   
<!-- BEGIN DYNAMIC BLOCK: getfunctionsvar -->
${CLASSVAR}->get{FUNC_NAME}();
<!-- END DYNAMIC BLOCK: getfunctionsvar -->

<!-- BEGIN DYNAMIC BLOCK: setfunctionsvar -->
${CLASSVAR}->set{FUNC_NAME}();
<!-- END DYNAMIC BLOCK: setfunctionsvar -->

${CLASSVAR}->save();


*/

/**
*
* @author - {AUTHOR}
* @desc -
* @vers - 1.0
*/
class {NAME}
{
 <!-- BEGIN DYNAMIC BLOCK: row -->
{TYPE}  ${VARIABLES};
 <!-- END DYNAMIC BLOCK: row -->

/**
*
* @author - {AUTHOR}
* @type - public
* @desc - Constructor
* @param  $ - string ${IDCLASS} - the ID
* @return - mixed rewrite array
* @vers - 1.0
* @Mod -
*/
function {NAME}(${IDCLASS})
	{
		
		
	 if(${IDCLASS}<>0)
	  {
	
		$this->{IDCLASS} = ${IDCLASS};


		$SQL = " SELECT {LIST} FROM {DBNAME}  WHERE `{IDCLASS}`='".$this->{IDCLASS}."'";
		$retid = mysql_query($SQL) or die($MYSQL);

		if ($row = mysql_fetch_array($retid))
		{
			
		 <!-- BEGIN DYNAMIC BLOCK: value -->
 	 	  $this->{FIELD_NAME} = $row["{FIELD_NAME}"];
         <!-- END DYNAMIC BLOCK: value -->
	
		}
		else
		{
		
		 <!-- BEGIN DYNAMIC BLOCK: nullvalue -->
 	 	  $this->{FIELD_NAME} = "";
         <!-- END DYNAMIC BLOCK: nullvalue -->
		}
      }
	}//end constructor {NAME}

<!-- BEGIN DYNAMIC BLOCK: getfunctions -->

/**
*
* @author - {AUTHOR}
* @type - {GETFUNCTIONTYPE}
* @desc - get $this->{VAR_NAME}
* @return - string
* @vers - 1.0
* @Mod -
*/
{GETFUNCTIONTYPE} function get{FUNC_NAME}()
{
  return $this->{VAR_NAME};

} // end get{FUNC_NAME}()	
<!-- END DYNAMIC BLOCK: getfunctions -->

<!-- BEGIN DYNAMIC BLOCK: setfunctions -->

/**
*
* @author - {AUTHOR}
* @type - {SETFUNCTIONTYPE}
* @desc - set $this->{VAR_NAME} to ${VAR_NAME}
* @param  $ - string ${VAR_NAME}
* @return - void
* @vers - 1.0
* @Mod -
*/
{SETFUNCTIONTYPE}function set{FUNC_NAME}(${VAR_NAME})
{
  $this->{VAR_NAME}=${VAR_NAME};
} // end set{FUNC_NAME}()
	
<!-- END DYNAMIC BLOCK: setfunctions -->

/**
*
* @author - {AUTHOR}
* @type - {SAVEFUNCTIONTYPE}
* @desc - saves data into database
* @return - void
* @vers - 1.0
* @Mod -
*/
{SAVEFUNCTIONTYPE}function save() {

		if (($this->{IDCLASS})==0)
		{
			$SQL = "INSERT INTO {DBNAME} ({LIST})";
			$SQL .= " VALUES({LIST_INSERT})";

			$retid = mysql_query($SQL);
			if (!$retid) { echo( mysql_error()); }
			$this->{IDCLASS} = mysql_insert_id();
		}
		else
		{
			$SQL = "UPDATE {DBNAME} SET {LIST_UPDATE}";
			$SQL .= " WHERE `{IDCLASS}`='".$this->{IDCLASS}."'";
			$retid = mysql_query($SQL);
			if (!$retid) { echo( mysql_error()); }
		}
		
}//end save()


/**
*
* @author - {AUTHOR}
* @type - {FDTYPE}
* @desc - delete ${IDCLASS} from database
* @return - void
* @vers - 1.0
* @Mod -
*/
{FDTYPE} function delete(${IDCLASS})
{

	$SQL = "DELETE FROM {DBNAME} WHERE `{IDCLASS}`='".${IDCLASS}."'";
	$retid = mysql_query($SQL);
	if (!$retid) { echo( mysql_error()); }

} // end delete()



} // end class {NAME}
?>
Return current item: PHP or Java Class Code Generator