record time in Postgresql database

Asked

Viewed 473 times

2

In the application I inform the start and end time of the activity, and save this information in the bank.

Segue Query:

$status = $_GET['status'];
$intervalo = $_GET['intervalo'];
$dataini = $_GET['horainicio']."<br>";
$horainicio = date('H:i:s',$dataini);
$datafim = $_GET['horafinal']."<br>";
$horafinal = date('H:i:s',$datafim);
$qtdtentativas = $_GET['qtdtentativas'];
$destino = $_GET['destino'];
$skill = $_GET['skill'];
$pacing = $_GET['pacing'];
$prefixo = $_GET['prefixo'];



$query = sprintf("update bettaivr.public.ivr_campanha set status = %d,horainicio = %d,horafinal = %d, intervalo = %d, pacing = %d, qtdtentativas = %d  where id = %s",
$status,$horainicio ,$horafinal ,$intervalo, $pacing, $qtdtentativas,$campanha);

However I can not keep the schedules in the bank, it returns 0 always. How can I keep this schedule in the bank?

Error signaled when executing query:

Problem with query update bettaivr.public.ivr_campanha set status = 0,horainicio = '0', horafinal = '0', interval = 20, pacing = 1, qtdtentativas = 5 Where id = 4

  • What kind of data is in the time field of the database?

  • 1

    this as team in the bank.

  • time fields are among apostrophes??

  • no bank. in the application are as demonstrated, I added the answer that comes from the bank

1 answer

2


Your problem is here:

$horafinal = date('H:i:s',$datafim);
$horainicio = date('H:i:s',$dataini);

try like this:

$horafinal = date('H:i:s',strtotime($datafim));
$horainicio = date('H:i:s',strtotime($dataini));

And use the query that way:

$query = "
    UPDATE 
        bettaivr.public.ivr_campanha 
    SET 
        status = '$status',
        horainicio = '$horainicio',
        horafinal = '$horafinal',
        intervalo = '$intervalo',
        pacing = '$pacing',
        qtdtentativas = '$qtdtentativas'
    WHERE id = '$campanha'
";
  • Some references from the documentation on date and strtotime:

strtotime - Interprets any date/time description in English text in Unix timestamp

date - Format date and local time. Returns a string according to the format string given using the given integer timestamp

  • Still not solved, the problem persisted. he returned this error ERROR: column "horainicio" is of type time without time zone but Expression is of type integer LINE 1: ...r.public.ivr_campaign set status = 0,horainicio = 0,horafina... HINT: You will need to rewrite or cast the Expression.

  • when I write to the database: sprintf("update bettaivr.public.ivr_campaign set status = %d, horainicio = %i ,horafinal = %i, interval = %d, pacing = %d, qtdtentativas = %d Where id = %s", $status,$hour start ,$hour end ,$interval, $pacing, $qtdtentativas,$campaign); I think the writing format might be wrong, but I don’t think it’s right

  • I edited the answer, try there to see, using what I said tbm about the time variables, since the error accuses that the value is being passed in type int

  • Show man, already started to give another face to the query, now the error is variable that receives.. ERROR: invalid input syntax for integer: "08:00:00" LINE 9: pacing = '08:00:00',

  • It is indicating integer error, saying that the type is int, check this

  • 1

    the mistake he made was that the pacing field should not receive the time, for some reason when I do the get it takes the dataini data, but it’s working.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.