Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 1.73 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to write $stmt in log from PHP script?
  2. $stmt = $this->pdo->prepare('SELECT * FROM usersTable WHERE udid = ? LIMIT 1');
  3.         $stmt->execute(array($udid));
  4.         $user = $stmt->fetch(PDO::FETCH_OBJ);
  5.  
  6.         writeToLog('handleMessage SELECT * FROM usersTable WHERE udid = ? LIMIT 1');
  7.  
  8.         if ($user !== false)
  9.         {
  10.             // Put the sender's name and the message text into the JSON payload
  11.             // for the push notification.
  12.             $payload = $this->makePayload($user->nickname, $text);
  13.  
  14.             writeToLog('handleMessage Payload: ' . $payload);
  15.  
  16.             // Find the device tokens for all other users who are registered
  17.             // for this secret code. We exclude the device token of the sender
  18.             // of the message, so he will not get a push notification. We also
  19.             // exclude users who have not submitted a valid device token yet.
  20.             $stmt = $this->pdo->prepare("SELECT device_token FROM usersTable WHERE secret_code = ? AND device_token <> ? AND device_token <> '0'");
  21.             $stmt->execute(array($user->secret_code, $user->device_token));
  22.             $tokens = $stmt->fetchAll(PDO::FETCH_COLUMN);
  23.                 writeToLog('handleMessage Tokens: ' . $tokens); // It is showing value like 'Array'
  24.  
  25.             // Send out a push notification to each of these devices.
  26.                     // If the senders secret code is differ from registered secret code this foreach loop won't execute
  27.             foreach ($tokens as $token)
  28.             {
  29.                 writeToLog('Sending payload and token to addPushNotification Function');
  30.                 writeToLog('token in foreach loop token: ' . $token);
  31.                 $this->addPushNotification($token, $payload);
  32.             }
  33.         }