DbConnectionAdapterMysql.php 773 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. class LtDbConnectionAdapterMysql implements LtDbConnectionAdapter
  3. {
  4. public function connect($connConf)
  5. {
  6. return mysql_connect($connConf["host"] . ":" . $connConf["port"], $connConf["username"], $connConf["password"]);
  7. }
  8. public function exec($sql, $connResource)
  9. {
  10. return mysql_query($sql, $connResource) ? mysql_affected_rows($connResource) : false;
  11. }
  12. public function query($sql, $connResource)
  13. {
  14. $result = mysql_query($sql, $connResource);
  15. $rows = array();
  16. while($row = mysql_fetch_assoc($result))
  17. {
  18. $rows[] = $row;
  19. }
  20. return $rows;
  21. }
  22. public function lastInsertId($connResource)
  23. {
  24. return mysql_insert_id($connResource);
  25. }
  26. public function escape($sql, $connResource)
  27. {
  28. return mysql_real_escape_string($sql, $connResource);
  29. }
  30. }