當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Manager::selectOne方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Capsule\Manager::selectOne方法的典型用法代碼示例。如果您正苦於以下問題:PHP Manager::selectOne方法的具體用法?PHP Manager::selectOne怎麽用?PHP Manager::selectOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Capsule\Manager的用法示例。


在下文中一共展示了Manager::selectOne方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRawQueries

 public function testRawQueries()
 {
     // Insert
     $inserted = Capsule::insert('INSERT INTO articles (title) VALUES (:title)', ['title' => static::ARTICLE_TITLE]);
     $this->assertTrue($inserted);
     // Last Insert ID
     $id = Capsule::connection()->getPdo()->lastInsertId();
     $this->assertEquals(1, $id);
     // Select
     $articles = Capsule::select('SELECT * FROM articles WHERE id = ?', [$id]);
     $this->assertCount(1, $articles);
     $this->assertEquals($articles[0]->title, static::ARTICLE_TITLE);
     // Delete
     $deleted = Capsule::delete('DELETE FROM articles WHERE id = ?', [$id]);
     $this->assertEquals(1, $deleted);
     // Count
     $count = Capsule::selectOne('SELECT COUNT(*) as nb FROM articles');
     $this->assertEquals(0, $count->nb);
 }
開發者ID:jguyomard,項目名稱:silex-capsule-eloquent,代碼行數:19,代碼來源:CapsuleServiceProviderTest.php

示例2: statistics

 /**
  * 係統信息 - 基本信息
  */
 public function statistics()
 {
     $statistics = array();
     /*
      * 重要: 為了防止與應用別名重名,“服務器信息”、“用戶信息”、“開發團隊”作為key前麵有空格
      */
     // 服務器信息
     //$site_version = model('Xdata')->get('siteopt:site_system_version');
     $serverInfo[L('PUBLIC_CORE_VERSION')] = 'TS V' . C('VERSION');
     $serverInfo[L('PUBLIC_SERVER_PHP')] = PHP_OS . ' / PHP v' . PHP_VERSION;
     $serverInfo[L('PUBLIC_SERVER_SOFT')] = $_SERVER['SERVER_SOFTWARE'];
     $serverInfo[L('PUBLIC_UPLOAD_PERMISSION')] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : '<font color="red">no</font>';
     // 數據庫信息
     $mysqlinfo = Capsule::selectOne('SELECT VERSION() AS version');
     $serverInfo[L('PUBLIC_MYSQL')] = $mysqlinfo['version'];
     $t = D('')->query("SHOW TABLE STATUS LIKE '" . C('DB_PREFIX') . "%'");
     $dbsize = 0;
     foreach ($t as $k) {
         $dbsize += $k['Data_length'] + $k['Index_length'];
     }
     $umap['is_del'] = 0;
     $userInfo['totalUser'] = model('User')->where($umap)->count();
     // 用戶總數
     $aumap['ctime'] = array('GT', time() - 24 * 3600 * 30);
     // 1個月內登錄過的用戶
     $userInfo['activeUser'] = D('login_record')->where($aumap)->count();
     $ymap['day'] = date('Y-m-d', strtotime('-1 day'));
     $d = D('online_stats')->where($ymap)->find();
     $userInfo['yesterdayUser'] = $d['most_online'];
     $onmap['uid'] = array('GT', 0);
     $onmap['activeTime'] = array('GT', time() - 1800);
     $userInfo['onlineUser'] = count(D()->table(C('DB_PREFIX') . 'online')->where($onmap)->findAll());
     $onmap['uid'] = 0;
     $userInfo['onlineUser'] += count(D()->table(C('DB_PREFIX') . 'online')->where($onmap)->findAll());
     // 加上遊客
     $ymap['day'] = array('GT', date('Y-m-d', strtotime('-7 day')));
     $d = D('online_stats')->where($ymap)->field('max(most_online) AS most_online')->find();
     $userInfo['weekAvg'] = $d['most_online'];
     $this->assign('userInfo', $userInfo);
     $ymap['day'] = array('GT', date('Y-m-d', strtotime('-7 day')));
     $d = D('online_stats')->where($ymap)->getHashList('day', '*');
     $visitCount = array();
     $today = date('Y-m-d');
     $yesterday = date('Y-m-d', strtotime('-1 day'));
     $visitCount['today'] = array('pv' => $d[$today]['total_pageviews'], 'pu' => $d[$today]['total_users'], 'guest' => $d[$today]['total_guests']);
     $visitCount['yesterday'] = array('pv' => $d[$yesterday]['total_pageviews'], 'pu' => $d[$yesterday]['total_users'], 'guest' => $d[$yesterday]['total_guests']);
     $apv = 0;
     $apu = 0;
     $agu = 0;
     foreach ($d as $v) {
         $apv += $v['total_pageviews'];
         $apu += $v['total_users'];
         $agu += $v['total_guests'];
     }
     $visitCount['weekAvg'] = array('pv' => ceil($apv / count($d)), 'pu' => ceil($apu / count($d)), 'guest' => ceil($agu / count($d)));
     $this->assign('visitCount', $visitCount);
     $serverInfo[L('PUBLIC_DATABASE_SIZE')] = byte_format($dbsize);
     $statistics[L('PUBLIC_SERVER_INFORMATION')] = $serverInfo;
     unset($serverInfo);
     // 開發團隊
     $statistics[L('PUBLIC_DEV_TEAM')] = array(L('PUBLIC_COPYRIGHT') => '<a href="http://www.zhishisoft.com" target="_blank">' . L('PUBLIC_COMPANY') . '</a>');
     $this->assign('statistics', $statistics);
     $this->display();
 }
開發者ID:medz,項目名稱:thinksns-4,代碼行數:67,代碼來源:HomeAction.class.php


注:本文中的Illuminate\Database\Capsule\Manager::selectOne方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。