Question: I'm setting up a PHP script that connects to the 4D Database on my local system.

However, I keep getting:

```
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user ''@'localhost' to database 'tester'' in /Applications/MAMP/htdocs/4d/index.php:8 Stack trace: #0 /Applications/MAMP/htdocs/4d/index.php(8): PDO->__construct('mysql:host=loca...', 'XXXX', 'XXXX') #1 {main} thrown in /Applications/MAMP/htdocs/4d/index.php on line 8

```

I don't know HOW and WHERE to set the username & password for permissions for PHP to connect to the database :/

Any help is appreciated.

Simple code:

```
$db = new PDO('mysql:host=localhost;dbname=tester', "tester", "");

try {
echo "OK";
} catch (PDOException $e) {
die("Error 4D : " . $e->getMessage());
}

```

Answer: 
Subclassing `list`
------------------

If you insist, you can subclass `list`:

```
class ListContainer(list):
    def play(self, *args, **kwargs):
        for item in self:
            item.play(*args, **kwargs)
    def close(self, *args, **kwargs):
        for item in self:
            item.close(*args, **kwargs)

```

(Btw. Anything you will pass to the container method, will be passed to every item, unless error occurs)

Which would work like that:

```
>>> class Sound(object):
    def __init__(self, name):
        self.name = name
    def play(self):
        print('Playing %s' % (self.name,))
    def close(self):
        print('Closing %s' % (self.name,))

>>> container = ListContainer([Sound('a'), Sound('b'), Sound('c')])
>>> container.play()
Playing a
Playing b
Playing c
>>> container.close()
Closing a
Closing b
Closing c

```

Better solution
---------------

But you should not. The better solution is to do it explicitly:

```
container = [a, b, c]
# ...
for item in container:
    item.play()

```

Remember, that *explicit is better than implicit*. This is why it is often better to iterate through the items and call them one by one.

Worse solution
--------------

If you want to implicitly call methods of list items, there is a way ;) Below is the implementation that will first search for `list` attribute, and if not found, will assume it is a method and will call every item in a list:

```
class BadImplicitContainer(list):
    def __getattr__(self, name):
        def _wrapper(*args, **kwargs):
            for item in self:
                getattr(item, name)(*args, **kwargs)
        return _wrapper

```

And this is how it would behave with examples from previous snippets:

```
>>> container = BadImplicitContainer([Sound('bad'), Sound('Bad'), Sound('BAD')])
>>> container.play()
Playing bad
Playing Bad
Playing BAD

```
[`map()`](http://docs.python.org/2/library/functions.html#map) should do the trick

Try this:

```
map(MyListClass.play,my_list)

```

`map()` takes two arguments, a function and an iterable, as shown above.