Convert from timestamp to datetime. Datetime is consistent between mysql 4.0x and newer

versions and is faster for date/time computations. Modify object creation methods to specify
any time fields that were previously updated with timestamp properties.
This commit is contained in:
Chris Morgan
2007-07-31 23:48:22 +00:00
committed by WineHQ
parent 8b7fdf606c
commit b94a2a392b
22 changed files with 96 additions and 81 deletions

View File

@@ -153,7 +153,7 @@ class appData
$sLink,
$oRow->type,
$oRow->description,
print_date(mysqltimestamp_to_unixtimestamp($oRow->submitTime))),
print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime))),
($i % 2) ? "color0" : "color1");
}
@@ -500,7 +500,7 @@ class appData
$oUser = new User($this->iSubmitterId);
$oTableRow = new TableRow();
$oTableRow->AddTextCell(print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime)));
$oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($this->sSubmitTime)));
$oTableRow->AddTextCell($oUser->objectMakeLink());
$oTableRow->AddTextCell($oApp->objectMakeLink());
$oTableRow->AddTextCell($this->iVersionId ? $oVersion->objectMakeLink() : "N/A");

View File

@@ -121,12 +121,14 @@ class Application {
if(!$_SESSION['current']->canCreateApplication())
return;
$hResult = query_parameters("INSERT INTO appFamily (appName, description, keywords, ".
"webPage, vendorId, catId, submitterId, queued) VALUES (".
"'?', '?', '?', '?', '?', '?', '?', '?')",
$hResult = query_parameters("INSERT INTO appFamily (appName, description, ".
"keywords, webPage, vendorId, catId, ".
"submitTime, submitterId, ".
"queued) VALUES (".
"'?', '?', '?', '?', '?', '?', ?, '?', '?')",
$this->sName, $this->sDescription, $this->sKeywords,
$this->sWebpage, $this->iVendorId, $this->iCatId,
$_SESSION['current']->iUserId,
"NOW()", $_SESSION['current']->iUserId,
$this->mustBeQueued() ? "true" : "false");
if($hResult)
{
@@ -804,7 +806,7 @@ class Application {
$oTableRow->AddTextCell($oApp->objectMakeLink());
$oTableRow->AddTextCell($oRow->description);
$oTableRow->AddTextCell($oVendor->objectMakeLink());
$oTableRow->AddTextCell(print_date(mysqltimestamp_to_unixtimestamp($oRow->submitTime)));
$oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime)));
$oTableRow->SetClass(($i % 2) ? "color0" : "color1");
$oTable->AddRow($oTableRow);
@@ -902,7 +904,7 @@ class Application {
$sVendor = $oVendor->objectMakeLink();
$oTableRow = new TableRow();
$oTableRow->AddTextCell(print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime)));
$oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($this->sSubmitTime)));
$oTableRow->AddTextCell($oUser->objectMakeLink());
$oTableRow->AddTextCell($sVendor);
$oTableRow->AddTextCell($this->sName);

View File

@@ -77,7 +77,7 @@ class browse_newest_apps
$oTableRow = new TableRow();
$oTableCell = new TableCell(print_short_date(mysqltimestamp_to_unixtimestamp($oApp->sSubmitTime)));
$oTableCell = new TableCell(print_short_date(mysqldatetime_to_unixtimestamp($oApp->sSubmitTime)));
$oTableCell->SetWidth("20%");
$oTableRow->AddCell($oTableCell);
$oTableRow->AddTextCell($oApp->objectMakeLink());

View File

@@ -120,11 +120,13 @@ class Bug {
/* passed the checks so lets insert the puppy! */
$hResult = query_parameters("INSERT INTO buglinks (versionId, bug_id, queued, submitterId) ".
"VALUES('?', '?', '?', '?')",
$hResult = query_parameters("INSERT INTO buglinks (versionId, bug_id, ".
"submitTime, submitterId, queued) ".
"VALUES('?', '?', ?, '?', '?')",
$this->iVersionId, $this->iBug_id,
$this->bQueued ? "true":"false",
$_SESSION['current']->iUserId);
"NOW()",
$_SESSION['current']->iUserId,
$this->bQueued ? "true":"false");
if($hResult)
{
$this->iLinkId = mysql_insert_id();
@@ -279,7 +281,7 @@ class Bug {
$oBug->sBug_status,
$oBug->sResolution,
$oBug->sShort_desc,
print_date(mysqltimestamp_to_unixtimestamp($oRow->submitTime))),
print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime))),
($i % 2) ? "color0" : "color1");
}

View File

@@ -99,9 +99,11 @@ class distribution {
}
}
$hResult = query_parameters("INSERT INTO distributions (name, url, submitterId, queued) ".
"VALUES ('?', '?', '?', '?')",
$hResult = query_parameters("INSERT INTO distributions (name, url, submitTime, ".
"submitterId, queued) ".
"VALUES ('?', '?', ?, '?', '?')",
$this->sName, $this->sUrl,
"NOW()",
$_SESSION['current']->iUserId,
$this->mustBeQueued() ? "true" : "false");
if($hResult)
@@ -570,7 +572,7 @@ class distribution {
else
echo $oSubmitter->sRealname;
echo '</td>',"\n";
echo '<td>'.date("M d Y", mysqltimestamp_to_unixtimestamp($oTest->sSubmitTime)).'</td>',"\n";
echo '<td>'.date("M d Y", mysqldatetime_to_unixtimestamp($oTest->sSubmitTime)).'</td>',"\n";
echo '<td>'.$oTest->sTestedRelease.'&nbsp</td>',"\n";
echo '<td>'.$oTest->sInstalls.'&nbsp</td>',"\n";
echo '<td>'.$oTest->sRuns.'&nbsp</td>',"\n";

View File

@@ -297,11 +297,13 @@ class downloadurl
return FALSE;
$hResult = query_parameters("INSERT INTO appData (versionId, type,
description, url, queued, submitterId)
VALUES('?','?','?','?','?','?')",
description, url, queued, submitTime, submitterId)
VALUES('?', '?', '?', '?', '?', ?, '?')",
$this->iVersionId, "downloadurl", $this->sDescription,
$this->sUrl, downloadurl::canEdit($this->iVersionId) ?
"false" : "true", $_SESSION['current']->iUserId);
$this->sUrl,
downloadurl::canEdit($this->iVersionId) ? "false" : "true",
"NOW()",
$_SESSION['current']->iUserId);
$this->iId = mysql_insert_id();
if(!$hResult)

View File

@@ -75,9 +75,11 @@ class Monitor {
return FALSE;
// create the new monitor entry
$hResult = query_parameters("INSERT INTO appMonitors (versionId, appId, userId) ".
"VALUES ('?', '?', '?')",
$this->iVersionId, $this->iAppId, $this->iUserId);
$hResult = query_parameters("INSERT INTO appMonitors (versionId, appId,".
"submitTime, userId) ".
"VALUES ('?', '?', ?, '?')",
$this->iVersionId, $this->iAppId,
"NOW()", $this->iUserId);
if($hResult)
{

View File

@@ -53,11 +53,14 @@ class Note {
*/
function create()
{
$hResult = query_parameters("INSERT INTO appNotes (versionId, noteTitle, noteDesc, submitterId) ".
"VALUES('?', '?', '?', '?')",
$hResult = query_parameters("INSERT INTO appNotes (versionId, ".
"noteTitle, noteDesc, submitterId, ".
"submitTime) ".
"VALUES('?', '?', '?', '?', ?)",
$this->iVersionId, $this->sTitle,
$this->shDescription,
$_SESSION['current']->iUserId);
$_SESSION['current']->iUserId,
"NOW()");
if($hResult)
{
@@ -154,7 +157,8 @@ class Note {
$oSubmitter = new User($this->iSubmitterId);
$sSubject = "Note $this->sTitle for $sAppName has been deleted by ".
$_SESSION['current']->sRealname;
$sMsg .= "This note was made on ".print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime))." by ".$oSubmitter->sRealname."\n";
$sMsg .= "This note was made on ".print_date(mysqldatetime_to_unixtimestamp($this->sSubmitTime)).
" by ".$oSubmitter->sRealname."\n";
$sMsg .= "\n";
$sMsg .= "Subject: ".$this->sTitle."\n";
$sMsg .= "\n";

View File

@@ -71,11 +71,12 @@ class screenshot
function create()
{
$hResult = query_parameters("INSERT INTO appData
(versionId, type, description, queued, submitterId)
VALUES('?', '?', '?', '?', '?')",
(versionId, type, description, queued, submitTime, submitterId)
VALUES('?', '?', '?', '?', ?, '?')",
$this->iVersionId, "screenshot",
$this->sDescription,
$this->mustBeQueued() ? "true" : "false",
"NOW()",
$_SESSION['current']->iUserId);
if($hResult)
{

View File

@@ -65,9 +65,11 @@ class testData{
{
$hResult = query_parameters("INSERT INTO testResults (versionId, whatWorks, whatDoesnt,".
"whatNotTested, testedDate, distributionId, testedRelease,".
"installs, runs, testedRating, comments, submitterId, queued)".
" VALUES('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',".
"'?', '?')",
"installs, runs, testedRating, comments,".
"submitTime, submitterId, queued)".
"VALUES('?', '?', '?', '?', '?', '?', '?',".
"'?', '?', '?', '?',".
"?, '?', '?')",
$this->iVersionId, $this->shWhatWorks,
$this->shWhatDoesnt,
$this->shWhatNotTested, $this->sTestedDate,
@@ -75,6 +77,7 @@ class testData{
$this->sTestedRelease, $this->sInstalls,
$this->sRuns,
$this->sTestedRating, $this->sComments,
"NOW()",
$_SESSION['current']->iUserId,
$this->mustBeQueued() ? "true" : "false");
@@ -812,7 +815,7 @@ class testData{
version::fullNameLink($oRow->versionId),
$oRow->testedRating,
$oRow->testedRelease,
print_date(mysqltimestamp_to_unixtimestamp($oRow->submitTime))),
print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime))),
$oRow->testedRating);
$sReturn .= html_table_end();
@@ -1014,7 +1017,7 @@ class testData{
$bHasMaintainer = (mysql_num_rows($hMaintainers) == 0) ? false : true;
$oTableRow = new TableRow();
$oTableRow->AddCell(new TableCell(print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime))));
$oTableRow->AddCell(new TableCell(print_date(mysqldatetime_to_unixtimestamp($this->sSubmitTime))));
$oTableRow->AddCell(new TableCell($oUser->objectMakeLink()));
$oTableRow->AddCell(new TableCell($oApp->objectMakeLink()));
$oTableRow->AddCell(new TableCell($oVersion->objectMakeLink()));

View File

@@ -54,7 +54,8 @@ class Url {
/**
* Creates a new url.
*/
function create($sDescription = null, $sUrl = null, $iVersionId = null, $iAppId = null, $bSilent = false)
function create($sDescription = null, $sUrl = null, $iVersionId = null,
$iAppId = null, $bSilent = false)
{
global $aClean;
@@ -64,11 +65,11 @@ class Url {
$this->bQueued = true;
$hResult = query_parameters("INSERT INTO appData (appId, versionId, type,
description, queued, submitterId, url)
VALUES ('?', '?', '?', '?', '?', '?', '?')",
description, queued, submitTime, submitterId, url)
VALUES ('?', '?', '?', '?', '?', ?, '?', '?')",
$iAppId, $iVersionId, "url", $sDescription,
$this->bQueued ? "true" : "false",
$_SESSION['current']->iUserId, $sUrl);
"NOW()", $_SESSION['current']->iUserId, $sUrl);
if(!$hResult)
{

View File

@@ -44,7 +44,6 @@ function build_urlarg($vars)
return implode("&", $arr);
}
/*
* return all values of a mapping as an array
*/
@@ -56,7 +55,6 @@ function values($arr)
return $res;
}
// print the month, day, year, hour, minute, second
function print_date($sTimestamp)
{
@@ -99,10 +97,7 @@ function mysqltimestamp_to_unixtimestamp($sTimestamp)
function mysqldatetime_to_unixtimestamp($sDatetime)
{
sscanf($sDatetime, "%4s-%2s-%2s %2s:%2s:%2s",
&$y, &$m, &$d,
&$hours, &$minutes, &$seconds);
return mktime($hours,$minutes,$seconds,$m, $d, $y);
return strtotime($sDatetime);
}
function get_remote()

View File

@@ -86,10 +86,11 @@ class version {
$hResult = query_parameters("INSERT INTO appVersion
(versionName, description, maintainer_release,
maintainer_rating, appId, submitterId, queued, license)
VALUES ('?', '?', '?', '?', '?', '?', '?', '?')",
maintainer_rating, appId, submitTime, submitterId,
queued, license)
VALUES ('?', '?', '?', '?', '?', ?, '?', '?', '?')",
$this->sName, $this->sDescription, $this->sTestedRelease,
$this->sTestedRating, $this->iAppId,
$this->sTestedRating, $this->iAppId, "NOW()",
$_SESSION['current']->iUserId, $this->sQueued,
$this->sLicense);
@@ -1216,7 +1217,7 @@ class version {
$oTableRow = new TableRow();
$oTableRow->AddTextCell(version::fullNameLink($oRow->versionId));
$oTableRow->AddTextCell($oRow->description);
$oTableRow->AddTextCell(print_date(mysqltimestamp_to_unixtimestamp($oRow->submitTime)));
$oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime)));
$oTableRow->SetClass(($i % 2) ? "color0" : "color1");
$oTable->AddRow($oTableRow);
@@ -1515,7 +1516,7 @@ class version {
$oVendor = new vendor($oApp->iVendorId);
$oTableRow = new TableRow();
$oTableRow->AddTextCell(print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime)));
$oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($this->sSubmitTime)));
$oTableRow->AddTextCell($oUser->objectMakeLink());
$oTableRow->AddTextCell($oVendor->objectMakeLink());
$oTableRow->AddTextCell($oApp->objectMakeLink());

View File

@@ -68,7 +68,7 @@ function vote_add($iVersionId, $iSlot, $iUserId = null)
vote_remove($iSlot, $iUserId);
query_parameters("INSERT INTO appVotes (id, time, versionId, userId, slot)
VALUES (?, ?, '?', '?', '?')", "null", "null",
VALUES (?, ?, '?', '?', '?')", "null", "NOW()",
$iVersionId, $iUserId, $iSlot);
}