php - (1) filter on azure table storage and (2)catching errors -
i've got azure table storage, entities in it. putting new entities no problem. updating existing entities no problem either, works fine.
the next code hangs on line: $result = $tableclient->retrieveentities('users',"name eq 'john doe'",'partition1'); (somewhere on bottom) gives http 500 error.
require_once("microsoft/windowsazure/storage/table.php"); require_once("microsoft/windowsazure/storage/dynamictableentity.php"); $accountname = '***'; $accountkey = '*****'; $tableclient = new microsoft_windowsazure_storage_table('table.core.windows.net',$accountname,$accountkey); $tableclient->createtableifnotexists('users'); $result = $tableclient->listtables(); foreach ($result $table){ echo 'table name is: ' . $table->name . "\r\n<br />"; } function setuser($accountname,$accountkey,$partitionname,$data) { $tableclient = new microsoft_windowsazure_storage_table('table.core.windows.net',$accountname,$accountkey); $update = false; if(isset($data['id']) && $entity = $tableclient->retrieveentitybyid('users',$partitionname,$data['id'])){ $update = true; unset($data['id']); } else { $guid = substr(com_create_guid(),1,32); $entity = new microsoft_windowsazure_storage_dynamictableentity($partitionname, $guid); $entity->id = $guid; } $keys = array_keys($data); foreach($keys $key){ $entity->$key = $data[$key]; } if($update){ $tableclient->updateentity('users',$entity,true); } else { $tableclient->insertentity('users',$entity); } } setuser($accountname,$accountkey,'partition1',array(name => 'john doe',email => 'johndoe@gmail.com',time => time())); $result = $tableclient->retrieveentities('users',"name eq 'john doe'",'partition1'); //$result = $tableclient->retrieveentities('users'); foreach($result $data) { echo $data->id; echo ' - '; echo $data->name; echo ' - '; echo $data->email; echo ' - '; echo $data->time; echo '<br />'; } what want know is;
what doing wrong filter paramater? (when comment out line filter , uncomment line below, works fine).
how grab error(and other similar errors), tried seek { } grab { }, wasn't working. resulted in same http 500 error.
try-catch - code:
try { $result = $tableclient->retrieveentities('users',"name eq 'john doe'",'partition1'); } grab (microsoft_windowsazure_exception $e) { echo 'caught exception: '.$e->getmessage(); }
just taking wild guess (so may wrong) - looked @ code retrieving entities here: https://github.com/daniel15/ajaxplorer-azure/blob/master/azuresdk/microsoft/windowsazure/storage/table.php (hope looking @ right place) , noticed you're passing partition1 1 of arguments method.
could causing problem? seek like:
$tableclient->retrieveentities('users',"partitionkey eq 'partition1' , name eq 'john doe'") i looked @ project's page on codeplex (http://phpazure.codeplex.com/) , mentioned project has been deprecated in favor of azure sdk on github (https://github.com/azure/azure-sdk-for-php). imho, may worthwhile investing time in porting application utilize new sdk. thought.
php azure azure-table-storage
No comments:
Post a Comment