PostgreSQL-9.4, PHP-7.
I have a table 'items' with the following structure:
user_id integer references users(user_id),
item_id integer,
is_removed numeric (1) default 0,
unix integer default EXTRACT(epoch FROM CURRENT_TIMESTAMP),
title varchar (30),
text text default null
\d+ items
in psql shows that 'user_id' is really integer, 'text' is really text and so on.
Then I insert the respective data, and select it like:
SELECT * FROM items WHERE user_id = $1 AND item_id = ANY($2::int[]) LIMIT 1;
And the following code outputs 'string string string string string string
':
while ($row = pg_fetch_assoc($data)) {
foreach ($row AS $val) {
echo gettype($val) . ' ';
}
}
Is it alright? And is it possible to make PG to return integers?