Guest User

Untitled

a guest
Oct 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. /* $dataArray = Array(
  2. * "Column1" => "value1",
  3. * "Column2" => "value2",
  4. * and so on...);
  5. */
  6. foreach ($dataArray as $row => $value)
  7. {
  8. // $value[$PrimaryKey] >>> where condition
  9. // $PrimaryKey >>> name of the column
  10. // $Table >>> table name
  11. if($this->m_myModel->verifyRow($value[$PrimaryKey], $PrimaryKey, $Table))
  12. {
  13. $newArray[] = $value;
  14. unset($dataArray[$row]);
  15. }// if
  16. }// foreach
  17.  
  18. function verifyRow($where, $select, $table)
  19. {
  20.  
  21. //$this->db->query("SELECT $select FROM $table WHERE $select = $where LIMIT 1");
  22. $this->db->select($select)
  23. ->from($table)
  24. ->where($select, $where)
  25. ->limit(1);
  26.  
  27. $query = $this->db->get();
  28.  
  29. if(isset($query->result()[0])) // This is where the error occurs
  30. return true;
  31. else
  32. return false;
  33. }// function verifyRow
  34.  
  35. if($query->num_rows() > 0)
  36. return true;
  37. else
  38. return false;
  39.  
  40. $query = $this->db->get();
  41. $result = $query->result(); # added
  42.  
  43. if(!empty($result))
  44. return true;
  45. else
  46. {
  47. return false;
  48. }
  49.  
  50. foreach ($result as $value) {
  51. echo $value['field_name'];
  52. }
  53.  
  54. $name = $result[0]['field_name'];
  55. echo $name;
Add Comment
Please, Sign In to add comment