RE: [PHP] Insertion of integer in a database
| From: | Chris W. Parker | Date: | Wed, 23 Mar 2005 21:21:04 +0000 |
| Subject: | RE: [PHP] Insertion of integer in a database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-211415@lists.php.net to get a copy of this message | ||
david joffrin <mailto:david_joffrin@hotmail.com>
on Wednesday, March 23, 2005 1:01 PM said:
> So, I only had strings, but now I have introduced a timestamp column
> (bigint to cover the milleseconds)
Why not use VARCHAR instead? Timestamp doesn't need to be numeric does
it? For sure it's not required to be numeric.
> and I have the following statement:
> $queryInsert = "INSERT INTO mytables (..., timestamp)
> VALUES ('"; $queryInsert .= ...; // several columns
> $queryInsert .= "', '";
> $queryInsert .= time() . "')";
> $result = mysql_query($queryInsert);
May I suggest the following?
<?php
$timestamp = time();
$queryInsert = <<<QQQ
INSERT INTO mytables
(columnA
, columnB
, ...
, timestamp)
VALUES
('$valueA'
, '$valueB'
, ...
, $timestamp)
QQQ;
?>
HTH,
Chris.