$config = array(
'driver' => 'mysqli', // MySQL
'host' => 'localhost',
'username' => '{username}',
'password' => '{password}',
'database' => '{dbname}',
'characterset' => 'utf8',
);
$adapter = new \Zend\Db\Adapter\Adapter($config);
$id = 1;
$sql = "select * from user where id = ?";
$params = array($id);
$statement = $adapter->query($sql);
$results = $statement->execute($params);
foreach ($results as $result) {
//echo $result->id;
echo $result->name;
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme