Jump to content

Dex2k

New Members
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

1 Neutral

About Dex2k

  • Rank
    Newbie
  1. Guys dont call me dickhead but honestly I cannot go for the MONGO thingy I tried a litte bit and came to following result. Can somebody just help me finish it ? I hope it also helps some other people with same issue. it has still some bugs --> doesnt take create tables with most fields in it for each table that should be created . Normal should only create 1x query or each table(1x per parent, 1x per child) --> Puts a "," in the last input or create SQL function --> datafields not assigned to INSERT INTO function yet <?php $get_data = (file_get_co
  2. P.S. I know the given example is in JS but the same should be makeable in PHP or not?
  3. ok if its not a good idea to flatten how do i get it to mysql relationship your array converted to json [{"0":"bossman","name":"Bob","address":[{"type":"home","city":"Los Angeles"},{"type":"work","city":"Beverly Hills"}],"employee_id":1,"spouse":{"name":"Linda"}},{"0":"flunky","name":"Bob, Jr","address":[{"type":"home","city":"Los Angeles"},{"type":"vacation","city":"Beverly Hills"}],"employee_id":121,"notes":"This is Bob's son!"}] please try it out to see what i mean http://pojo.sodhanalibrary.com/convertJsonToSQL.html
  4. Sorry for the emotions but I don't like it if I ask one question and somebody in the first post begins with oh my Think if we clean the "oh my" in both posts it wouldnt have gotten so emotional Sorry for that didn't meant to
  5. Oh my you haven't even posted a solution it's just use application x and then do it and of course change your whole database to mongo bongo Seems you have no idea I myself I am a beginner but atleast I try . I know the structure of a database and I am aware of sql injections but it's basically something I do at the end if really needed for my local running little code.
  6. function array_keys_recursive ($array,$d=0) { $flat = array(); foreach($array as $key => $value) { if (is_array($value)) { $flat = array_merge($flat, array_keys_recursive($value)); } else { if (is_int($key)) { $key = "Dummy" . $key . "`"; $flat[] = "`" . $key . " VARCHAR(50) "; } else{$flat[] = $key . " VARCHAR(50)";} } } return $flat; } sorry first function got corrupted somehow when editing
  7. both should be inserted or created if possible vial only one function anyways i even would be glad if i could get the inserts in one row for text.txt with all the tables . Atm they are seperated due to array one dataset aways cause of "for each" you can see from output . Creating works OUTPUT FOR CREATE TABLE: CREATE TABLE `table1` (type VARCHAR(50), state VARCHAR(50), influence VARCHAR(50), has_boss VARCHAR(50), faction_id VARCHAR(50), constellation_id VARCHAR(50), staging_solar_system_id VARCHAR(50), `Dummy0` VARCHAR(50) , `Dummy1` VARCHAR(50) , `Dummy2` VARCHAR(50) , `Dummy3` VA
  8. function array_keys_recursive ($array,$d=0) { $flat = array(); foreach($array as $key => $value) { if (is_array($value)) { $flat = array_merge($flat, array_keys_recursive($value)); } else { if (is_int($key)) { $key = "Dummy" . $key . "`"; $flat[] = "`" . $key . " VARCHAR(50) "; } else{$flat[] = $key . " VARCHAR(50)";} } } return $flat; } function traverseArray($array,$table=NULL,$d=1) { $fields = array(); $values = array(); // Loops through each element. If element again is array, function is recal
  9. Hey there Looked already through the whole internet Somebody has a function which goes through a nested php Array no matter what structure The function should analyse the data entries and lookup for the keys and values It all sounds easy but when I come to the first nest there's another nest in it I get a headache. At the end I want the php function to create or insert values according to the array structure into the MySQL tables. Wonder why I haven't seen and solution out there Output : Create table1 (struc1,struc2...) Or. Insert into table1 (struc1,struc2...) (
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.