# Configuration in the php.ini file

- Thread: https://externals.io/message/45708
- Original archive: https://news-web.php.net/php.internals/45708
- Started by Samuel ROZE on 2009-10-09T13:21:38+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #45708 — Samuel ROZE — 2009-10-09T13:21:38+00:00

URL: https://externals.io/message/45708#45708

Hi,

I wanted to change a parameter in my PDO class, with the fourth
PDO::_construct arg. But, I've many projects, which uses PDO, with one
"new PDO" per project. The problem is that I have to change the source
of every projects...

Why isn't there an PDO section in the php.ini file ? For instance:

pdo.is_persistent = 1
pdo.fetch_notices = 1

...and more !

There isn't because nobody developed that or because it is contradicted ?

Samuel.

---

## #45709 — Pierre Joye — 2009-10-09T13:25:52+00:00

URL: https://externals.io/message/45708#45709 · In reply to: #45708

hi,

The general consensus is to do not add new ini settings unless it is
absolutely necessary. It is not the case for your example as it is
cleary an application configuration problem (user land configuration).

Cheers,
--
Pierre


> Hi,
>
> I wanted to change a parameter in my PDO class, with the fourth
> PDO::_construct arg. But, I've many projects, which uses PDO, with one
> "new PDO" per project. The problem is that I have to change the source
> of every projects...
>
> Why isn't there an PDO section in the php.ini file ? For instance:
>
> pdo.is_persistent = 1
> pdo.fetch_notices = 1
>
> ...and more !
>
> There isn't because nobody developed that or because it is contradicted ?
>
> Samuel.
>
> --
> 
> 
>
>



-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org

---

## #45710 — Samuel ROZE — 2009-10-09T13:31:11+00:00

URL: https://externals.io/message/45708#45710 · In reply to: #45709

It isn't. :-)
Thanks.

2009/10/9 Pierre Joye <pierre.php@gmail.com>:
> hi,
>
> The general consensus is to do not add new ini settings unless it is
> absolutely necessary. It is not the case for your example as it is
> cleary an application configuration problem (user land configuration).
>
> Cheers,
> --
> Pierre
>
> 
> > […]
>
>
>
> --
> Pierre
>
> http://blog.thepimp.net | http://www.libgd.org

---

## #45711 — Olivier B. — 2009-10-09T13:31:54+00:00

URL: https://externals.io/message/45708#45711 · In reply to: #45708

Hi

> There isn't because nobody developed that or because it is contradicted ?
here we extends the PDO class to configure it like we want.
For example :
class ourPDO
{
    public function __construct( $dsn, $user = NULL, $password = NULL, 
$options = `NULL` )
    {
        $defaultOptions = array(
            PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING,
            PDO::ATTR_TIMEOUT => 5,
            PDO::ATTR_CASE => PDO::CASE_NATURAL,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            );

        if( is_array($options) )
            $defaultOptions = $options + $defaultOptions;

        parent::__construct($dsn, $user, $password, $defaultOptions);
    }
}

and in code, we use $db = new ourPDO( ... );

---

## #45712 — Samuel ROZE — 2009-10-09T14:46:24+00:00

URL: https://externals.io/message/45708#45712 · In reply to: #45711

And I still have to modifiy my source. ;-)

In fact I'm using a personnaly Database class using PDO for add
execution times and array/string transformations. Actually, I just
wanted to know why there isn't any pdo propreties in the php.ini file.
Pierre replied.

Thanks !
Samuel.

2009/10/9 Olivier B. <php-dev.list@daevel.net>:
> Hi
>
> > […]
>
> here we extends the PDO class to configure it like we want.
> For example :
> class ourPDO
> {
>   public function __construct( $dsn, $user = NULL, $password = NULL,
> $options = `NULL` )
>   {
>       $defaultOptions = array(
>           PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING,
>           PDO::ATTR_TIMEOUT => 5,
>           PDO::ATTR_CASE => PDO::CASE_NATURAL,
>           PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
>           );
>
>       if( is_array($options) )
>           $defaultOptions = $options + $defaultOptions;
>
>       parent::__construct($dsn, $user, $password, $defaultOptions);
>   }
> }
>
> and in code, we use $db = new ourPDO( ... );

---

## #45737 — johannes@schlueters.de — 2009-10-12T10:37:45+00:00

URL: https://externals.io/message/45708#45737 · In reply to: #45708

Hi,


> I wanted to change a parameter in my PDO class, with the fourth
> PDO::_construct arg. But, I've many projects, which uses PDO, with one
> "new PDO" per project. The problem is that I have to change the source
> of every projects...
> 
> Why isn't there an PDO section in the php.ini file ? For instance:
> 
> pdo.is_persistent = 1
> pdo.fetch_notices = 1

Using these means two places have to be changed and monitored - the
application-specify configuration holding DSN, username and password and
the php.ini additionally. Some applications might have trouble if there
expectations about the environment isn't correct. The more ini settings
you have the more trouble ... these won'T be as troublesome as
magic_quotes but could still lead to unexpected behavior if the
developer doesn't expect them in some cases.

johannes
