?php class extends DBTable { /** * Constructor * Arguments : None */ function __construct() { parent::__construct(""); } /** * This will create a new and returns the id of the newly created row. */ function create() { $validation_rules = $this->getValidationRules(); $this->checkDuplicate('', $); $validation_errors = check($validation_rules,2); if($validation_errors) { $GLOBALS['QUERY']['error'] = "Please correct the errors before continuing...
" . $validation_errors; return false; } $this->newRow(); '$fn', 'is'=>'empty', 'error'=>'Please provide a password');\n"; if($f['password_encryption_algorithm']) $value = $f['password_encryption_algorithm'] . "(\$$fn . '$f[password_salt]')"; else $value = "\$$fn"; } else $value = '$' . $f['field']; if($f['auto_handler']) { //Auto handled values if($f['auto_handler'] === 'time_of_insert' || $f['auto_handler'] === 'current_time') $value = "'NOW()'"; elseif($f['auto_handler'] === 'current_user') $value = '$_SESSION["user_id"]'; elseif($f['auto_handler'] !== 'none' and $f['auto_handler']) continue; //Some unknown or invalid auto_handler - don't bother with that. } if(!in_array('must',$f['validation']) and $f['auto_handler'] === false) { ?>if($ !== false) $this->field[''] = ; return $this->save(); } /** * You can edit an existing using this function. The first argument * must be the id of the row to be edited */ function edit($id, ) { if(!$id) return -1; $this->checkDuplicate('', $); $validation_errors = check($this->getValidationRules(),2); if($validation_errors) { $GLOBALS['QUERY']['error'] = "Please correct the errors before continuing...
" . $validation_errors; return false; } $this->newRow($id); if($ !== false) $this->field[''] = ; return $this->save(); } /** * Delete the whose id is given * Argument : $id - The Id of the row to be deleted. */ function remove($id) { if(!$id) return -1; where("' . $user_field. 'id=$id");'; } else { print '$this->newRow($id);'; } ?> $this->delete(); } /** * Checks to make sure that there is no other row with the same value in the specified name. * Example: .checkDuplicate("username", "binnyva", 4); * .checkDuplicate("email", "binnyva@email.com"); */ function checkDuplicate($field, $value, $not_id=0) { //See if an item with that name is already there. $others = $this->find(array( "select" => 'id', 'where' => array("$field='$value'", "id!=$not_id"))); if($others) { showMessage(" '$new_name' already exists!","index.php",'error'); } return false; } function getValidationRules() { '$fn', 'is'=>'empty', 'error'=>'The $f[title] cannot be empty'),\n"; if(in_array('email', $f['validation'])) $validation_rules .= "\t\t\tarray('name'=>'$fn', 'is'=>'not_email', 'error'=>'Please provide a valid $f[title]'),\n"; if(in_array('number', $f['validation'])) $validation_rules .= "\t\t\tarray('name'=>'$fn', 'is'=>'nan', 'error'=>'$f[title] must be a number'),\n"; if(in_array('password', $f['validation'])) $validation_rules .= "\t\t\tarray('name'=>'$fn', 'is'=>'not', 'value_field'=>'confirm_password', 'error'=>'Password and confirmation dont match'),\n"; } } $validation_rules .= "\t\t)"; ?> return ; } } $GLOBALS[''] = new ; /* Controllor Constructor Code(JSON): */