<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # ThinkPHP6 雜項 --- ## `ThinkPHP6` 細節 ### 1、創建公用方法 ```php app/common.php 示例: /** * 取某天零點時間戳(本地時間) * @param number $time 欲獲取當日的時間戳 * return number 這天零點時間戳 */ function getZeroTime($time){ // Z 時差偏移量的秒數。UTC 西邊的時區偏移量總是負的,UTC 東邊的時區偏移量總是正的。 $timezone = date('Z', $time); $time += $timezone; $time = $time - $time % 86400 - $timezone; return $time; } ``` ```php controller示例: namespace app\index\controller; use app\BaseController; class Index extends BaseController{ public function index(){ $time = getZeroTime('1561785828'); print_r($time.'<br/>'); print_r(date('Y-m-d H:i:s',$time)); } } ``` ### 2、創建共用類方法 ```php BaseController 示例: /** * 取某天零點時間戳(本地時間) * @param number $time 欲獲取當日的時間戳 * return number 這天零點時間戳 */ public function getZeroTime($time){ // Z 時差偏移量的秒數。UTC 西邊的時區偏移量總是負的,UTC 東邊的時區偏移量總是正的。 $timezone = date('Z', $time); $time += $timezone; $time = $time - $time % 86400 - $timezone; return $time; } ``` ```php controller示例: namespace app\index\controller; use app\BaseController; class Index extends BaseController{ public function index(){ $time = $this->getZeroTime('1561785828'); print_r($time.'<br/>'); print_r(date('Y-m-d H:i:s',$time)); } } ``` ### 3、事務操作 * 使用事務處理的話,需要數據庫引擎支持事務處理。比如 `MySQL` 的 `MyISAM` 不支持事務處理,需要使用 `InnoDB` 引擎。 ```php namespace app\index\controller; use app\BaseController; use think\facade\Db; class Index extends BaseController{ public function index(){ Db::startTrans(); $delete = Db::table('admin')->delete(1); if($delete){ Db::commit(); }else{ Db::rollback(); } } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看