1

Is something like in the link below possible in Symfony2 ?

http://www.kodingmadesimple.com/2014/12/how-to-insert-json-data-into-mysql-php.html

My plan is to create a CRON Job that would hit a specific route which will execute logic in a controller that would persist json data into a database table at a set time every day.

So basically, I would grab the JSON file, extract the values I want and store them in variables, then persist them to a database table.

1 Answer 1

5

If you're using doctrine, you can simply do:

$data = json_decode($jsondata, true);
$entity = new Entity();

$entity->setName($data['personal']['name']);
$entity->setGender($data['personal']['gender']);

Then you just need to use the entitymanager, to persist it depending on you context:

$em->persist($entity);
$em->flush();
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.