コード例 #1
0
ファイル: demo.php プロジェクト: comdan66/zeusdesign
 function create_demo()
 {
     $db_line = color(str_repeat('=', 80), 'N') . "\n";
     $line = color(str_repeat('-', 80), 'w') . "\n";
     echo $db_line;
     $results = array();
     $migrations = array('event' => array(), 'attendee' => array(), 'tag' => array(), 'tag_event_map' => array());
     array_walk($migrations, function ($value, $key) use(&$results) {
         array_push($results, implode("\n", array_map(function ($result) {
             $count = 1;
             return color('  Create: ', 'g') . str_replace(FCPATH, '', $result, $count);
         }, create_migration(BASEPATH . 'cmd/templates/demo/' . $key . '/', $key, 'add'))));
     });
     echo implode("\n", $results) . "\n" . $line;
     $results = array();
     $models = array('event' => array('-p' => array('cover')), 'attendee' => array(), 'tag' => array(), 'tag_event_map' => array());
     array_walk($models, function ($value, $key) use(&$results) {
         array_push($results, implode("\n", array_map(function ($result) {
             $count = 1;
             return color('  Create: ', 'g') . str_replace(FCPATH, '', $result, $count);
         }, create_model(BASEPATH . 'cmd/templates/demo/' . $key . '/', $key, isset($value['-p']) ? $value['-p'] : array(), isset($value['-f']) ? $value['-f'] : array()))));
     });
     echo implode("\n", $results) . "\n" . $line;
     $results = array();
     $cells = array('demo' => array('main_menu'));
     array_walk($cells, function ($value, $key) use(&$results) {
         array_push($results, implode("\n", array_map(function ($result) {
             $count = 1;
             return color('  Create: ', 'g') . str_replace(FCPATH, '', $result, $count);
         }, create_cell(BASEPATH . 'cmd/templates/demo/cell/', $key, $value))));
     });
     echo implode("\n", $results) . "\n" . $line;
     $results = array();
     $controllers = array('events' => array(), 'tags' => array());
     array_walk($controllers, function ($value, $key) use(&$results) {
         array_push($results, implode("\n", array_map(function ($result) {
             $count = 1;
             return color('  Create: ', 'g') . str_replace(FCPATH, '', $result, $count);
         }, create_controller(BASEPATH . 'cmd/templates/demo/' . singularize($key) . '/', $key, 'site', array('index', 'show', 'add', 'create', 'edit', 'update', 'destroy')))));
     });
     echo implode("\n", $results) . "\n" . $line;
     $results = run_migration(null);
     echo color('注意! ', 'r');
     echo implode("\n", $results) . "\n";
     $results = array();
     array_push($results, "migrations(" . implode(', ', array_keys($migrations)) . ")");
     array_push($results, "models(" . implode(', ', array_keys($models)) . ")");
     array_push($results, "cells(" . implode(', ', array_keys($cells)) . ")");
     array_push($results, "controllers(" . implode(', ', array_keys($controllers)) . ")");
     return $results;
 }
コード例 #2
0
ファイル: create.php プロジェクト: comdan66/zeusdesign
// php   create   cell         cell_name         [method_name1, method_name2...]
// php   create   demo
// php   create   search       search_name
$file = array_shift($argv);
$type = array_shift($argv);
$name = array_shift($argv);
$action = !in_array(strtolower($type), array('model')) ? array_shift($argv) : $argv;
switch (strtolower($type)) {
    case 'controller':
        $results = create_controller($temp_path, $name, $action);
        break;
    case 'model':
        $params = params($action, array('-p', '-f', '-pic', '-file'));
        $images = array_merge($images = isset($params['-p']) ? $params['-p'] : array(), isset($params['-pic']) ? $params['-pic'] : array());
        $files = array_merge($files = isset($params['-f']) ? $params['-f'] : array(), isset($params['-file']) ? $params['-file'] : array());
        $results = create_model($temp_path, $name, $images, $files);
        break;
    case 'migration':
        $results = create_migration($temp_path, $name, $action);
        break;
    case 'cell':
        $results = create_cell($temp_path, $name, array_merge(array($action), $argv));
        break;
    case 'demo':
        include 'functions/demo.php';
        $results = create_demo();
        break;
    case 'search':
        $results = create_search($temp_path, $name);
        break;
    default:
コード例 #3
0
ファイル: automate-cli.php プロジェクト: tandrezone/automate
function create_crude($name, $empty)
{
    create_controller($name, $empty);
    create_model($name);
    create_routing($name);
    create_tables();
    echo "Crud " . $name . " created with success\n";
}
コード例 #4
0
ファイル: submit.php プロジェクト: sajedgit/MydataForCrud
    $arr = array();
    $table_name = $tables[0];
    $query_for_column = "DESCRIBE  {$table_name}";
    // find the column name from selected table
    $result_for_table_column = mysql_query($query_for_column);
    if (!$result_for_table_column) {
        echo "DB Error, could not list columns\n";
        echo 'MySQL Error: ' . mysql_error();
        die;
    }
    while ($columns = mysql_fetch_row($result_for_table_column)) {
        //print_r($columns);
        array_push($arr, $columns);
    }
    $table_name_to_class = create_table_to_class_name($table_name);
    create_model($arr, $table_name, $table_name_to_class);
    create_view($arr, $table_name, $table_name_to_class);
    create_controller($arr, $table_name, $table_name_to_class);
    create_route_file($arr, $table_name, $table_name_to_class);
    create_language_file($arr, $table_name, $table_name_to_class);
}
//print_r($arr[0]);die();
/* $sql = "DROP TABLE $table_name";
$retval = mysql_query( $sql );
if(! $retval )
{
  die('Could not delete table: ' . mysql_error());
}
else
	echo "Table deleted successfully\n"; */
function create_route_file($arr, $table_name, $table_name_to_class)
コード例 #5
0
ファイル: generate.php プロジェクト: rawhide/phpframework
<?php

error_reporting(E_ALL || ~E_NOTICE);
include dirname(__FILE__) . "/../config/environment.php";
$options = $_SERVER['argv'];
array_shift($options);
$type = array_shift($options);
switch ($type) {
    case 'migration':
        create_migration($options);
        break;
    case 'model':
        create_model($options);
        break;
}
function create_model($opts)
{
    $filename = filename($opts[0]);
    $text = <<<MODEL
<?php

class {$filename} extends Model {
  const TABLE = "{$opts['0']}";

}

MODEL;
    $fh = fopen(APP_ROOT . '/app/models/' . $filename . '.class.php', 'w');
    fwrite($fh, $text);
    fclose($fh);
    create_migration($opts);