Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8QbA-0000H6-DM for pgsql-general@arkaria.postgresql.org; Tue, 27 Jul 2021 17:10:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m8Qb9-0003FL-DR for pgsql-general@arkaria.postgresql.org; Tue, 27 Jul 2021 17:10:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8Qb9-0003FA-3N for pgsql-general@lists.postgresql.org; Tue, 27 Jul 2021 17:10:31 +0000 Received: from srv01.teladesign.ie ([2001:41c9:1:41d::10]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8Qb7-00077W-4t for pgsql-general@postgresql.org; Tue, 27 Jul 2021 17:10:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rodonnell.ie; s=exim; h=Content-Transfer-Encoding:Content-Type:MIME-Version :Date:Message-ID:Subject:From:To:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Message-ID:In-Reply-To:References; bh=r6UnMj5La91mlkDhXGg9uvw3V971gIxc0Z4N+7s25OU=; b=FMousDNZrqxkzQwuAEnLE1knOX IziWvI0CaeUsiUd2YybDAAyTGtKzweKbxIJx11HCZlR/FjapTThWRi5i1JQGvKFPrITg72UPJvgzC H1dirynUjMwAdN+RtIbQcKwapuq2oaq47P/lkSH31UZVKF1GwDHjsgkO0iVNcqTPNXjM=; Received: from [93.107.231.214] (helo=[192.168.1.21]) by srv01.teladesign.ie with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m8Qb4-00024T-8W for pgsql-general@postgresql.org; Tue, 27 Jul 2021 18:10:26 +0100 To: 'PostgreSQL' From: Ray O'Donnell Subject: PHP: query with parameter for SET Message-ID: <73cf54bb-7bd8-78f2-7997-c4e7d1ac7b0c@rodonnell.ie> Date: Tue, 27 Jul 2021 18:10:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi everyone, Using PHP (or indeed maybe more generally), is it possible to issue a SET TIME ZONE statement with a parameter for the new runtime setting? In a PHP application I'm issuing a SET TIME ZONE command just after the database connection is created, and for security I'd like to pass the time zone value in a parameter, as it's coming from a configuration file - something like this: $pdo = new PDO(/* DSN goes here */); $statement = $pdo->prepare('set time zone :tz'); $statement->execute([':tz' => 'Europe/Dublin']); However, in the logs I see: ERROR: syntax error at or near "to" at character 15 STATEMENT: set time zone $1 Is this possible? I've also tried the "set timezone ..." variant with similar results. I'm wondering too if the limitation (if such it is) is in PHP or whether it's a Postgres thing. Thanks, Ray. -- Raymond O'Donnell // Galway // Ireland ray@rodonnell.ie