Пример #1
0
function PollMessage()
{
    include 'config/config.php';
    require_once 'libs/database.php';
    $db = new DataBase($db_server, $db_user, $db_password);
    $db->Select($db_name);
    $db->Query("SELECT * FROM messages ORDER BY id DESC LIMIT 2");
    $data = $db->ReadNext();
    //no message in queue - return nop
    if ($data == null) {
        echo "none";
        return;
    }
    /*		echo "<pre>";
    		print_r($data);
    		echo "</pre>";*/
    $id = $data['id'];
    $message = $data['message'];
    //return the command to client
    echo $message;
    //delete message from queue
    $db = new DataBase($db_server, $db_user, $db_password);
    $db->Select($db_name);
    $db->Query("DELETE FROM messages WHERE id = '{$id}';");
}
Пример #2
0
function EnqueueMessage($message)
{
    include 'config/config.php';
    require_once 'libs/database.php';
    $db = new DataBase($db_server, $db_user, $db_password);
    $db->Select($db_name);
    $query = "INSERT INTO messages (\n\t\t\t\t\tmessage\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t'{$message}'\n\t\t\t\t\t);";
    $db->Query($query);
}
Пример #3
0
 private function _getData()
 {
     if (is_string($this->dataSource)) {
         $db = new DataBase();
         $db->Query($this->dataSource);
         if ($db->numRows() > 0) {
             while ($data = $db->fetchObject()) {
                 array_push($this->data, $data);
             }
         } else {
             $this->data = NULL;
         }
     }
     if (is_object($this->dataSource) && !is_string($this->dataSource)) {
         $this->data = $this->dataSource;
     }
     if (is_array($this->dataSource)) {
         $this->data = $this->dataSource;
     }
     $this->getDataKeys();
 }