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;
これは、データベースに反応するための現在推奨される方法です。