public function getFriends($userId) { $db_parse = new DbHandlerParse(); $usersArray = array(); $db_mark = new DbHandlerMark(); $db_mark->run_sql("SELECT * FROM follow WHERE follower_user_id = '{$userId}'"); $stmt = $this->conn->prepare("SELECT * FROM follow WHERE follower_user_id = ?"); $stmt->bind_param("s", $userId); if ($stmt->execute()) { /* Store the result (to get properties) */ $stmt->store_result(); /* Get the number of rows */ $num_of_rows = $stmt->num_rows; /* Bind the result to variables */ $stmt->bind_result($id, $followerUserId, $followedUserId, $status, $createdAt); while ($stmt->fetch()) { //echo 'ID: '.$id.'<br>'; //echo 'Follower: '.$followerUserId.'<br>'; //echo 'Followed: '.$followedUserId.'<br>'; //echo 'status: '.$status.'<br>'; //echo 'Created: '.$createdAt.'<br><br>'; //printf("Follower ID: %s Created: %s", $followerUserId, $createdAt); array_push($usersArray, $db_parse->getUserById($followedUserId)); } /* free results */ $stmt->free_result(); } $stmt->close(); return $usersArray; }
$eventSource = $app->request()->post('eventSource'); $postMsg = $app->request()->post('postMsg'); $postLat = $app->request()->post('userLat'); $postLng = $app->request()->post('userLng'); $postInfo = array(); $postInfo['message'] = $postMsg; $postInfo['latitude'] = $postLat; $postInfo['longitude'] = $postLng; $db = new DbHandlerNeo(); // TODO: Check if event exists too if ($db->isUserExistsByUserId($userId)) { $result = $db->createPostNoPhotos($userId, $eventId, $eventSource, $postInfo); } else { //Try and create parse user if exists in parse $dbParse = new DbHandlerParse(); $parseUser = $dbParse->getUserById($userId); if (null != $parseUser) { $db->createUser($parseUser->getObjectId(), $parseUser->get('email'), $parseUser->get('username')); $result = $db->createPostNoPhotos($parseUser->getObjectId(), $eventId, $eventSource, $postInfo); } else { $result = false; } } if ($result == 'POST_CREATED') { $response['result'] = 'success'; $response['message'] = "User ID: {$userId} successfully created a new post!"; } else { if ($result == 'EVENT_NOT_FOUND') { $response['result'] = 'error'; $response['message'] = 'Post could not be created because the associated event was not found.'; } else {