File: testInsert.php

package info (click to toggle)
spotweb 20130826%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,132 kB
  • ctags: 11,281
  • sloc: php: 31,367; xml: 1,009; sh: 148; makefile: 83
file content (35 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
error_reporting(E_ALL);	

 mysql_connect('localhost', 'spotweb', 'spotweb', 'spotweb');

mysql_select_db('spotweb');

  $data = array('5412321e9b3024b668854ef1ffff606a140@free.pt', 'testposter', 'Test Title', 'tagtagtagtagtag', 0, 'a10|', 'b3|', 'c6|', 'd11|', 'z1|', time(), -time(), 0, NULL, 0, 0, 0, '');


  $sql = '';


  $x = microtime(true);
  for($i = 0; $i < 50; $i++) {
  $sql = 'INSERT INTO spots(messageid, poster, title, tag, category, subcata, subcatb, subcatc, subcatd, subcatz, stamp, reversestamp, filesize, moderated, commentcount, spotrating, reportcount, spotterid) VALUES';
  for ($j = 0; $j < 10000; $j++) {
	$sql .= "('{$data[0]}{$i}-{$j}', '{$data[1]}', '{$data[2]}', '{$data[3]}', {$data[4]}, 	
				'{$data[5]}', '{$data[6]}', '{$data[7]}', '{$data[8]}', '{$data[9]}', {$data[10]}, {$data[11]}, {$data[12]}, NULL, {$data[14]}, {$data[15]}, {$data[16]}, '{$data[17]}'),";
  } # for
  $sql = substr($sql, 0, -1);

  	 mysql_query($sql);

  	 if (mysql_errno() != 0) {
  	 	echo "ffs!" . PHP_EOL;
  	 	break;
  	 } # if
  	} # for

   $y = microtime(true);

   echo "Total time for 500k inserts: " . ($y - $x) . PHP_EOL;

die(mysql_error().PHP_EOL);