Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- error_reporting( error_reporting() & ~E_NOTICE );
- ini_set('max_execution_time', 3000);
- ini_set('memory_limit', '2G'); // due to memory error
- //connect to mysql db
- $con =mysqli_connect("x.x.x.x", "user", "password", "bdnaem");;
- //connect to the employee database
- //read the json file contents
- $jsondata = file_get_contents('big9.file');
- //convert json object to php associative array
- $data = json_decode($jsondata, true);
- //mysqli_query("BEGIN");
- $sql = "INSERT INTO `Items`(`Buy`, `Issued`, `Price`, `Duration`, `ID`, `Minvolume`, `Volume Entered`, `RangeR`, `Station`, `Type`)
- VALUES ";
- $rowcount = 0;
- $trowcount = 0;
- $lim = 1000;
- echo count($data);
- foreach ($data['items'] as $row){
- //get the items details
- $Buy = $row['buy'];
- $Issued = $row['issued'];
- $Price = $row['price'];
- $Duration = $row['duration'];
- $ID = $row['id'];
- $Minvolume = $row['minvolume'];
- $Volume_Entered = $row['volumeEntered'];
- $RangeR = $row['range'];
- $Station = $row['station'];
- $Type = $row['type'];
- //insert into mysql table
- $sql .= "('$Buy', '$Issued', '$Price', '$Duration', '$ID', '$Minvolume', '$Volume_Entered', '$RangeR', '$Station', '$Type')";
- $rowcount++;
- if($rowcount == $lim) {
- if(!mysqli_query($con,$sql))
- {
- die('Error : ' . mysqli_error($con));
- }
- $rowcount = 0;
- $trowcount ++;
- $sql = "INSERT INTO `Items`(`Buy`, `Issued`, `Price`, `Duration`, `ID`, `Minvolume`, `Volume Entered`, `RangeR`, `Station`, `Type`)
- VALUES ";
- } else {
- $sql .= ",";
- }
- }
- if(!mysqli_query($con,$sql))
- {
- die('Error : ' . mysqli_error($con));<----Here error
- }
- $time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
- echo "Did nothing in $time seconds\n";
- ?>
Add Comment
Please, Sign In to add comment