本文整理匯總了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;
}