Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Array to table 09 Apr 2012 15:42 #1951

  • devil
  • devil's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 2
Hi,

i have 3 Tables: events - categories - cache

Every time i create a new event ,i get the categories via json from an external server via Json (curl).

Now i will put the Categories (id,name) to the "categories" table (inside helper).

Anyone have an idea how?


Here the code inside the helper to get the categories:
function enumList($ctrl, $fieldName)
	{
			$url='http://**************';

				$curl = curl_init();
				curl_setopt($curl, CURLOPT_URL, $url);
				curl_setopt($curl, CURLOPT_HEADER, 0);
				curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
				$get = curl_exec($curl) or die('Error.');
				curl_close($curl);

				$data = json_decode($get);
				$cats = $data->data;
               


				//build the select with categorie names
				$lists = array();
				$lists["events"]["kategorie"] = array();

				foreach($cats as $cat){
					if($cat->id==$id) $title = $cat->title;

							$lists["events"]["kategorie"][$cat->id] = array("value" => $cat->id, "text" => $cat->title);
                         
					}
                
		return $lists[$ctrl][$fieldName];
	}

Please Log in or Create an account to join the conversation.

Last edit: by devil.
  • Page:
  • 1
Time to create page: 0.069 seconds

Although I found this tool some time ago I just started learning experimenting and building this first component on Monday and now on Thursday afternoon it's already online. Although I already had a working version done with another tool this is much easier to build and at the end you have the freedom to own your own component. Once you know how to use Cook you will boost your productivity as the learning curve is really moderate compared to many other tools.
Giori (Forum)

Get Started