Работаю на OpenServere
Ошибка:
Fatal error: Uncaught PDOException: could not find driver in W:\domains\myproject\www\idiorm.php:328 Stack trace: #0 W:\domains\myproject\www\idiorm.php(328): PDO->__construct('mysqli:host=loc...', 'root', '', Array) #1 W:\domains\myproject\www\idiorm.php(311): ORM::_setup_db('default') #2 W:\domains\myproject\www\sklyar.php(30): ORM::for_table('chatt') #3 {main} thrown in W:\domains\myproject\www\idiorm.php on line 328
PHP часть:
include 'idiorm.php';
ORM::configure ('mysqli:host=localhost;dbname=chatt');
ORM::configure ('username', 'root');
ORM::configure ('password', '');
ORM::configure ('driver_options', array (PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf-8'));
function get_request_var ($var, $default=null) {
return isset($_REQUEST[$var])
? trim ($_REQUEST[$var])
: $default
;
}
function esc ($str) {
return htmlspecialchars ($str, ENT_QUOTES | ENT_IGNORE);
}
if (get_request_var('name') && get_request_var('message')) {
$record = ORM::for_table ('chatt') -> create();
$record -> name = get_request_var ('name');
$record -> message = get_request_var ('message');
$record -> created_at = time ();
$record -> save ();
header ('Location:?name=' . urlencode($get_request_var('name')));
}
$chatHistory = ORM::for_table ('chatt') -> order_by_desc ('created_at') -> limit (25) -> find_many ();
HTML часть:<html>
<head>
<style>
.form-group {margin: 5px 0;}
.form group .form-control {display: block; margin-bottom: 5px;}
</style>
</head>
<body>
<form action="?" method="post">
<div class="form-group">
<label for="name" class="form-control">Имя</label>
<input type="text" name="name" class="form-control" value="<?=esc(get_request_var('name'))?>" />
</div><br />
<div class="form-group">
<label for="message" class="form-control">Сообщение</label>
<input type="text" name="message" class="form-control" value="" />
<input type="submit" value="Отправить" class="form-control" />
</div>
</form>
<?php if ($chatHistory): ?>
<hr>
<?php foreach ($chatHistory as $record):?>
<div class="char-record">
[<?=esc(date('d.m.y H:i', $record->created_at))?>]
<?=esc ($record->name)?> →
<?=esc($record->message)?>
</div>
<?php endforeach;?>
<?php endif;?>
</body>
</html>
W:\domains\myproject\www\idiorm.php on line 328:
$db = new PDO(
self::$_config[$connection_name]['connection_string'],
self::$_config[$connection_name]['username'],
self::$_config[$connection_name]['password'],
self::$_config[$connection_name]['driver_options'] //328 строка
);
Не уточнил что работаю на OpenServere.
В нем все есть в комплекте.
Значит дело не в отсутствии драйвера.