Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- I'm inserting a text object with a structure like this (it's a PHP object but here's what
- it looks like in JSON)
- { "title": "My text",
- "other_details": 5,
- "phrases": [
- { "sentence": "séres humanos", "translation": "human" },
- { "sentence": "derechòs", "translation": "rights" } ]
- }
- */
- public function create() {
- $text_data = array(
- 'title' => $this->input->post('title'),
- 'other_details' => $this->input->post('other_details'),
- );
- $text_id = $this->text_model->insert($text_data);
- $phrases = $this->input->post('phrases');
- $this->phrase_model->insert_many($phrases);
- redirect('texts/show/' . $id);
- }
- /*
- Question is: what is the PHP way to iterate through $phrases and add
- stick that $text_id field on there?
- */
Add Comment
Please, Sign In to add comment