Advertisement
Guest User

Untitled

a guest
Jul 28th, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. CREATE TABLE $rounds_table (
  2. ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  3. state ENUM('OPEN', 'CLOSED', 'PUBLISHED', 'COMPLETE') DEFAULT 'OPEN',
  4. title TEXT NOT NULL,
  5. created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
  6. PRIMARY KEY(ID)
  7. );
  8.  
  9. function create_round($name) {
  10. global $wpdb;
  11. $rounds_table = $wpdb->prefix . "videovote_rounds";
  12. $result = $wpdb->insert($rounds_table, array( 'title' => $name, 'state' => 'OPEN', 'created' => 'Now()'));
  13. return $wpdb->insert_id;
  14. }
  15.  
  16. create_round("test");
  17.  
  18.  
  19. result:
  20. mysql> select * from wp_videovote_rounds;
  21. +----+-------+-------+---------------------+
  22. | ID | state | title | created |
  23. +----+-------+-------+---------------------+
  24. | 1 | OPEN | | 0000-00-00 00:00:00 |
  25. | 2 | OPEN | | 0000-00-00 00:00:00 |
  26. +----+-------+-------+---------------------+
  27. 2 rows in set (0.00 sec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement