PHP Wrappers - PDO

2 posts, 0 answers
  1. Paweł Kasztelan
    Paweł Kasztelan avatar
    17 posts
    Member since:
    Aug 2012

    Posted 18 Mar 2013 Link to this post

    Welcome. I downloaded the BETA version and started with Kendo testing in combination with MySQL.
    Even at the start I encountered a problem with the PDO.
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        header('Content-Type: application/json');
        $request = json_decode(file_get_contents('php://input'));
        $result = new DataSourceResult('mysql:host=localhost;dbname=databasename;charset=utf8', 'root', 'password');
        echo json_encode($result->read('acc_adr_Ewid', array('adr_Nazwa', 'adr_NazwaPelna', 'adr_Ulica'), $request));
    When trying to connect to a database using receives an error. As it turned out, even though you specify a user name and password PDO is created incorrectly.

    If you connect to the database should be developed DataSourceResult :: _construct

    Old code:
    function __construct($dsn) {
        $this->db = new PDO($dsn);
    Valid entry:
    function __construct($dsn, $username, $passwd, $opt) {
         $this->db = new PDO($dsn, $username, $passwd, $opt);
  2. Vladimir Iliev
    Vladimir Iliev avatar
    2155 posts

    Posted 20 Mar 2013 Link to this post

    Hi Marek,

    Thank you for reporting this problem! Indeed our using of PDO will only work for SQLite because the latter only requires the $dsn parameter. We will update our code to allow specifying $username, $password and $options.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET AJAX banner
Back to Top