本文整理汇总了PHP中Tweet::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Tweet::insert方法的具体用法?PHP Tweet::insert怎么用?PHP Tweet::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tweet
的用法示例。
在下文中一共展示了Tweet::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* create dependent objects before running each test
**/
public final function setUp()
{
// run the default setUp() method first
parent::setUp();
// create and insert a Profile to own the test Tweet
$this->profile = new Profile(null, "@phpunit", "test@phpunit.de", "+12125551212");
$this->profile->insert($this->getPDO());
// create the test Tweet
$this->tweet = new Tweet(null, $this->profile->getProfileId(), "PHPUnit favorite test passing");
$this->tweet->insert($this->getPDO());
// calculate the date (just use the time the unit test was setup...)
$this->VALID_FAVORITEDATE = new DateTime();
}
示例2: 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);
}
示例3: connectToEncryptedMySQL
<?php
require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/dmartinez337.ini");
$tweet = new Tweet(null, 1, "this is from PHP");
$tweet->insert($pdo);
$tweet->setTweetContent("now I changed the message");
$tweet->update($pdo);
$tweet->delete($pdo);
示例4: explode
<?php
require_once 'includes/master.inc.php';
$db = Database::getDatabase();
$tweet_apps = $db->getRows('SELECT id, tweet_terms FROM applications');
foreach ($tweet_apps as $tweet_app) {
$terms = explode(',', $tweet_app['tweet_terms']);
foreach ($terms as $term) {
$term = trim($term);
if (strlen($term) > 0) {
$json = geturl("http://search.twitter.com/search.json?q=" . urlencode($term));
$data = json_decode($json);
if (!is_object($data)) {
continue;
}
foreach ($data->results as $result) {
$t = new Tweet();
$t->tweet_id = $result->id;
$t->username = $result->from_user;
$t->app_id = $tweet_app['id'];
$t->dt = dater($result->created_at);
$t->body = $result->text;
$t->profile_img = $result->profile_image_url;
$t->new = 1;
$t->replied_to = 0;
$t->insert();
}
}
}
}
示例5: Tweet
<?php
require 'connection.php';
require 'class_tweet.php';
set_time_limit(0);
$tweet = new Tweet();
$infomax = mysql_query("SELECT HashTag,MaxID FROM infomax WHERE Active='1'");
while ($info = mysql_fetch_array($infomax)) {
$result_json = $tweet->get_json($info['HashTag'], $info['MaxID']);
$obj = json_decode($result_json, TRUE);
$maxid = mysql_real_escape_string($obj["max_id_str"]);
$hash = mysql_real_escape_string($info['HashTag']);
mysql_query("UPDATE infomax SET MaxID = {$maxid} WHERE HashTag='{$hash}'");
if (isset($obj["results"])) {
$tweet->insert($obj["results"], $hash);
} else {
header("HTTP/1.1 503 Service Unavailable");
}
}
mysql_close($con);
unset($tweet);