예제 #1
0
파일: Post.php 프로젝트: rjha/sc
 /**
  * @error if links json is empty or spaces in DB column
  * @error if links json evaluates to NULL by json_decode
  * @error if links json is valid but not an array
  * @return an array of strings (links)
  *
  */
 function getLinkDataOnId($postId)
 {
     $row = mysql\Post::getLinkDataOnId($postId);
     $json = $row['json'];
     $links = NULL;
     if (!Util::tryEmpty($json)) {
         $links = json_decode($json);
     }
     if (is_null($links) || !is_array($links)) {
         $message = sprintf("Post %d has Bad json [ %s ] ", $postId, $json);
         Logger::getInstance()->error($message);
         $links = NULL;
     }
     $data = array('links' => $links, 'version' => $row['version']);
     return $data;
 }