Questions tagged [pg-query]
33 questions
3
votes
1 answer
SQLSTATE[42883]: Undefined function: 7 ERROR: function date_format(date, unknown) does not exist
I created this to compare is time now the same as time in my table row executes_at.
$dateNow = Carbon::now()->format('Y-m-d');
$hourNow = Carbon::now()->format('H');
$minuteNow = Carbon::now()->format('i');
$recordings = Recording::with('therapy')
…

Emia
- 55
- 8
3
votes
2 answers
pq_query Syntax Error because of a hyphen. How do i write this?
This does not work
$query = "SELECT * FROM time-lords WHERE user='thedoctor'";
I get this error:
Warning: pg_query(): Query failed: ERROR: syntax error at or near
"-"
This one does work
$query = "SELECT * FROM time_lords WHERE…

Rex Reyes
- 91
- 6
2
votes
1 answer
PHP Queries Not Working After MySQL to Postgres Conversion + Odd Errors
Setup
- PHP 7 app.
- Postgres is on Heroku Hobby v11.x
- MySQL version was v5.5.56 and protocol 10
- I do not have a great understanding of PHP
- I do not have a great knowledge of lower-level Postgres conversions.
I migrated from MySQL to…

cph
- 458
- 2
- 6
- 24
1
vote
0 answers
Cannot instal pg_query 1.3.0 with bundle install, mac M1 latest
I am new to this, I should install everything with bundle install and I am stuck at the pg_query 1.3.0 gem. It seems to show me error
linking shared-object pg_query/pg_query.bundle
ld: library not found for -lpg_query
clang: error: linker command…

DominikKraut
- 11
- 2
1
vote
1 answer
nodejs with express streaming http response
I have the following test code:
const compression = require('compression');
const bodyParser = require('body-parser')
const cors = require('cors')
const { pool, connectionString } = require('./config')
const { handleError, ErrorHandler } =…

schultz
- 316
- 2
- 14
1
vote
1 answer
How to destructure multiple query results in sequence?
I want to use the same pattern for destructuring query results, but seems I cannot. In the following code:
var {rows} = await client.query("SELECT id FROM mytable;");
var Id = rows[0].id; //destructured here as expected
if I then follow that…

Kenobi
- 465
- 6
- 13
1
vote
1 answer
unix second into postgres timestamp using php pg_query_params
I want to insert a unix timestamp value into a postgres timestamp column, using the PHP pg_query_params method, but get stuck.
Here's the incomplete code:
$con = pg_connect(...);
$stmt = 'INSERT INTO my_table (submitted) VALUES ($1)';
$ts =…

Gisela
- 1,194
- 2
- 16
- 30
1
vote
1 answer
shell command psql vs php pg_query performance
I have doubts about the speed of a query in postgres.
I run this query in psql (shell):
"EXPLAIN ANALYZE select * from historial where empresa = 2";
The result is:
Execution time: 125.064 ms
Then i run the same query with PHP:
$sql = "SELECT *…

Gonzalo Fernandez Larravide
- 91
- 1
- 2
1
vote
2 answers
Query in PHP with 'and' or 'or' as variable
I would like to do search for advanced search. The Search feature has and/or for every category. User can choose any combination of and n or. Here i give the screenshot
I store the and/or into variable call $pil, $pil1,$pil2 and $pil3. And will put…

Elbert
- 516
- 1
- 5
- 15
1
vote
2 answers
Why is my pg-query result throwing a TypeError
I am creating a node function to create a user in a PostgreSQL database. I'm using node.js, pg and pg-query to communicate from the app to the database.
Before I insert a new record Im trying to validate the email address does not already exist. …

ProfessionalAmateur
- 4,447
- 9
- 46
- 63
0
votes
1 answer
PgQuery gem not working after upgrade rails version from 5.1.3 to 5.2.3
Recently I updated my rails version from 5.1.3 to 5.2.3.
I deleted my Gemfile.lock file & run bundle install && bundle update command.
Now everything is working fine except pg_query. It shows me
undefined method `first' for…

Animesh
- 417
- 2
- 5
- 14
0
votes
2 answers
Add a column to select for order_by in Postgresql
I have a complicated db query that selects schools based on real estate listing attributes, performance statistics for the schools, and the distance of each listing to public transit. Users create a Search object, and a method find_schools in the…

tomb
- 1,374
- 1
- 13
- 23
0
votes
0 answers
postgres query takes longer when streaming in node : how to optimize?
This is how I query my data in Node :
const {Pool} = require('pg');
const QueryStream = require('pg-query-stream');
const CSVStream = require('../path/to/CSVStream');
const pool = new Pool({
host: "localhost",
port: 5432,
user: "blah",
…

Chapo
- 2,563
- 3
- 30
- 60
0
votes
1 answer
How to detect deadlocks in PostgreSQL when using PHP's pg_* functions?
I use transactions with PostgreSQL. Transactions are a necessary part of serious databasing. Transactions inevitably lead to "deadlocks". Deadlocks are logged as errors, as they are. I don't want to ever have any errors logged, so I need to handle…

Island Crumley
- 65
- 4
0
votes
0 answers
Why do PHP and PostgreSQL have wildly different ideas of what is valid UTF-8?
I have a $string in PHP. It doesn't matter where this comes from (it's from incoming e-mails); the important part is that sometimes, it's not valid UTF-8 according to PostgreSQL, but is valid according to PHP.
I explicitly set both…
user12686806