PHP Classes

PHPeclipse - PHP - Code Templates: Generate DB class, manager and exception file like PHPeclipse

Recommend this page to a friend!
  All requests RSS feed  >  PHPeclipse - PHP - Code Templates  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

PHPeclipse - PHP - Code Templates


Picture of Dean Fragnito by Dean Fragnito - 6 years ago (2017-01-28)

Generate DB class, manager and exception file like PHPeclipse

This request is clear and relevant.
This request is not clear or is not relevant.


I havea code base thats makes use of templates files that where generated by PHPeclipse - PHP - Code Templates. I like how these templates work and would like to be bale to generate similiar data base class and manger files form new Tables I am creating. The generated files consist of class file, manager file and exception based on a table


Table salesrep fiields salesrep_id,first_name,last_name,username

class file SalesRep.php (Came Case)

class SalesRep
	private $salesrep_id;
	private $first_name;
	private $last_name;
	private $username;

	// Getters & Setters for the member variables

	// Getter & Setter for salesrep_id
	function getSalesRepId()
		return $this->salesrep_id;

	function setSalesRepId( $value )
		$this->salesrep_id = $value;

	// Getter & Setter for First Name
	function getFirstName()
		return $this->first_name;

	function setFirstName( $value )
		$this->first_name = $value;

	// Getter & Setter for Last Name
	function getLastName()
		return $this->last_name;

	function setLastName( $value )
		$this->last_name = $value;

	// Getter & Setter for Username
	function getUsername()
		return $this->username;

	function setUsername( $value )
		$this->username = $value;

} // class

Manager file SalesRepManager.php (Came Case)



class SalesRepManager {

     function addSalesRep($objSalesRep)
                   generated code inserts fileds into table
             catch(SalesRepException $e)
			throw $e;

       } // addSalesRep

} // class

other functions generated function updateSalesRep($objSalesRep) function deleteSalesRep($salesRepId) function getAllSalesReps() function getAllSalesRepsCount()

Exception file SalesRepException.php class SalesRepException extends Exception {

var $message;
var $errorNo;

function __construct($errorNo='', $message='')
	$this->message = $message;
	$this->errorNo = $errorNo;
} // function __construct()

function exception_handler($exception)
	echo "Uncaught exception: " , $exception->getMessage(), "\n";
} // function exception_handler()

function getErrorMessage()
	return $this->message ;

} // SalesRepException


Ask clarification

1 Recommendation

MySQL Class Generator: Generate classes to access MySQL as objects

This recommendation solves the problem.
This recommendation does not solve the problem.


Picture of Saro Carvello by Saro Carvello package author package author Reputation 430 - 6 years ago (2017-02-28) Comment

This utility generates automatically classes for any tables of a given database schema.

An auto generated PHP class provides the following services for a MySQL table:

  • A constructor for managing a fetched table row or for a adding a new one
  • Management for both single or composite Primary Keys
  • Automatic mapping of the different date formats may occurs between application and database
  • Destructor to automatically close database connection
  • Defines a set of attributes corresponding to the table fields
  • Setter and Getter methods for each attribute
  • OO methods for simplify DML select, insert, update and delete operations
  • A facility for quickly updating a previously fetched row
  • Useful methods to obtain table DDL and the last executed SQL statement
  • Error handling of SQL statements
  • Camel/Pascal case naming convention for Attributes/Class used for mapping Fields/Table
  • Useful PHPDOC information about table, fields and the usage of class, attributes and methods

Recommend package