本文整理汇总了PHP中CI::model方法的典型用法代码示例。如果您正苦于以下问题:PHP CI::model方法的具体用法?PHP CI::model怎么用?PHP CI::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CI
的用法示例。
在下文中一共展示了CI::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
function delete()
{
$id = $_POST['to_table_id'];
if (intval($id) == 0) {
exit('id?');
} else {
global $cms_db_tables;
$id = intval($_POST['to_table_id']);
$real_table = $cms_db_tables[$_POST['to_table']];
$q = "delete from {$real_table} where id={$id} ";
$q = CI::model('core')->dbQ($q);
$table = $cms_db_tables['table_reports'];
$q = "delete from {$table} where to_table='{$_POST['to_table']}' and to_table_id='{$_POST['to_table_id']}' ";
$q = CI::model('core')->dbQ($q);
CI::model('core')->cleanCacheGroup('reports');
switch ($_POST['to_table']) {
case 'table_content':
CI::model('core')->cleanCacheGroup('content');
break;
case 'table_comments':
CI::model('core')->cleanCacheGroup('comments');
break;
default:
CI::model('core')->cacheDeleteAll();
break;
}
//CI::model('comments')->commentsDeleteById ( $id );
}
}
示例2: get_visits_by_url
function get_visits_by_url($url, $start_time = false)
{
global $cms_db_tables;
$idsite = $this->site_id();
$table = $cms_db_tables['table_log_action'];
$cache_group = 'global/stats';
$q = "SELECT * FROM {$table} WHERE name = '{$url}' ";
$q = CI::model('core')->dbQuery($q, __FUNCTION__ . md5($q), $cache_group, '- 5 minutes');
if (!empty($q)) {
$q = $q[0];
$idaction = $q['idaction'];
$table2 = $cms_db_tables['table_log_link_visit_action'];
if ($start_time == false) {
$start_time = strtotime("4 weeks ago");
$start_time = date("Y-m-d H:i:s", $start_time);
} else {
$start_time = strtotime($start_time);
$start_time = date("Y-m-d H:i:s", $start_time);
}
$q = " SELECT idaction_name as id, \n COUNT(idlink_va) as views, \n COUNT(DISTINCT idvisitor) as visits, \n COUNT(IF(idaction_url_ref=0, 1, null)) as entry, \n log_action.name as page \n FROM {$table2}, {$table} \n WHERE {$table2}.idsite={$idsite} \n \n and idaction_url = {$idaction} \n \n AND {$table2}.idaction_name = {$table}.idaction \n AND server_time >='{$start_time}'\n \n ";
$q = " SELECT idaction_name as id, \n COUNT(idlink_va) as views \n \n FROM {$table2} \n WHERE \n \n idaction_url = {$idaction} \n \n \n AND server_time >='{$start_time}'\n \n ";
$q = CI::model('core')->dbQuery($q, __FUNCTION__ . md5($q), $cache_group, '- 5 minutes');
return intval($q[0]["views"]);
} else {
return 0;
}
}
示例3: index
function index()
{
header("Content-type: text/plain");
$segs = $this->uri->segment_array();
$cron_group = false;
$force = false;
$action = false;
foreach ($segs as $segment) {
if (stristr($segment, 'g:') == true) {
$cron_group = substr($segment, 2, strlen($segment));
/// exit($cron_group);
}
if (stristr($segment, 'force:true') == true) {
$force = true;
}
if (stristr($segment, 'a:') == true) {
$action = substr($segment, 2, strlen($segment));
}
}
$job = CI::model('core')->cronjobGetOne($cron_group, $force, $action);
if (!empty($job)) {
print "\n\n" . 'Begin - ' . date("Y-m-d H:i:s") . ' - ' . $job['cronjob_name'] . "\n";
$to_exc = '$this->' . $job['model_name'] . '->' . $job['function_to_execute'];
//print $to_exc;
eval($to_exc . ';');
print "\n" . 'End - ' . date("Y-m-d H:i:s") . ' - ' . $job['cronjob_name'] . "\n\n";
} else {
print "\n" . 'No jobs - ' . date("Y-m-d H:i:s") . "\n\n";
}
//var_dump($job);
//print 'cron-' . date("Y-m-d H:i:s");
}
示例4: load
function load()
{
$plugin_name = $this->uri->segment(4);
$this->template['functionName'] = strtolower(__FUNCTION__);
$this->template['pluginName'] = $plugin_name;
$this->load->vars($this->template);
$layout = CI::view('admin/layout', true, true);
$primarycontent = '';
$secondarycontent = '';
$plugindata = CI::model('core')->plugins_getPluginConfig($plugin_name);
//
//print PLUGINS_DIRNAME . $dirname .$plugin_name.'/'.$plugindata['plugin_admin_dir']. '/controller.php' ;
if (is_file(PLUGINS_DIRNAME . $dirname . $plugin_name . '/' . $plugindata['plugin_admin_dir'] . '/controller.php') == true) {
$firecms = get_instance();
define('THIS_PLUGIN_URL', site_url('admin/plugins/load') . '/' . $plugin_name . '/');
define('THIS_PLUGIN_DIRNAME', PLUGINS_DIRNAME . $dirname . $plugin_name . '/');
define('THIS_PLUGIN_DIRNAME_ADMIN', PLUGINS_DIRNAME . $dirname . $plugin_name . '/' . $plugindata['plugin_admin_dir'] . '/');
require_once PLUGINS_DIRNAME . $dirname . $plugin_name . '/' . $plugindata['plugin_admin_dir'] . '/controller.php';
}
//$primarycontent = CI::view ( 'admin/comments/index', true, true );
//$secondarycontent = CI::view ( 'admin/content/sidebar', true, true );
$layout = str_ireplace('{primarycontent}', $primarycontent, $layout);
$layout = str_ireplace('{secondarycontent}', $secondarycontent, $layout);
//CI::view('welcome_message');
CI::library('output')->set_output($layout);
}
示例5: mediaDelete
function mediaDelete()
{
$id = $_POST['id'];
if (intval($id) != 0) {
CI::model('core')->mediaDelete($id);
}
exit;
}
示例6: delete
function delete()
{
$id = $_POST['id'];
if (intval($id) == 0) {
exit('id');
} else {
CI::model('comments')->commentsDeleteById($id);
}
}
示例7: useremail_check
function useremail_check($username)
{
$check = CI::model('users')->doUserExist('email', $username);
if ($check == true) {
$this->validation->set_message('useremail_check', "The email {$username} is already assigned to another user! Please choose new one!");
return FALSE;
} else {
return TRUE;
}
}
示例8: ajax_delete_by_id
function ajax_delete_by_id()
{
$id = $_POST['id'];
if (intval($id) == 0) {
exit(0);
} else {
CI::model('core')->optionsDeleteById($id);
exit(1);
}
}
示例9: google_Analytics_getKeywordsForProfile
function google_Analytics_getKeywordsForProfile($profile_id, $start_date = false, $end_date = false)
{
$email = CI::model('content')->optionsGetByKey('google_analytics_login');
$pass = CI::model('content')->optionsGetByKey('google_analytics_pass');
require_once "Zend/Loader.php";
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $pass, "analytics");
$gdClient = new Zend_Gdata($client);
if ($start_date == false) {
$start_date = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
}
if ($end_date == false) {
$end_date = date("Y-m-d", mktime(0, 0, 0, date("m") - 0, date("d"), date("Y")));
}
try {
$dimensions = array("ga:region", "ga:city", "ga:latitude", "ga:longitude");
$metrics = array("ga:visits", "ga:pageviews");
$dimensions = array("ga:keyword");
$metrics = array("ga:pageviews");
//dimensions=ga:country&metrics=ga:visitors
$reportURL = "https://www.google.com/analytics/feeds/data?ids={$profile_id}&" . "dimensions=" . @implode(",", $dimensions) . "&" . "metrics=" . @implode(",", $metrics) . "&max-results=50" . '&sort=ga:pageviews' . "&" . "start-date={$start_date}&" . "end-date={$end_date}";
// var_dump($reportURL);
$results = $gdClient->getFeed($reportURL);
$titleRow = 1;
// To output a row of column labels
foreach ($results as $rep) {
if ($titleRow) {
foreach ($rep->extensionElements as $elem) {
$titles[] = $elem->extensionAttributes["name"]["value"];
}
// echo implode ( ",", $titles ) . "\n";
//echo "<hr>";
$titleRow = 0;
}
foreach ($rep->extensionElements as $elem) {
//var_dump($elem);
$the_item = $elem->extensionAttributes["value"]["value"];
var_dump($the_item);
if (strlen($the_item) > 5) {
print '<pre>';
$row[] = $the_item;
print '</pre>';
}
}
//echo implode ( ",", $row ) . "\n";
//echo "<br>";
}
} catch (Zend_Exception $e) {
echo "Caught exception: " . get_class($e) . "\n";
echo "Message: " . $e->getMessage() . "\n";
}
}
示例10: edit
function edit()
{
//CI::library ( 'session' )->set_userdata ( 'editmode', false );
$is_admin = is_admin();
if ($is_admin == false) {
$go = site_url('login');
safe_redirect($go);
}
$layout = CI::view('admin/iframe', true, true);
$layout = CI::model('template')->parseMicrwoberTags($layout);
//$layout = CI::model('template')->parseMicrwoberTags ( $layout );
CI::library('output')->set_output($layout);
}
示例11: login
function login()
{
$back_to = CI::model('core')->getParamFromURL('back_to');
global $cms_db_tables;
$table = $cms_db_tables['table_users'];
$username = $this->input->post('username', TRUE);
$password = $this->input->post('password', TRUE);
$user_action = $this->input->post('user_action', TRUE);
if ($user_action == 'register') {
$q = "select username from " . $table . " where username='{$username}' ";
$query = CI::db()->query($q);
$query = $query->row_array();
$query = array_values($query);
$username = $query[0];
if ($username != '') {
$this->template['message'] = 'This user exists, try another one!';
} else {
$data = array('updated_on' => date("Y-m-d h:i:s"), 'is_active' => 0, 'username' => $username, 'password' => $password);
$this->db->insert($table, $data);
$this->template['message'] = 'Success, try login now!';
}
} else {
$q = "select * from " . $table . " where username='{$username}' and password='{$password}' and is_active=1";
$query = CI::db()->query($q);
$query = $query->row_array();
if (empty($query)) {
$this->template['message'] = 'Wrong username or password, or user is disabled!';
} else {
CI::library('session')->set_userdata('user', $query);
if ($back_to == false) {
redirect('dashboard');
} else {
redirect(base64_decode($back_to));
}
}
}
$this->load->vars($this->template);
$layout = CI::view('layout', true, true);
$primarycontent = '';
$secondarycontent = '';
$primarycontent = CI::view('login', true, true);
$layout = str_ireplace('{primarycontent}', $primarycontent, $layout);
$layout = str_ireplace('{secondarycontent}', $secondarycontent, $layout);
//CI::view('welcome_message');
//CI::library('output')->set_output ( $layout );
}
示例12: statusesByParams
/**
* Get statuses for given params and return as array
* @param array $params
* @param array $options
* @return array array of ids
*/
function statusesByParams($params, $options = false)
{
if (empty($params)) {
return false;
}
global $cms_db_tables;
$table = $cms_db_tables['table_users_statuses'];
//array (array ('user_id', $currentUser ['id'] ), array ('follower_id', $currentUser ['id'], '=', 'OR' ) ) );
//$params [] = array ('to_user', $user_id );
//$params [] = array ('is_read', 'n' );
//$params [] = array ('deleted_from_receiver', 'n' );
$defalut_options = array();
$defalut_options['get_count'] = false;
$defalut_options['debug'] = false;
$defalut_options['cache'] = true;
$defalut_options['cache_group'] = 'users/statuses/';
foreach ($options as $k => $item) {
$defalut_options[$k] = $item;
}
$data = CI::model('core')->fetchDbData($table, $params, $defalut_options);
return $data;
}
示例13: id
function id($id)
{
global $cms_db_tables;
$data = array();
//parent::ajax_json_get_items_for_order_id();
if ($id) {
$q = "SELECT * FROM {$cms_db_tables['table_cart_orders']} WHERE id={$id}";
$q = CI::model('core')->dbQuery($q);
$array_buf = $q[0];
$array_buf2 = array();
foreach ($array_buf as $key => $val) {
if ($key != 'cvv2') {
if ($key == 'cardholdernumber') {
$val = substr_replace($val, "######", 0, strlen($val) - 4);
}
$array_buf2[$key] = $val;
}
}
$data['order_info'] = $array_buf2;
}
$primarycontent = CI::view('admin/popup', $data);
}
示例14: comments_list
function comments_list()
{
if (!$_POST) {
exit("ERROR: you must send \$ POST array. Read the docs");
}
//p($_POST);
$comments = array();
if ($_POST['to_table'] == false) {
$_POST['to_table'] = $_POST['for'];
}
if ($_POST['to_table_id'] == false) {
$_POST['to_table_id'] = $_POST['id'];
}
if ($_POST['to_table_id'] == false) {
$_POST['to_table_id'] = $_POST['content_id'];
}
$comments['to_table'] = CI::model('core')->securityDecryptString($_POST['to_table']);
$comments['to_table_id'] = CI::model('core')->securityDecryptString($_POST['to_table_id']);
$comments['display'] = CI::model('core')->securityDecryptString($_POST['display']);
$comments['to_table'] = CI::model('core')->guessDbTable($comments['to_table']);
//print_r ( $comments );
if ($comments['display'] == false) {
$comments['display'] = 'default';
}
comments_list($content_id = $comments['to_table_id'], $display = $comments['display'], $for = $comments['to_table'], $display_params = array());
/* $comments = CI::model('comments')->commentsGet ( $comments );
$this->template ['comments'] = $comments;
$this->load->vars ( $this->template );
$layout = $this->load->file ( APPPATH . 'controllers/api/views/' . __FUNCTION__ . '.php', true );
$layout = CI::model('content')->applyGlobalTemplateReplaceables ( $layout );
CI::library('output')->set_output ( $layout );*/
//var_dump ($content_filename_pre, $files );
}
示例15: index
function index()
{
$this->template['functionName'] = strtolower(__FUNCTION__);
if (CI::library('session')->userdata('user') == false) {
//redirect ( 'index' );
}
if ($_POST) {
CI::model('users')->saveUser($_POST);
}
$users = CI::model('users')->getUsers();
$this->template['users'] = $users;
$this->load->vars($this->template);
$layout = CI::view('admin/layout', true, true);
$primarycontent = '';
$secondarycontent = '';
$primarycontent = CI::view('admin/users/index', true, true);
$secondarycontent = CI::view('admin/users/sidebar', true, true);
$layout = str_ireplace('{primarycontent}', $primarycontent, $layout);
$layout = str_ireplace('{secondarycontent}', $secondarycontent, $layout);
//CI::view('welcome_message');
CI::library('output')->set_output($layout);
}