F
F
fokin_nikolay19892021-02-18 12:57:57
PHP
fokin_nikolay1989, 2021-02-18 12:57:57

How to pass date to Firebird?

tell me what is the problem? how to pass the date to SQ:L
After all, the date comes out in the right format

<?php
$strconnect = 'localhost';
if (!($db=ibase_connect($strconnect, 'sysdba', 'masterkey', 'ISO8859_1', 0, 1)))
    die('nil ' .  ibase_errmsg());
$d = date("d.m.Y");
echo $d;
  $sql  = "SELECT count(*) FROM P WHERE DATE = '$d'";
  $cursor = ibase_query($sql);
  $row_array = ibase_fetch_row($cursor);
  print_r($row_array);
  ibase_free_result($cursor);
  ibase_close($db);
?>

Error:
# php test.php
2/18/2021PHP Warning: ibase_query(): Dynamic SQL Error SQL error code = -206 Column unknown ID Client SQL dialect 1 does not support reference to BIGINT datatype in /var/www/html/stat/test .php on line 18
PHP Warning: ibase_fetch_row() expects parameter 1 to be resource, boolean given in /var/www/html/stat/test.php on line 19
PHP Warning: ibase_free_result() expects parameter 1 to be resource, boolean given in /var/www/html/stat/test.php on line 23

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
ThunderCat, 2021-02-18
@ThunderCat

1) DATE keyword, if you have such a field in the table, it must be surrounded by back quotes.
2) Table fields are wisely called in lower case and through underscore if the name contains several words
3) There is NOW () for skuel, which automatically substitutes the current date-time. You can use the date functions to generate a suitable format, the same DATE for example.
4) the date storage standard that most databases understand is "Ymd".

G
Gena, 2021-02-18
@brary

Date format like date("Ymd") or if you have timestamp you can strtotime('now')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question