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


PHP JDate::toSQL方法代碼示例

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


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

示例1: loadSampleStatisticalData

    function loadSampleStatisticalData()
    {
        if (!($tem_id = $this->loadTemplate())) {
            return false;
        }
        if (!($news_private_id = $this->loadPrivateNewsletter($tem_id))) {
            return false;
        }
        if (!($news_public_id = $this->loadPublicNewsletter($tem_id))) {
            return false;
        }
        if (!$this->loadMessages($news_private_id, $news_public_id)) {
            return false;
        }
        $dbo =& $this->getDBO();
        $now = JFactory::getDate();
        for ($i = 0; $i < 60; $i++) {
            $num = (int) rand(15, 50);
            for ($j = 0; $j < $num; $j++) {
                $d = new JDate($now->toUNIX() - $i * 24 * 60 * 60 + rand(0, 24 * 60) * 60);
                $query = "INSERT INTO #__jinc_stats_event (type, date, news_id) " . "VALUES (0, '" . $d->toSQL() . "', {$news_private_id})";
                $dbo->setQuery($query);
                if (!$dbo->query()) {
                    $this->setError($dbo->getErrorMsg() . ': ' . $query);
                    return false;
                }
            }
            $num = (int) rand(5, 15);
            for ($j = 0; $j < $num; $j++) {
                $d = new JDate($now->toUNIX() - $i * 24 * 60 * 60 + rand(0, 24 * 60) * 60);
                $query = "INSERT INTO #__jinc_stats_event (type, date, news_id) " . "VALUES (1, '" . $d->toSQL() . "', {$news_private_id})";
                $dbo->setQuery($query);
                if (!$dbo->query()) {
                    $this->setError($dbo->getErrorMsg() . ': ' . $query);
                    return false;
                }
            }
            $num = (int) rand(15, 50);
            for ($j = 0; $j < $num; $j++) {
                $d = new JDate($now->toUNIX() - $i * 24 * 60 * 60 + rand(0, 24 * 60) * 60);
                $query = "INSERT INTO #__jinc_stats_event (type, date, news_id) " . "VALUES (0, '" . $d->toSQL() . "', {$news_public_id})";
                $dbo->setQuery($query);
                if (!$dbo->query()) {
                    $this->setError($dbo->getErrorMsg() . ': ' . $query);
                    return false;
                }
            }
            $num = (int) rand(5, 15);
            for ($j = 0; $j < $num; $j++) {
                $d = new JDate($now->toUNIX() - $i * 24 * 60 * 60 + rand(0, 24 * 60) * 60);
                $query = "INSERT INTO #__jinc_stats_event (type, date, news_id) " . "VALUES (1, '" . $d->toSQL() . "', {$news_public_id})";
                $dbo->setQuery($query);
                if (!$dbo->query()) {
                    $this->setError($dbo->getErrorMsg() . ': 

        

        

         

        ' . $query);
                    return false;
                }
            }
        }
        return true;
    }
開發者ID:sulicz,項目名稱:JINC_J30,代碼行數:68,代碼來源:tools.php


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