Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个存储设置及其值的表从数据库中检索值的最佳方法是什么?
设置表如下所示:
setting value host 1.2.3.4 port 1234 user me pass cake
例如:
$host = $db->query('SELECT value FROM settings where setting = "host" '); print $host;
我正在使用 PDO
$sth = $dbh->prepare('SELECT value FROM settings where setting = :host'); $sth->bindValue(':host', $host, PDO::PARAM_STR); $sth->execute(); $value = $sth->fetch(); return $value;
这是现在与数据库做出反应的推荐方式。