$pdocrud = new PDOCrud();
/**
* Sets data binding of the field i.e. load the field data from some datasource
* @param string $fieldName field name to be bind
* @param mixed $dataSource data source either tablename or array of data
* @param string $key name of col, that will serve as data key
* @param mixed $val name of col as string or array of columns, that will serve as field value
* @param string $bind whether datasource is db table or array or sql, default is db table
* @param string $separator Separator string in case of $val is an array of columns. Default value is " "
* @param string $where Where condition for the datasource
* @param string $orderby Order by clause for the datasource
* return object Object of class
*/
$pdocrud->fieldTypes("gender", "radio");//change gender to radio button
$pdocrud->fieldDataBinding("gender", array("male","female"), "", "","array");//add data binding using array
$pdocrud->fieldTypes("country", "select");//change type to select
$pdocrud->fieldDataBinding("country", "country", "country_id", "country_name", "db");//add data using another table name country
$pdocrud->fieldTypes("state", "select");//change state to select dropdown
$pdocrud->fieldDataBinding("state", array("Andhra Pradesh","Bihar","Patna","Gujarat","Madhya Pradesh"), "", "","array");//add data using array in select dropdown
//Version 4.0 features
//1. Pass select query to generate the data
$pdocrud->fieldTypes("hobbies", "checkbox");//change field type to checkbox
$query = "select * from `hobbies` where `hobby_status` = 1 order by `hobby_name`";
$pdocrud->fieldDataBinding("hobbies", $query, "hobby_id", "hobby_name", "sql");
//2. Combine two or more columns in the display value
$pdocrud->fieldTypes("city", "select");//change city field to select
//add data using another table name city and merge columns "city_code" and "city_name" with separator "-"
$pdocrud->fieldDataBinding("city", "city", "city_id", array("city_code","city_name"), "db", "-");
echo $pdocrud->dbTable("users")->render("insertform");
//Version 4.2 features
//Add 'where' and 'orderby' statement.
//$pdocrud->fieldTypes("city", "select");//change city field to select
//add data using another table name city and merge columns "city_code" and "city_name" with separator "-"
//$pdocrud->fieldDataBinding("city", "city", "city_id", array("city_code","city_name"), "db", "-", array(array("city_code","0001","=")), array("city_name"));