12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
-
-
- $servername = "127.0.0.1";
- $username = "root";
- $password = "";
- $database = "trabajoolas5";
-
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $database);
-
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- echo "Connected successfully\n";
-
- $allrubrics = mysqli_query($conn, 'select id, contents from `rubrics`');
-
- while ($row = mysqli_fetch_array($allrubrics)) {
-
- foreach (json_decode($row['contents']) as $criterion) {
-
- $outcome_id = $criterion->outcome_id;
- $querySelect = "select * from rubric_outcome where rubric_id ={$row['id']} and outcome_id = {$outcome_id}";
- $makeQuery = mysqli_query($conn, $querySelect);
- if (!mysqli_num_rows($makeQuery)) {
-
- $query2 = "insert into `rubric_outcome` (`rubric_id`, `outcome_id`) values ({$row['id']}, {$outcome_id});";
- $makeQuery = mysqli_query($conn, $query2);
- if (!$makeQuery) {
- die("Connection failed: " . mysqli_error($conn) . $query2);
- }
- }
-
-
-
- $criteria_id = $criterion->id;
- $querySelect = "select * from rubric_criterion where rubric_id ={$row['id']} and criterion_id = {$criteria_id}";
- $makeQuery = mysqli_query($conn, $querySelect);
- if (!mysqli_num_rows($makeQuery)) {
- $query2 = "insert into `rubric_criterion` (`rubric_id`, `criterion_id`) values ({$row['id']}, {$criteria_id});";
- $makeQuery = mysqli_query($conn, $query2);
- if (!$makeQuery) {
- echo "Connection failed: " . mysqli_error($conn) . $query2;
- }
- }
- }
- }
|