mirror of
https://github.com/bcit-ci/CodeIgniter.git
synced 2025-02-20 11:13:29 +08:00
...
parent
b2242a32c5
commit
98d229f100
@ -140,8 +140,8 @@ cicrud.php
|
||||
[code]
|
||||
#!/usr/bin/php -q
|
||||
<?
|
||||
# CICRUD 0.1 By Vladimir Grubor (grubor@gmail.com)
|
||||
# 2008.12.08
|
||||
# CICrud 0.1
|
||||
# Author Vladimir Grubor (grubor@gmail.com)
|
||||
# Use ./cicrud.php [(m)odel|(c)ontroller|(v)iew|(a)ll] [CI project folder] [table] [fields]
|
||||
# or php cicrud.php [(m)odel|(c)ontroller|(v)iew|(a)ll] [CI project folder] [table] [fields]
|
||||
# cat textfile | xargs ./cicrud.php [(m)odel|(c)ontroller|(v)iew|(a)ll] [CI project folder] [table]
|
||||
@ -258,7 +258,47 @@ function model()
|
||||
|
||||
function controller()
|
||||
{
|
||||
global $folder,$table;
|
||||
global $folder,$table,$author,$date;
|
||||
$controllername = $table;
|
||||
$controller = $folder.'/controllers/'.$controllername.'.php';
|
||||
$model = 'mod'.$table;
|
||||
echo "Generating controller...\n";
|
||||
$fp = fopen($controller, 'w');
|
||||
fwrite($fp,"<?php if (!defined('BASEPATH')) exit('No direct script access allowed');\n");
|
||||
|
||||
fwrite($fp, "/**\n");
|
||||
fwrite($fp, "* $table controller\n");
|
||||
fwrite($fp, "*\n");
|
||||
fwrite($fp, "* @author $author\n");
|
||||
fwrite($fp, "* @date $date\n");
|
||||
fwrite($fp, "*/\n");
|
||||
|
||||
fwrite($fp,"class $controllername extends Controller {\n\n");
|
||||
fwrite($fp," function $controllername(){\n");
|
||||
fwrite($fp," parent::Controller();\n");
|
||||
fwrite($fp," \$this->load->model('mod$table');;\n");
|
||||
fwrite($fp," }\n\n");
|
||||
|
||||
fwrite($fp," function index(){\n");
|
||||
fwrite($fp," \$data['$table'] = \$this->".$model."->get()\n");
|
||||
fwrite($fp," }\n\n");
|
||||
|
||||
fwrite($fp," function add(){\n");
|
||||
fwrite($fp," }\n\n");
|
||||
|
||||
fwrite($fp," function edit(\$id){\n");
|
||||
fwrite($fp," \$editable = \$this->".$model."->id = \$id;\n");
|
||||
fwrite($fp," \$editable = \$this->".$model."->get();\n");
|
||||
fwrite($fp," }\n\n");
|
||||
|
||||
fwrite($fp," function del(\$id){\n");
|
||||
fwrite($fp,' $this->mod'.$table."->del(\$id);\n");
|
||||
fwrite($fp," redirect('$controllername');\n");
|
||||
fwrite($fp," }\n\n");
|
||||
fwrite($fp,"}\n");
|
||||
fwrite($fp, "/* End of file $controllername */\n");
|
||||
fwrite($fp, "/* Location: ./application/controllers/$controllername.php */\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
function view()
|
||||
|
Loading…
x
Reference in New Issue
Block a user