0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TweetTable.php
Go to the documentation of this file.
1 <?
24 require_once 'HypertableConnection.php';
25 require_once 'Tweet.php';
26 require_once 'UserTable.php';
27 require_once 'User.php';
28 
30 {
31  // load a tweet from the database
32  public function load($id) {
33  $result=HypertableConnection::query("SELECT * FROM tweet ".
34  "WHERE ROW='$id'");
35  if (!$result or !count($result->cells))
36  return null;
37 
38  $tweet=new Tweet();
39  $tweet->setId($id);
40  $tweet->setTimestamp($result->cells[0]->key->timestamp);
41  $tweet->setMessage($result->cells[0]->value);
42  return $tweet;
43  }
44 
45  // Store a tweet; this function will automatically assign a new ID
46  // if necessary
47  public function store($tweet, $author) {
48  if (!$tweet->getId())
49  $tweet->createId($author);
50  HypertableConnection::insert('tweet', $tweet->getId(), 'message',
51  $tweet->getMessage());
52  $u=UserTable::load($author);
53  $u->sendTweet($tweet);
54  return true;
55  }
56 }
57 
58 ?>
static insert($table, $row, $column, $value, $timestamp=0)
store($tweet, $author)
Definition: TweetTable.php:47
load($userid)
Definition: UserTable.php:31
Copyright (C) 2007-2015 Hypertable, Inc.
Definition: Tweet.php:24
Copyright (C) 2007-2015 Hypertable, Inc.
Definition: TweetTable.php:29