unable to add new columns

5 views
Skip to first unread message

vineetdaniel

unread,
Apr 12, 2010, 5:34:56 AM4/12/10
to pandra-user
Hi

I am not able to add columns whenever i change the keyid. In existing
keyid i m able to add columns. Here is the code that I am using.
<?php
// session_start();

session_start();

if (!empty($_SESSION['badAgent'])) {
// echo 'BAD AGENT';
// exit; // bail on problem agents
}

error_reporting(E_ALL);
require_once(dirname(__FILE__).'/../config.php');
if (!PandraCore::connect('default', 'localhost')) {
die(PandraCore::$lastError);
}
$keyId = 'content1';
$keyspace = 'Keyspace1';
$columnFamily = 'Standard2';


$put = new PandraColumnFamily($keyId,
$keyspace,
$columnFamily
);
//$put = new content();
$put->setKeyID($keyId);
//$put->setColumn('city','meerut111');
$put->addColumn('city')->setValue('meerut221111');
$put->addColumn('state')->setValue('AP');
if (!$put->save()) {
die($put->lastError());
}

echo 'hi';
//unset($put);
$put1 = new PandraColumnFamily($keyId,
$keyspace,
$columnFamily
);
$put1->load('content');
echo '<pre>'.$put1->toJSON(TRUE);
print_r($put1);

mjpearson

unread,
Apr 12, 2010, 8:01:00 AM4/12/10
to pandra-user
Hi,

This looks like correct usage, you're saving city/state for key
'content1' and then loading a non-existant key 'content'.

If I'm understanding this ok, if you're trying to clone key 'content1'
into 'content', then you'll need to set key 'content' after the load.

... eg :


$put1 = new PandraColumnFamily($keyId,
$keyspace,
$columnFamily
);
$put1->load('content');
echo '<pre>'.$put1->toJSON(TRUE);
print_r($put1);

... should be :

$put1 = new PandraColumnFamily($keyId,
$keyspace,
$columnFamily
);

$put1->load();
$put1->setKeyID('content');


echo '<pre>'.$put1->toJSON(TRUE);
print_r($put1);

... key 'content' should then be savable.

Is that what you're after?

vineet daniel

unread,
Apr 12, 2010, 8:04:47 AM4/12/10
to pandr...@googlegroups.com

Hi,

Thanks for your reply and sorry for not updating my query, I found my mistake and have resolved it. As of now I have moved a little further and just inserted around 1000000 rows and read them using pandra.

Thanks for pandra. I am trying to create columns and super columns in single (finding it difficult) script. Any help would be appreciated.

Thanks Again for Pandra. Keep up the Good Work.


--
To unsubscribe, reply using "remove me" as the subject.

mjpearson

unread,
Apr 12, 2010, 9:44:30 AM4/12/10
to pandra-user

On Apr 12, 10:04 pm, vineet daniel <vineetdan...@gmail.com> wrote:
> I am trying to create columns and super columns in single
> (finding it difficult) script. Any help would be appreciated.

Hi :)

There's a supercolumn usage example @
http://github.com/mjpearson/Pandra/blob/master/examples/address_supercolumn.php
which might be useful, it shows how to create child classes via the
init() methods, attach supercolumns to column families etc. Do you
have a sample of the code you're working on? I'm happy to help out.
The object structure is fairly dynamic, checking out the interfaces
for 'columnpathable' (binds columnfamilies, supercolumns and columns)
and 'containerchild' (binds supercolumns and columns) would be a good
place to start conceptually if you need to work efficiently with
complex structures.

-michael

vineet daniel

unread,
Apr 12, 2010, 9:54:08 AM4/12/10
to pandr...@googlegroups.com
Hi

Ive gone through this example but I am not sure practically how to implement it as I am creating columns and I want to add supercolumns in the same row. Rather than using two seperate files and then doing a lot of hanky-panky stuff. I will soon upload the code once i able to do something with it.

I want something like this :

Col1, Col2, Col3 -> subCol1, subCol2, Col4, Col5.

I hope I am clear.



--
Reply all
Reply to author
Forward
0 new messages