Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public function myRow($sql)
  2. {
  3. $this->connect();
  4. $rec = $this->conn->query($sql);
  5. $this->recordCount = $rec->num_rows;
  6.  
  7. if ($this->makeRecordCount) {
  8. $this->totalRecordCount = $this->recordCount;
  9. }
  10.  
  11. if ($this->recordCount > 0) {
  12. $names = array();
  13. $result = array();
  14. $temp = array();
  15. $count = $rec->field_count;
  16.  
  17. // Get fields name
  18. while ($fields = mysqli_fetch_field($rec)) {
  19. $names[] = $fields->name;
  20. }
  21.  
  22. while ($row = $rec->fetch_assoc()) {
  23. foreach ($names as $name) {
  24. $temp[$name] = $row[$name];
  25. }
  26.  
  27. array_push($result, $temp);
  28. }
  29. } else {
  30. $result = null;
  31. }
  32.  
  33. $this->conn->close();
  34.  
  35. return $result;
  36. }
  37.  
  38. $sql = "SELECT * FROM `table`";
  39. $datas = $class->myRow($sql);
  40. $smarty->assign('datas', $datas);
  41.  
  42. $class->connect();
  43. $sql = "SELECT * FROM `table`";
  44. $datas = $class->myRow($sql);
  45. $smarty->assign('datas', $datas);
  46.  
  47. $sql = "SELECT * FROM `table2`";
  48. $datas = $class->myRow($sql);
  49. $smarty->assign('data2s', $data2s);
  50. $class->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement