本文整理汇总了PHP中model::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP model::factory方法的具体用法?PHP model::factory怎么用?PHP model::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
function delete($id)
{
// Let the file-model deal with the deletion
model::factory('file')->delete($id);
// and send the user back to the filelist
header('location: ' . model::factory('renderer')->url('/admin/file/'));
}
示例2: logout
function logout()
{
// Unset the session!
unset($_SESSION['user']);
// And send the user to the frontpage
header('Location: ' . model::factory('renderer')->url('/'));
}
示例3: test
function test()
{
$database = model::factory('database');
$r = $database->safe_query('select * from user where user_id in :user_id', array('user_id' => array(329, 339)));
var_Dump($r);
var_dump($r->fetchAll());
}
示例4: page
function page($page)
{
list($id, $null) = explode(':', $page);
$sql = 'select * from page where idpage="' . $id . '"';
list($page) = model::factory('database')->query($sql);
$page_renderer = model::factory('renderer', 'pages');
$page_renderer->page = $page;
model::factory('renderer')->content = $page_renderer->render('template/page.php');
}
示例5: get_all
function get_all()
{
$settings = array();
$r = model::factory('database')->query('select * from conf order by name asc');
foreach ($r as $s) {
$settings[] = $s;
}
return $settings;
}
示例6: post
function post($post)
{
list($id, $null) = explode(':', $post);
$sql = 'select * from post where idpost="' . $id . '"';
$post = model::factory('database')->query($sql)->fetch_assoc();
$post_renderer = model::factory('renderer', 'post');
$post_renderer->post = $post;
model::factory('renderer')->title = $post['title'];
model::factory('renderer')->content = $post_renderer->render('template/post.php', true);
}
示例7: index
function index()
{
if (isset($_POST) && !empty($_POST)) {
foreach ($_POST as $key => $p) {
model::factory('conf')->set($key, $p);
}
}
$renderer = model::factory('renderer', 'settings');
$renderer->settings = model::factory('conf')->get_all();
return model::factory('renderer')->admin_content = $renderer->render('template/admin/settings/index.php', true);
}
示例8: roll
function roll()
{
$roll = model::factory('kmom2_randomize')->roll_dice(6);
$rounds = $this->get_data($this->gamename);
$current_round = count($rounds['players'][$rounds['current_player']]['rounds']);
if ($current_round == 0 && !isset($rounds['players'][$rounds['current_player']]['rounds'][$current_round])) {
$rounds['players'][$rounds['current_player']]['rounds'][] = array();
}
if ($roll != 1) {
$rounds['players'][$rounds['current_player']]['rounds'][count($rounds['players'][$rounds['current_player']]['rounds']) - 1][] = $roll;
} else {
$rounds['players'][$rounds['current_player']]['rounds'][count($rounds['players'][$rounds['current_player']]['rounds']) - 1] = array();
$rounds['players'][$rounds['current_player']]['rounds'][count($rounds['players'][$rounds['current_player']]['rounds'])] = array();
}
$this->last_roll = $roll;
$this->set_data($this->gamename, $rounds);
}
示例9: safe_query
function safe_query($sql, $parameters = array())
{
if (!is_array($parameters)) {
$parameters = array($parameters);
}
$statement = $this->database->prepare($sql);
$statement->setFetchMode(PDO::FETCH_ASSOC);
$statement->execute($parameters);
if ($statement->errorCode() != '00000') {
model::debug()->print_backtrace();
model::factory('log')->warning('PDO errorcode: ' . $statement->errorCode());
model::factory('log')->warning('PDO errorinfo: ' . json_encode($statement->errorInfo()));
model::factory('log')->warning('PDO sql: ' . $sql);
model::factory('log')->warning('PDO parameters: ' . json_encode($parameters));
}
return $statement->fetchAll();
}
示例10: get
function get($file)
{
if (is_numeric($file)) {
$sql = "select path, filename, type from file where idfile = '" . $file . "'";
} else {
$sql = "select path, filename, type from file where filename = '" . $file . "'";
}
list($data) = model::factory('database')->query($sql);
header('Content-Description: File Transfer');
header('Content-Type: ' . $data['type']);
$mime = explode('/', $data['type']);
if ($mime[0] != 'image') {
header('Content-Disposition: attachment; filename=' . $data['filename']);
}
header('Pragma: public');
header('Content-Length: ' . filesize(UPLOAD . $data['path']));
readfile(UPLOAD . $data['path']);
die;
}
示例11: resolv
function resolv($url)
{
// get_parts splits the url by '/' and returns an array with the parts or a single element array with ''
$parts = model::factory('url')->get_parts();
if ($parts[0] == 'admin') {
// Admin... Always requiring special attention...
// Set the controller to be used if none is set
if (!isset($parts[1]) || $parts[1] == '') {
$parts[1] = 'welcome';
}
// Prepare the parameters
if (isset($parts[3])) {
$params = explode('/', $parts[3]);
} else {
$params = array();
}
// Instantiate the class
$class_name = 'controller_' . $parts[0] . '_' . $parts[1];
$class = new $class_name();
// And finish with the method
$method = isset($parts[2]) && !empty($parts[2]) ? $parts[2] : 'index';
} else {
// if parts is empty, use the default welcome-controller
if ($parts[0] == '') {
$parts[0] = 'welcome';
}
// Prepare the parameters
if (isset($parts[2])) {
$params = explode('/', $parts[2]);
} else {
$params = array();
}
// Instantiate the class
$class_name = 'controller_' . $parts[0];
$class = new $class_name();
// And finish with the method
$method = isset($parts[1]) && !empty($parts[1]) ? $parts[1] : 'index';
}
// Once done. return an array with the stuff
return array('class' => $class, 'params' => $params, 'method' => $method);
}
示例12: clear
function clear()
{
$this->gamedata->clear();
header('Location: ' . model::factory('renderer')->url('/kmom2/'));
}
示例13: delete
function delete($id)
{
$sql = 'delete from movie where movie_id=?';
model::factory('database')->safe_query($sql, $id);
}
示例14: index
function index()
{
model::factory('renderer')->set('admin_content', 'hi');
}
示例15: check_password
static function check_password($userid, $password)
{
$count = model::factory('database')->safe_query('select user_id from user where user_id = :user_id and where password = :password', array('user_id' => $userid, 'password' => $password));
if (count($count) == 1) {
return true;
} else {
return false;
}
}