RE: Insertion of integer in a database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



david joffrin <mailto:david_joffrin@xxxxxxxxxxx>
    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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux