Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

PDO initialization unsafe #118

Open
Open

Description

@TGM

Usually i call this in a common file like a index or header

$psl = new phpSec\Core();
$psl['store'] = $psl->share(function($psl) {
$dsn = 'mysql:' .
'dbname=test;' .
'table=phpsec;' .
'host=localhost;' .
'username=databaseusername;' .
'password=databasepassword';
return new phpSec\Store\Pdo($dsn, $psl);
});

Definind the $dsn in such a major file seems really unsafe and unconfortable as well.

We need something like

$dsn = 'mysql:' .
'dbname=test;' .
'table=phpsec;' .
'host=localhost;' .
'username=databaseusername;' .
'password=databasepassword';
$psl = new phpSec\Core();
$psl['store'] = $psl->share(function($dsn, $psl) {
return new phpSec\Store\Pdo($dsn, $psl);
});

Any ideas?

Activity

  1. TGM commented on Jun 13, 2013

    @TGM
    Author

    I think this is the proper way to do it.

    $dsn = 'mysql:' .
    'dbname=test;' .
    'table=phpsec;' .
    'host=localhost;' .
    'username=databaseusername;' .
    'password=databasepassword';

    $psl['store'] = $psl->share(function($psl) use($dsn) {
    return new phpSec\Store\Pdo($dsn, $psl);
    });

  2. xqus commented on Jul 28, 2013

    @xqus
    Contributor

    This is a docimentation issue. The part describing the database connection should be updated.

  3. TGM commented on Jan 14, 2014

    @TGM
    Author

    Regarding the database connection.

    We should add

    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions