Пример #1
0
function saveImplementFile($name, $meta_data_class)
{
    $className = className($name);
    $fileName = $className . ".m";
    $content = $GLOBALS['template_m_file'];
    $template_collection = $GLOBALS['template_collection_file'];
    $template_object = $GLOBALS['template_object_file'];
    $content = str_replace("#TEMPLATE_CLASS_NAME#", $className, $content);
    $properties = "";
    $classes = "";
    foreach ($meta_data_class as $meta) {
        $name = parameterName($meta);
        if ($meta->is_collection) {
            $map = str_replace("#TEMPLATE_PROPERTY_NAME#", $name, $template_collection);
            $map = str_replace("#TEMPLATE_PROPERTY_CLASS#", $meta->type, $map);
            $map = str_replace("#TEMPLATE_PROPERTY_KEY#", $meta->name, $map);
            $properties .= "{$map},\n";
        } else {
            $map = str_replace("#TEMPLATE_PROPERTY_NAME#", $name, $template_object);
            $map = str_replace("#TEMPLATE_PROPERTY_KEY#", $meta->name, $map);
            $properties .= "{$map},\n";
        }
        // if ( !in_array($meta->type, $GLOBALS['system_types']) ) {
        // 	$classes .= "#import \"{$className}.h\";\n";
        // }
    }
    $content = str_replace("#TEMPLATE_MAP_PROPERTIES#", $properties, $content);
    $content = str_replace("#TEMPLATE_IMPORT_CLASSES#", $classes, $content);
    file_put_contents($GLOBALS['path_result'] . '/' . $fileName, $content, null);
}
Пример #2
0
error_reporting(-1);
$url = parse_url(getenv("CLEARDB_DATABASE_URL"));
print_r($url);
$server = $url["host"];
$username = $url["user"];
$password = $url["pass"];
$db = substr($url["path"], 1);
$conn = new mysqli($server, $username, $password, $db);
$con = mysqli_connect('localhost', 'bella_wonderdog', 'emily1106', 'bella_wonderdog') or die("Cannot Connect to MySQL: " . mysqli_connect_error());
$userid = 1634434248;
$selectUser = "******";
$userResult = mysqli_query($con, $selectUser) or die("Error gettings user data: " . mysqli_error($con) . "<br>{$selectUser}");
while ($row = mysqli_fetch_array($userResult)) {
    $user[] = $row;
}
function className($value)
{
    if ($value > 0) {
        $return = "good";
    } elseif ($value < 0) {
        $return = "bad";
    } else {
        $return = "";
    }
    return $return;
}
$followerchange = isset($user[1]) ? $user[0]['NoFollowers'] - $user[1]['NoFollowers'] : 0;
$followerclass = className($followerchange);
$followingchange = isset($user[1]) ? $user[0]['NoFollowing'] - $user[1]['NoFollowing'] : 0;
$followingclass = className($followingchange);
$pagename = $_SERVER['PHP_SELF'];
Пример #3
0
    $tables = Typeframe::Database()->execute('SHOW TABLES LIKE \'' . mysql_real_escape_string($argv[2]) . '\'');
} else {
    $tables = Typeframe::Database()->execute('SHOW TABLES');
}
foreach ($tables as $rowTable) {
    $autoIncrement = false;
    $array = $rowTable->getArray();
    $tableName = array_pop($array);
    if (substr($tableName, 0, strlen(DBI_PREFIX)) == DBI_PREFIX) {
        $shortName = substr($tableName, strlen(DBI_PREFIX));
        $prefix = 'DBI_PREFIX';
    } else {
        $shortName = $tableName;
        $prefix = "''";
    }
    $className = className($shortName);
    $columns = array();
    $table = array('name' => $tableName);
    $rsColumns = Typeframe::Database()->execute('SHOW COLUMNS IN ' . $tableName);
    foreach ($rsColumns as $column) {
        //$columns[] = $column;
        $columns[] = defineColumn($column);
        continue;
        if ($column['Extra'] == 'auto_increment') {
            $autoIncrement = true;
        }
        $xlate = array();
        $xlate['name'] = $column['Field'];
        /*if (substr($column['Type'], 0, 3) == 'int') {
        			// integer
        		} else if (substr($column['Type'], 0, 7) == 'varchar') {
Пример #4
0
    foreach ($fields as $field) {
        $fieldDecl .= "\tprotected \${$field->Field}; // Type: {$field->Type}, Null: {$field->Null}, Key: {$field->Key}\r\n";
        $edit[] = $field;
    }
    array_shift($edit);
    $fieldArr = "\r\n";
    foreach ($edit as $field) {
        $fieldArr .= "\t\t\t\t'{$field->Field}'=>'{$field->Field}',\r\n";
    }
    $fieldArr .= "\t\t\t";
    $filetext = "<?php\r\n\r\nclass Base" . className($table) . " extends data_util\r\n{\r\n{$fieldDecl}\r\n\r\n\tfunction Base" . className($table) . "(\$object=null)\r\n\t{\r\n\t\t\$this->__tableName\t= '{$table}';\r\n\t\t\$this->__idField\t= '" . $fields[0]->Field . "';\r\n\t\t\$this->__fields\t= array({$fieldArr});\r\n\t}\r\n}\r\n\r\n";
    $filename = $dm->basePath() . 'includes/model/base/class.Base' . className($table) . '.php';
    $fp = fopen($filename, 'w');
    fwrite($fp, $filetext);
    fclose($fp);
    echo "{$filename} created.<br />\r\n";
    /**** END BASE MODEL CLASS FILE ****/
    /**** EXTENDED MODEL CLASS FILE ****/
    $filename = $dm->basePath() . 'includes/model/class.' . className($table) . '.php';
    if (!file_exists($filename)) {
        $filetext = "<?php\r\n\r\nclass " . className($table) . " extends Base" . className($table) . "\r\n{\r\n\tfunction " . className($table) . "(\$object=null)\r\n\t{\r\n\t\tparent::__construct(\$object);\r\n\t}\r\n}\r\n\r\n";
        $fp = fopen($filename, 'w');
        fwrite($fp, $filetext);
        fclose($fp);
        echo "{$filename} created.<br />\r\n";
    } else {
        echo "{$filename} exists.<br />\r\n";
    }
    /**** END EXTENDED MODEL CLASS FILE ****/
}
echo "</div>\r\nDone.<br />\r\n";
Пример #5
0
foreach ($result as $row) {
    $row = $row->getArray();
    //var_dump($row);
    $tableName = array_pop($row);
    $columns = array();
    //$rsCol = Typeframe::Database()->prepare('SHOW COLUMNS IN `' . $tableName . '`');
    //$rsCol->execute();
    $cols = Typeframe::Database()->execute('SHOW COLUMNS IN `' . $tableName . '`');
    //while ($col = $rsCol->fetch_array()) {
    foreach ($cols as $col) {
        $columns[] = $col['Field'];
    }
    $tables[$tableName] = $columns;
}
foreach (array_keys($tables) as $table) {
    $cls = className($table);
    if (!in_array($cls, $models)) {
        echo "The {$table} table does not have a BaseModel class.\n";
        $diffs++;
    } else {
        $mod = new $cls();
        foreach ($tables[$table] as $fld) {
            if (!$mod->field($fld)) {
                echo "The {$cls} BaseModel does not have the {$fld} field from the {$table} table.\n";
                $diffs++;
            }
        }
    }
}
foreach ($models as $cls) {
    $mod = new $cls();