Added new function cat_status to take profile_name and profile_url via json

pull/109/head
Peter Goodhall 2012-12-10 15:51:41 +00:00
rodzic 53d27e9844
commit 6430b9dc11
2 zmienionych plików z 44 dodań i 1 usunięć

Wyświetl plik

@ -322,7 +322,7 @@ class API extends CI_Controller {
$obj = json_decode(file_get_contents("php://input"), true);
// Store Result to Database
$this->cat->update($obj);
$this->cat->cat_status($obj);
// Return Message
@ -331,4 +331,14 @@ class API extends CI_Controller {
echo json_encode($arr);
}
function cat_status () {
header('Content-type: application/json');
$this->load->model('cat');
// Decode JSON and store
$obj = json_decode(file_get_contents("php://input"), true);
}
}

Wyświetl plik

@ -41,6 +41,39 @@
}
}
function cat_status($result) {
$this->db->where('profile_name', $result['profile_name']);
$query = $this->db->get('cat');
if ($query->num_rows() > 0)
{
// Update the record
foreach ($query->result() as $row)
{
$radio_id = $row->id;
$data = array(
'profile_name' => $result['profile_name'],
'profile_url' => $result['profile_url']
);
$this->db->where('id', $radio_id);
$this->db->update('cat', $data);
}
} else {
// Add a new record
$data = array(
'profile_name' => $result['profile_name'],
'profile_url' => $result['profile_url']
);
$this->db->insert('cat', $data);
}
}
function status() {
//$this->db->where('radio', $result['radio']);