/** * Load another model as a dependency of this one. * * @param string $model_name */ function depend($model) { foreach (func_get_args() as $name) { if (isset($this->depends->{$name})) { continue; } $this->depends->{$name} =& Factory::model($name); } }
/** * Instantiate one or more models and load them into the holder * * @param string $name,... Name(s) of model(s) to import */ function import_model($name) { foreach (func_get_args() as $name) { $this->models->{$name} =& Factory::model($name); if ($this->models->{$name} === false) { trigger_error("Model {$name} does not exist"); die; } } }
/** * Load another model as a dependency of this one. * * @param string $model_name */ function &depend($model) { foreach (func_get_args() as $name) { if (isset($this->depends->{$name})) { continue; } $this->depends->{$name} =& Factory::model($name); } // return a reference to the last model loaded return $this->depends->{$name}; }
#!/usr/bin/env php <?php /** * An example of a commandline script in Pronto. * */ @chdir(dirname($argv[0]) . '/..'); require_once 'profiles/cmdline.php'; $m_user =& Factory::model('user'); $users = $m_user->find("status='active'"); while ($u = $users->load_one()) { echo "{$u['email']}\n"; } exit(0);