[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-bugs
Subject: [DOC-BUGS] Doc #65465 [Com]: passing ArrayAccess to PDO constructor
From: "giw42161 at uooos dot com" <php-bugs () lists ! php ! net>
Date: 2022-07-04 7:31:06
Message-ID: E1o8GXy-0003jk-3x () bugs ! php ! net
[Download RAW message or body]
Edit report at https://bugs.php.net/bug.php?id=65465&edit=1
ID: 65465
Comment by: giw42161 at uooos dot com
Reported by: gongteng524702837 at gmail dot com
Summary: passing ArrayAccess to PDO constructor
Status: Not a bug
Type: Documentation Problem
Package: PDO related
Operating System: linux 64bit
PHP Version: 5.5.2
Block user comment: N
Private report: N
New Comment:
(https://centurylawfirm.in/)gist.github.com
(https://centurylawfirm.in/blog/divorce-lawyer-in-delhi-2/)gist.github.com
(https://centurylawfirm.in/blog/debt-recovery-tribunal-drt/)gist.github.com
(https://centurylawfirm.in/blog/get-bail-in-india/)gist.github.com
(https://centurylawfirm.in/blog/best-lawyer-for-criminal-case/)gist.github.com
(https://centurylawfirm.in/blog/high-court-cases/)gist.github.com
(https://centurylawfirm.in/blog/cheque-bounce-case/)gist.github.com
(https://centurylawfirm.in/blog/how-to-take-mutual-divorce/)gist.github.com
Previous Comments:
------------------------------------------------------------------------
[2022-03-26 05:05:37] giw42161 at uooos dot com
(https://centurylawfirm.in/)gist.github.com
------------------------------------------------------------------------
[2014-02-01 09:14:57] krakjoe@php.net
Arrays and objects are not interchangeable, if a function is prototyped to accept an \
array then you must pass it an array, not an object.
Not a bug.
------------------------------------------------------------------------
[2013-08-17 13:16:34] gongteng524702837 at gmail dot com
Description:
------------
Passing object that implement ArrayAccess interface to PDO constructor(forth
param), the constructor will return NULL, no Exception raised.
(I‘m not sure is the bug come from PDO or ArrayAccess.)
Test script:
---------------
$config = array(...);
$options = new SomeObjImplArrAcc(); // just an empty object
$pdo = new PDO($config['dsn'],$config['user'],$config['pass'],$options);
var_dump($pdo); // <- NULL
$options[PDO::ATTR_PERSISTENT] = true; // or have some elements
$pdo = new PDO($config['dsn'],$config['user'],$config['pass'],$options);
var_dump($pdo); // <- NULL
// but success if convert to "native" array
$pdo = new PDO($config['dsn'],$config['user'],$config['pass'],(array)$options);
var_dump($pdo); // <- {PDO}[0]
Expected result:
----------------
construct three same PDO object
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65465&edit=1
--
PHP Documentation Bugs Mailing List (https://www.php.net/)
To unsubscribe, visit: https://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic