-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
88 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
<?php echo '<?php' ?> | ||
<?php echo '<?php' ?> | ||
<?php foreach ($belongsTo as $relation): ?> | ||
$<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']; ?> = DB::selectPairs('select `<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_COLUMN_NAME']; ?>`,`<?php echo $findDisplayField($relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']); ?>` from `<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']; ?>`'); | ||
<?php endforeach; ?> | ||
<?php endforeach;?> | ||
if ($_SERVER['REQUEST_METHOD']=='POST') { | ||
$data = $_POST; | ||
$data = $_POST; | ||
<?php foreach ($belongsTo as $relation): ?> | ||
if (!isset($<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']; ?>[$data['<?php echo $table; ?>']['<?php echo $relation['KEY_COLUMN_USAGE']['COLUMN_NAME']; ?>']])) $errors['<?php echo $table; ?>[<?php echo $relation['KEY_COLUMN_USAGE']['COLUMN_NAME']; ?>]']='<?php echo ucfirst($singularize($humanize($relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']))); ?> not found'; | ||
<?php endforeach; ?> | ||
if (!isset($errors)) { | ||
$id = DB::insert('INSERT INTO `<?php echo $table; ?>` (<?php echo implode(', ',array_map(function($field){ return '`'.$field['COLUMNS']['COLUMN_NAME'].'`'; }, $fields)); ?>) VALUES (<?php echo implode(', ',array_map(function(){ return '?'; }, $fields)); ?>)', <?php echo implode(', ',array_map(function($field) use ($table) { return "\$data['$table']['".$field['COLUMNS']['COLUMN_NAME']."']"; }, $fields)); ?>); | ||
if ($id) { | ||
Flash::set('success','<?php echo ucfirst($singularize($humanize($table))); ?> saved'); | ||
Router::redirect('<?php echo $path; ?>/<?php echo $table; ?>/index'); | ||
} | ||
} | ||
Flash::set('danger','<?php echo ucfirst($singularize($humanize($table))); ?> not saved'); | ||
if (!isset($<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']; ?>[$data['<?php echo $table; ?>']['<?php echo $relation['KEY_COLUMN_USAGE']['COLUMN_NAME']; ?>']])) $errors['<?php echo $table; ?>[<?php echo $relation['KEY_COLUMN_USAGE']['COLUMN_NAME']; ?>]']='<?php echo ucfirst($singularize($humanize($relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']))); ?> not found'; | ||
<?php endforeach;?> | ||
if (!isset($errors)) { | ||
$id = DB::insert('INSERT INTO `<?php echo $table; ?>` (<?php echo implode(', ', array_map(function ($field) {return '`' . $field['COLUMNS']['COLUMN_NAME'] . '`';}, $fields)); ?>) VALUES (<?php echo implode(', ', array_map(function () {return '?';}, $fields)); ?>)', <?php echo implode(', ', array_map(function ($field) use ($table) {return "\$data['$table']['" . $field['COLUMNS']['COLUMN_NAME'] . "']";}, $fields)); ?>); | ||
if ($id) { | ||
Flash::set('success','<?php echo ucfirst($singularize($humanize($table))); ?> saved'); | ||
Router::redirect('<?php echo $path; ?>/<?php echo $table; ?>/index'); | ||
} | ||
} | ||
Flash::set('danger','<?php echo ucfirst($singularize($humanize($table))); ?> not saved'); | ||
} else { | ||
$data = array('<?php echo $table; ?>'=>array(<?php echo implode(', ',array_map(function($field){ return "'".$field['COLUMNS']['COLUMN_NAME']."'".'=>'.var_export($field['COLUMNS']['COLUMN_DEFAULT'],true); }, $fields)); ?>)); | ||
$data = array('<?php echo $table; ?>'=>array(<?php echo implode(', ', array_map(function ($field) {return "'" . $field['COLUMNS']['COLUMN_NAME'] . "'" . '=>' . var_export($field['COLUMNS']['COLUMN_DEFAULT'], true);}, $fields)); ?>)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php echo '<?php' ?> | ||
<?php echo '<?php' ?> | ||
if (!empty($_POST)) { | ||
$rows = DB::delete('DELETE FROM `<?php echo $table; ?>` WHERE `id` = ?', $id); | ||
if (!$rows) Flash::set('danger','<?php echo ucfirst($singularize($humanize($table))); ?> not deleted'); | ||
else Flash::set('success','<?php echo ucfirst($singularize($humanize($table))); ?> deleted'); | ||
Router::redirect('<?php echo $path; ?>/<?php echo $table; ?>/index'); | ||
$rows = DB::delete('DELETE FROM `<?php echo $table; ?>` WHERE `id` = ?', $id); | ||
if (!$rows) Flash::set('danger','<?php echo ucfirst($singularize($humanize($table))); ?> not deleted'); | ||
else Flash::set('success','<?php echo ucfirst($singularize($humanize($table))); ?> deleted'); | ||
Router::redirect('<?php echo $path; ?>/<?php echo $table; ?>/index'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
<?php echo '<?php' ?> | ||
<?php echo '<?php' ?> | ||
<?php foreach ($belongsTo as $relation): ?> | ||
$<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']; ?> = DB::selectPairs('select `<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_COLUMN_NAME']; ?>`,`<?php echo $findDisplayField($relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']); ?>` from `<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']; ?>`'); | ||
<?php endforeach; ?> | ||
<?php endforeach;?> | ||
if ($_SERVER['REQUEST_METHOD']=='POST') { | ||
$data = $_POST; | ||
$data = $_POST; | ||
<?php foreach ($belongsTo as $relation): ?> | ||
if (!isset($<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']; ?>[$data['<?php echo $table; ?>']['<?php echo $relation['KEY_COLUMN_USAGE']['COLUMN_NAME']; ?>']])) $errors['<?php echo $table; ?>[<?php echo $relation['KEY_COLUMN_USAGE']['COLUMN_NAME']; ?>]']='<?php echo ucfirst($singularize($humanize($relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']))); ?> not found'; | ||
<?php endforeach; ?> | ||
if (!isset($errors)) { | ||
$rowsAffected = DB::update('UPDATE `<?php echo $table; ?>` SET <?php echo implode(', ',array_map(function($field){ return '`'.$field['COLUMNS']['COLUMN_NAME'].'`=?'; }, $fields)); ?> WHERE `id`=?', <?php echo implode(', ',array_map(function($field) use ($table) { return "\$data['$table']['".$field['COLUMNS']['COLUMN_NAME']."']"; }, $fields)); ?>, $id); | ||
if ($rowsAffected!==false) { | ||
Flash::set('success','<?php echo ucfirst($singularize($humanize($table))); ?> saved'); | ||
Router::redirect('<?php echo $path; ?>/<?php echo $table; ?>/view/'.$id); | ||
} | ||
} | ||
Flash::set('danger','<?php echo ucfirst($singularize($humanize($table))); ?> not saved'); | ||
if (!isset($<?php echo $relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']; ?>[$data['<?php echo $table; ?>']['<?php echo $relation['KEY_COLUMN_USAGE']['COLUMN_NAME']; ?>']])) $errors['<?php echo $table; ?>[<?php echo $relation['KEY_COLUMN_USAGE']['COLUMN_NAME']; ?>]']='<?php echo ucfirst($singularize($humanize($relation['KEY_COLUMN_USAGE']['REFERENCED_TABLE_NAME']))); ?> not found'; | ||
<?php endforeach;?> | ||
if (!isset($errors)) { | ||
$rowsAffected = DB::update('UPDATE `<?php echo $table; ?>` SET <?php echo implode(', ', array_map(function ($field) {return '`' . $field['COLUMNS']['COLUMN_NAME'] . '`=?';}, $fields)); ?> WHERE `id`=?', <?php echo implode(', ', array_map(function ($field) use ($table) {return "\$data['$table']['" . $field['COLUMNS']['COLUMN_NAME'] . "']";}, $fields)); ?>, $id); | ||
if ($rowsAffected!==false) { | ||
Flash::set('success','<?php echo ucfirst($singularize($humanize($table))); ?> saved'); | ||
Router::redirect('<?php echo $path; ?>/<?php echo $table; ?>/view/'.$id); | ||
} | ||
} | ||
Flash::set('danger','<?php echo ucfirst($singularize($humanize($table))); ?> not saved'); | ||
} else { | ||
$data = DB::selectOne('SELECT * from `<?php echo $table; ?>` where `id` = ?', $id); | ||
$data = DB::selectOne('SELECT * from `<?php echo $table; ?>` where `id` = ?', $id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters