Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

INT to DATATIME

Asked Modified Viewed 1,494 times
K
kaka
K
kaka 10
  • Junior Member, joined since
  • Contributed 21 posts on the community forums.
  • Started 7 threads in the forums
  • Started this discussions
asked
Junior Member

Hi ppl,

As you know Php-fusion use INT type for storing publishing data of news, artickels...etc. But I want to convert this INT to DATATIME on my sql database. Anyone knows the solution?

Thnx a lot!
0 replies

2 posts

K
kneekoo
K
  • Senior Member, joined since
  • Contributed 289 posts on the community forums.
  • Started 12 threads in the forums
  • Answered 1 question
answered
Senior Member

WARNING! Just as SiteMaster told you above, changing the table structures means you will also have to adjust the PHP code in your depending files or you will have troubles.

Here's a sample query to convert the article_datestamp from INT to DATETIME:
<?php
$convert = dbquery("ALTER TABLE ".DB_ARTICLES." CHANGE article_datestamp article_datestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'");
echo "<div class='tbl-border tbl2' align='center'><b>";
if ($convert) {
    echo "Column converted successfully.";
} else {
    echo "Conversion failed.";
}
echo "</b></div>";
?>


To revert the changes above and get back to PHPFusion's default table setup, use the code below:
<?php
$convert = dbquery("ALTER TABLE ".DB_ARTICLES." CHANGE article_datestamp article_datestamp INT(10) UNSIGNED NOT NULL DEFAULT '0'");
echo "<div class='tbl-border tbl2' align='center'><b>";
if ($convert) {
    echo "Column converted successfully.";
} else {
    echo "Conversion failed.";
}
echo "</b></div>";
?>


Notes:
1. Remember to backup your website before performing any changes.
2. The code above is only compatible with PHPFusion v7.x and must be executed through the Custom Pages inside the Admin Panel -> Content Admin.
3. It's DATETIME, not DATATIME.

Good luck!
Edited by kneekoo on 04-05-2010 16:32,
0 replies
S
SiteMaster
S
If i have touched it, it's W3C Valid
  • Senior Member, joined since
  • Contributed 305 posts on the community forums.
  • Started 15 threads in the forums
answered
Senior Member

and why would you want that, you then need to edit every PF files where the date and time are shown.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 2 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

K
K
kaka 10
  • Junior Member, joined since
  • Contributed 21 posts on the community forums.
  • Started 7 threads in the forums
  • Started this discussions
K
K
  • Senior Member, joined since
  • Contributed 289 posts on the community forums.
  • Started 12 threads in the forums
  • Answered 1 question
S
S
If i have touched it, it's W3C Valid
  • Senior Member, joined since
  • Contributed 305 posts on the community forums.
  • Started 15 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet