DbConnectionAdapterMysqli.php 751 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class LtDbConnectionAdapterMysqli implements LtDbConnectionAdapter
  3. {
  4. public function connect($connConf)
  5. {
  6. return new mysqli($connConf["host"], $connConf["username"], $connConf["password"], $connConf["dbname"], $connConf["port"]);
  7. }
  8. public function exec($sql, $connResource)
  9. {
  10. $connResource->query($sql);
  11. return $connResource->affected_rows;
  12. }
  13. public function query($sql, $connResource)
  14. {
  15. $rows = array();
  16. $result = $connResource->query($sql);
  17. while($row = $result->fetch_assoc())
  18. {
  19. $rows[] = $row;
  20. }
  21. return $rows;
  22. }
  23. public function lastInsertId($connResource)
  24. {
  25. return $connResource->insert_id;
  26. }
  27. public function escape($sql, $connResource)
  28. {
  29. return mysqli_real_escape_string($connResource, $sql);
  30. }
  31. }