-
Notifications
You must be signed in to change notification settings - Fork 101
/
README
82 lines (58 loc) · 2.1 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Notes:
* Compatible with Cassandra 0.5.1 upwards (0.6.1)
* Direct port of pycassa
* Basic conversion of types (UUIDs to strings)
Examples:
* Including files:
<?php
// Copy all the files in this repository to your include directory.
$GLOBALS['THRIFT_ROOT'] = dirname(__FILE__) . '/include/thrift/';
require_once $GLOBALS['THRIFT_ROOT'].'/packages/cassandra/Cassandra.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php';
require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';
include_once(dirname(__FILE__) . '/include/phpcassa.php');
include_once(dirname(__FILE__) . '/include/uuid.php');
?>
* Setting up nodes:
<?php
CassandraConn::add_node('192.168.1.1', 9160);
CassandraConn::add_node('192.168.1.2', 5000);
?>
* Create a column family object
<?php
$users = new CassandraCF('Keyspace1', 'Users'); // ColumnFamily
$super = new CassandraCF('Keyspace1', 'SuperColumn', true); // SuperColumnFamily
?>
* Inserting:
<?php
$users->insert('1', array('email' => 'hoan.tonthat@gmail.com', 'password' => 'test'));
?>
* Querying:
<?php
$users->get('1'); // array('email' => 'hoan.tonthat@gmail.com', 'password' => 'test')
$users->multiget(array('1', '2')); // array('1' => array('email' => 'hoan.tonthat@gmail.com', 'password' => 'test'))
?>
* Removing:
<?php
$users->remove('1'); // removes whole object
$users->remove('1', 'password'); // removes 'password' field
?>
* Other:
<?php
$users->get_count('1'); // counts the number of columns in user 1 (in this case 2)
$users->get_range('1', '10'); // gets all users between '1' and '10'
?>
Email hoan.tonthat@gmail.com with any questions. We also have a google group to ask questions:
http://groups.google.com/group/phpcassa
AUTHORS:
* Hoan Ton-That (hoan.tonthat@gmail.com)
* Benjamin Sussman (ben@fwix.com)
* Anthony ROUX (anthony.rx43@gmail.com)
* Vadim Derkach
* Zach Buller (zachbuller@gmail.com)
* Timandes
* Todd Zusman
* Yancho Georgiev (yancho@inspirestudio.net)
* Pieter Maes (maescool@gmail.com)