Пример #1
0
 function &model($model)
 {
     trigger_before('model', $this, $this);
     return $this->get_table(tableize($model));
 }
Пример #2
0
function load_model(&$model, &$model2)
{
    global $db;
    $tab = tableize(get_class($model));
    if ($tab == 'models') {
        return;
    }
    if (!$db->models[$tab]->exists) {
        $model->register($tab);
    }
}
Пример #3
0
				onComplete: function(res) { 
					var response = res.response;
					if (response == 'ok') {
						Element.remove(e.parentNode.parentNode);
					} else {
						console.log(res.response);
					}	
				}
			});
		}
	</script>
	</head><body style='text-align: center;'>


<?php 
    $table = tableize($output);
    $table = str_replace('<table', "<table class='sortable' style='width: 98%;' id='querytable'", $table);
    print $table;
    ?>
 </body></html><?php 
} elseif ($action == 'confirm') {
    $id = $db->quote($_REQUEST['id']);
    $query = "insert ignore into dupe_check set ids='{$id}'";
    dbQuery($query);
    if ($error) {
        print $error;
    } else {
        print "ok";
    }
} else {
    ?>
Пример #4
0
 function save()
 {
     trigger_before('save', $this, $this);
     global $db;
     trigger_before('save', $this, $db);
     if (!isset($this->table)) {
         $this->table = tableize(get_class($this));
     }
     if ($this->table == 'models') {
         return;
     }
     if (!isset($db->tables)) {
         $db->tables = $db->get_tables();
     }
     if (!in_array($db->prefix . $this->table, $db->tables)) {
         if (count($this->field_array) > 0) {
             if (!isset($this->primary_key)) {
                 $this->auto_field('id');
             }
             $db->add_table($this->table, $this->field_array);
             $this->class_init();
         } else {
             return NULL;
         }
     }
     if (!isset($this->primary_key) && !strstr($this->table, 'db_sessions')) {
         trigger_error("The " . $this->table . " table must have a primary key. Example: " . $this->table . "->set_primary_key('field')" . @mysql_error($this->conn), E_USER_ERROR);
     }
     $this->exists = true;
     $this->set_routes($this->table);
     trigger_after('save', $this, $db);
 }
Пример #5
0
 function run()
 {
     $paths = environment('load_paths');
     //$this->models[$table] = new $custom_class();
     //$this->models[$table]->register($table);
     //return $this->models[$table];
     global $db;
     if (isset($paths['application'])) {
         $app = $paths['application'];
     } else {
         $app = 'db';
     }
     $loadpaths = array();
     foreach ($paths as $name => $path) {
         if (!empty($path)) {
             $loadpaths[$name] = $GLOBALS['PATH']['app'] . $path . DIRECTORY_SEPARATOR;
         }
     }
     if (isset($GLOBALS['PATH']['apps'])) {
         foreach ($GLOBALS['PATH']['apps'] as $k => $v) {
             $loadpaths[$k] = $v['model_path'];
         }
     }
     foreach ($loadpaths as $name => $loadpath) {
         //next unless path.last && name != :application
         //Dir[path.first / path.last].each do |file|
         //load_file file
         if (!empty($loadpath) && ($handle = opendir($loadpath))) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != '.' && $file != '..' && substr($file, -3) == 'php') {
                     require_once $loadpath . $file;
                     $cl = substr($file, 0, -4);
                     if (!isset($db->models[tableize($cl)]) && class_exists($cl)) {
                         $db->models[tableize($cl)] = new $cl();
                     }
                 }
             }
             closedir($handle);
         }
     }
     $orphaned_classes = array();
     # Add models, controllers, and lib to the load path
     #$LOAD_PATH.unshift Merb.dir_for(:model)
     #$LOAD_PATH.unshift Merb.dir_for(:controller)
     #$LOAD_PATH.unshift Merb.dir_for(:lib)
     #load_file Merb.dir_for(:application) if File.file?(Merb.dir_for(:application))
     # Require all the files in the registered load paths
     //Merb::Controller.send :include, Merb::GlobalHelpers
     $this->load_classes_with_requirements($orphaned_classes);
 }
Пример #6
0
 function just_get_objects()
 {
     if (isset($_GET['dbscript_xml_error_continue'])) {
         $path = $GLOBALS['PATH']['models'];
         if (is_dir($path)) {
             if ($handle = opendir($path)) {
                 while (false !== ($file = readdir($handle))) {
                     if ($file != '.' && $file != '..' && substr($file, -3) == 'php') {
                         $table = tableize(substr($file, 0, -4));
                         if (!in_array($table, $this->get_tables())) {
                             $tab = $this->get_table($table);
                         }
                     }
                 }
                 closedir($handle);
             }
         }
         $this->get_objects();
         return true;
     }
     return false;
 }