I am interesting in creating a code spitter that takes a database table (simulated views would be even better) and generates Accessors, Mutators and Data Persistance methods (a simple SELECT command and a simple UPDATE / INSERT command) I've already built a modification on http://www.card2u.com.my/classbuilder.php that does the first part but not the Persistance methods and not very well (not supporting views of course). If you don't get what I'm saying, I mean a simple class where specify the table you need a class for, the primary key, whether it autoincrements or not, and fields to not include, and it generates a basic class. If anyone is interested email me @ jacob@calabashmusic.com
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been working on a new phpCodeGenie which does about what you just asked. e.g from a table.. it will generate this sample code.. tableInfo.php which is the accessors, mutators, tableDAO.php which is the data persistance layer containng all DML operations and tableManager which is merely a facade for tableDAO used by the front end programs.. Hopefully I'll release in a couple of weeks... sample code generated so far is like this...
<pre>
<?php
class testtbInfo {
// Variables
// name field from table
var $name;
/**
* @return returns value of variable $name
* @desc getName : Getting value for variable $name
*/
function getName() {
return $this->name;
}
/**
* @param param : value to be saved in variable $name
* @desc setName : Setting value for $name
*/
function setName($value) {
$this->name = $value;
}
Cool! This looks promising, but the real question is how can we leave itup to the user to define their DBA of choice. This is pretty difficult.... Anyway, maybe I could pry myself away from PEAR DB.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yeah.. I am using adodb for that.. the tableDAO class makes class to another database abstraction class which in turns makes adodb calls... adodb can talk to most databases... but users can customize the database abstraction class to use pear Db or others...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am interesting in creating a code spitter that takes a database table (simulated views would be even better) and generates Accessors, Mutators and Data Persistance methods (a simple SELECT command and a simple UPDATE / INSERT command) I've already built a modification on http://www.card2u.com.my/classbuilder.php that does the first part but not the Persistance methods and not very well (not supporting views of course). If you don't get what I'm saying, I mean a simple class where specify the table you need a class for, the primary key, whether it autoincrements or not, and fields to not include, and it generates a basic class. If anyone is interested email me @ jacob@calabashmusic.com
Hi there,
I have been working on a new phpCodeGenie which does about what you just asked. e.g from a table.. it will generate this sample code.. tableInfo.php which is the accessors, mutators, tableDAO.php which is the data persistance layer containng all DML operations and tableManager which is merely a facade for tableDAO used by the front end programs.. Hopefully I'll release in a couple of weeks... sample code generated so far is like this...
<pre>
<?php
class testtbInfo {
// Variables
// name field from table
var $name;
/**
* @return returns value of variable $name
* @desc getName : Getting value for variable $name
*/
function getName() {
return $this->name;
}
/**
* @param param : value to be saved in variable $name
* @desc setName : Setting value for $name
*/
function setName($value) {
$this->name = $value;
}
}
?>
<?php
class testtbManager {
/**
* @return returns the insert Id of the inserted Row
* @param a populated instance of object - (testtb)
* @desc Inserts a new row in the table populated from parameters of (testtb) object
* @version 1.0 [2003-10-21]
* @licenseGNU GPL License
* @author Nilesh Dosooye <nilesh@dosooye.com>
* @copyright Copyright © 2003, Nilesh Dosooye
*/
function addNewTesttb($thisTesttb) {
// Instantiating new instance of TesttbDAO
$thisTesttbDAO = new TesttbDAO();
$thisTesttbDAO->createTesttb($thisTesttb);
}
/**
* @return returns true if update if successful or false if failure
* @param a populated instance of object - (testtb)
* @desc Updates database table row from parameters of (testtb) object
* @version 1.0 [2003-10-21]
* @licenseGNU GPL License
* @author Nilesh Dosooye <nilesh@dosooye.com>
* @copyright Copyright © 2003, Nilesh Dosooye
*/
function updateTesttb($thisTesttb) {
// Instantiating new instance of TesttbDAO
$thisTesttbDAO = new TesttbDAO();
$thisTesttbDAO->updateTesttb($thisTesttb);
}
/**
* @return returns true if delete if successful or false if failure
* @param a populated instance of object - (testtb)
* @desc Delete database table row from parameters of (testtb) object
* @version 1.0 [2003-10-21]
* @licenseGNU GPL License
* @author Nilesh Dosooye <nilesh@dosooye.com>
* @copyright Copyright © 2003, Nilesh Dosooye
*/
function deleteTesttb($thisTesttb) {
// Instantiating new instance of TesttbDAO
$thisTesttbDAO = new TesttbDAO();
$thisTesttbDAO->deleteTesttb($thisTesttb);
}
/**
* @return returns true if delete if successful or false if failure
* @param a populated instance of object - (testtb)
* @desc Delete database table row from parameters of (testtb) object
* @version 1.0 [2003-10-21]
* @licenseGNU GPL License
* @author Nilesh Dosooye <nilesh@dosooye.com>
* @copyright Copyright © 2003, Nilesh Dosooye
*/
function getTesttbById($id) {
// Instantiating new instance of TesttbDAO
$thisTesttbDAO = new TesttbDAO();
return $thisTesttbDAO->getTesttbById($id);
}
} // end of testtbManager
?>
</pre>
Cool! This looks promising, but the real question is how can we leave itup to the user to define their DBA of choice. This is pretty difficult.... Anyway, maybe I could pry myself away from PEAR DB.
yeah.. I am using adodb for that.. the tableDAO class makes class to another database abstraction class which in turns makes adodb calls... adodb can talk to most databases... but users can customize the database abstraction class to use pear Db or others...
When might the new phpCodeGenie be available?
~ James