$pdo = new PDO ( $dsn, $user, $pass, $options ) PDO :: ATTR_DEFAULT_FETCH_MODE => PDO :: FETCH_ASSOC , PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION , $dsn = "mysql:host= $host dbname= $db charset= $charset " Here goes an example for mysql: $host = '127.0.0.1' Note that it's important to follow the proper format - no spaces or quotes or other decorations have to be used in DSN, but only parameters, values and delimiters, as shown in the manual. Where DSN is a semicolon-delimited string, consists of param=value pairs, that begins from the driver name and a colon: mysql : host = localhost dbname = test port = 3306 charset = utf8mb4ĭriver ^ ^ colon ^ param = value pair ^ semicolon
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |