function.php 669 B

123456789101112131415161718192021222324
  1. <?php
  2. function pdoConnect(){
  3. return new PDO('mysql:host=' . $GLOBALS['DB_HOST'] . ';dbname=' . $GLOBALS['DB_NAME'], $GLOBALS['DB_USER'], $GLOBALS['DB_PASS']);
  4. }
  5. function getInfo($name)
  6. {
  7. try{
  8. $pdo = pdoConnect();
  9. $stmt = $pdo->prepare("select * from loveway_config where name = ?");
  10. $stmt->bindValue(1,$name);
  11. if($stmt->execute()){
  12. $rows = $stmt->fetchAll();
  13. return $rows[0]['value'];
  14. } else {
  15. return 'database connection failed';
  16. }
  17. } catch (Exception $e) {
  18. return 'database connection failed';
  19. //echo $e->getMessage();
  20. }
  21. }
  22. ?>