| <?php | |
| /* | |
| * YOU MUST REMOVE THE HEADER FROM THE CSV FILE BEFORE RUNNING | |
| * This script expects strictly CSV data in the following format: | |
| * CODE,URL,CREATION_DATE,... | |
| * IE: xcxcxvxcvxcvx,https://get.printfection.com/qbbhw/2268425967/sxcxcvxcvxc,9/17/2014,,,,, | |
| * | |
| * You can run this on the build server to populate dbmaster. | |
| */ | |
| $codes_file = 'codes.csv'; | |
| function fix_date($date_str) { | |
| $d = explode('/', $date_str); | |
| return $d[2] . "-" . $d[0] . "-" . $d[1]; | |
| } | |
| $con = mysqli_connect("dbmaster","user_here","password_here", "eclipse"); | |
| $f = fopen($codes_file, 'r'); | |
| while ($line = fgets($f)) { | |
| $line = trim($line); | |
| $line = trim($line, ','); | |
| $data = explode(',', $line); | |
| $data[2] = fix_date($data[2]); | |
| $sql = 'INSERT INTO tshirts VALUES ("' . $data[0] . '", "' . $data[1] . '", \'' . $data[2] . '\', null, null, null)'; | |
| mysqli_query($con,$sql); | |
| } |