0

I have a value stored in database from which i want to get value of a key of that array using mysql query . The value is

{"key":"754rtgsdsds?clientAccnum=940122","clientSubacc":"0005","eventType":"NewSaleSuccess","eventGroupType":"Subscription","accountingCurrency":"USD","accountingCurrencyCode":"840","accountingInitialPrice":"29.95","accountingRecurringPrice":"24.95","address1":"321 Hurley Street","billedCurrency":"USD","billedCurrencyCode":"840","billedInitialPrice":"29.95","billedRecurringPrice":"24.95","cardType":"MASTERCARD","city":"Cambridge","clientAccnum":"98989","country":"US","email":"sd","firstName":"David","formName":"201cc","initialPeriod":"30","ipAddress":"65.96.161.24","lastName":"Pendleton","nextRenewalDate":"2014-12-02","password":"mark3mark","paymentType":"CREDIT","postalCode":"02141","priceDescription":"29.95(USD) for 30 days then 24.95(USD) recurring every 30 days","rebills":"99","recurringPeriod":"30","referringUrl":"","reservationId":"02143067100090003425","state":"MA","subscriptionCurrency":"USD","subscriptionCurrencyCode":"840","subscriptionId":"021430670100000601309","subscriptionInitialPrice":"29.95","subscriptionRecurringPrice":"24.95","subscriptionTypeId":"00000001870","timestamp":"2014-11-02 10:46:09","transactionId":"0214306701000006013","username":"figofani","X-variableToPassNamesAsString":"clientAccnum:clientSubacc:formName:regionalPricingProfileId:regionalPricingList:","X-session":"fromBillingCascade","X-x_enc":"74d5d917b514206d3be4e000d9a5bee1","X-clientCascadeConfigurationId":"17159","X-region-option":"on","X-externalCascadeFlowId":"13967","X-previousCascadeProcessorId":"1","X-payment-option2":"on","X-previousCascadeProcessorName":"CCBill","X-billingCascade":"1","X-cascadeProcessorId":"1","X-emailConfirmationSessionId":"74d5d917b514206d3be4e000d9a5bee1","X-join":"JOIN","X-checkAns":"true","X-cascadeProcessorName":"CCBill","X-cascadeProcessorRoleId":"1","X-stage":"1","X-enc":"74d5d917b514206d3be4e000d9a5bee1","X-isRedirected":"false"}

and the value of key which i wanted is subscriptionId . Can this be done in mysql itself ? or do we need php for it ?

1 Answer 1

1

That is a JSON string representaion of an object, you will have to read the whole column and then decode the json string so you can process it easily in PHP

So assuming you read that column from the database and into a variable called $json_string;

$obj = json_decode($json_string);

echo $obj->subscriptionId;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.