This is a migrated thread and some comments may be shown as answers.

PHP Wrappers - PDO

1 Answer 266 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paweł Kasztelan
Top achievements
Rank 2
Paweł Kasztelan asked on 18 Mar 2013, 12:12 PM
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.
Doc: http://php.net/manual/pl/ref.pdo-mysql.php
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));
 
    exit;
}
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);
 }

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 20 Mar 2013, 08:55 AM
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!
Tags
Grid
Asked by
Paweł Kasztelan
Top achievements
Rank 2
Answers by
Vladimir Iliev
Telerik team
Share this question
or