本文整理汇总了PHP中Tweet::getAllTweets方法的典型用法代码示例。如果您正苦于以下问题:PHP Tweet::getAllTweets方法的具体用法?PHP Tweet::getAllTweets怎么用?PHP Tweet::getAllTweets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tweet
的用法示例。
在下文中一共展示了Tweet::getAllTweets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAllValidTweets
/**
* test grabbing all Tweets
**/
public function testGetAllValidTweets()
{
// count the number of rows and save it for later
$numRows = $this->getConnection()->getRowCount("tweet");
// create a new Tweet and insert to into mySQL
$tweet = new Tweet(null, $this->profile->getProfileId(), $this->VALID_TWEETCONTENT, $this->VALID_TWEETDATE);
$tweet->insert($this->getPDO());
// grab the data from mySQL and enforce the fields match our expectations
$results = Tweet::getAllTweets($this->getPDO());
$this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("tweet"));
$this->assertCount(1, $results);
$this->assertContainsOnlyInstancesOf("Tweet", $results);
// grab the result from the array and validate it
$pdoTweet = $results[0];
$this->assertEquals($pdoTweet->getProfileId(), $this->profile->getProfileId());
$this->assertEquals($pdoTweet->getTweetContent(), $this->VALID_TWEETCONTENT);
$this->assertEquals($pdoTweet->getTweetDate(), $this->VALID_TWEETDATE);
}
示例2: InvalidArgumentException
if (in_array($format, $validFormats) === false) {
throw new InvalidArgumentException("invalid format", 405);
}
if ($method === "DELETE" && (empty($id) === true || $id < 0)) {
throw new InvalidArgumentException("id cannot be empty or negative", 405);
}
// grab the mySQL connection
$pdo = connectToEncryptedMySql("/etc/apache2/data-design/dmcdonald21.ini");
// handle all RESTful calls to Tweet
if ($class === "tweet") {
// get some or all Tweets
if ($method === "GET") {
if (empty($id) === false) {
$reply->data = Tweet::getTweetByTweetId($pdo, $id);
} else {
$reply->data = Tweet::getAllTweets($pdo)->toArray();
}
// post to an existing Tweet
} else {
if ($method === "POST") {
// convert POSTed JSON to an object
verifyXsrf();
$requestContent = file_get_contents("php://input");
$requestObject = json_decode($requestContent);
if (empty($id) === true || $id < 0) {
$tweet = new Tweet(null, 1, "empty tweet");
} else {
$tweet = Tweet::getTweetByTweetId($pdo, $id);
}
$tweet->setProfileId($requestObject->profileId);
$tweet->setTweetContent($requestObject->tweetContent);