summaryrefslogtreecommitdiff
path: root/src/test/pdo-test/regsql.inc
blob: c78d148ef13d0bcd7302047e6d3f909f4062901d (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
  require_once("def.inc");
  require_once("mod/database.inc");
  require_once("collections.inc");

	function getfiles( $dir )
	{
	$tree = array();

	if( $handle = opendir( $dir ) )
	{
		$i = 0;
		while ( false !== $file = readdir( $handle ) )
		{
			if( $file != "." && $file != ".." )
			{
					$tree[$i] = $file;
					$i++;
			}
		}
		closedir( $handle );
		uasort( $tree, "strcmp" ); 
	}
	return $tree;
	}

  function dosql($trans) {
		$context = NULL;

		if($trans)
		{
    	$file = "SQLlist/".$trans;
			if(is_file($file))
			{
    		$context=file_get_contents($file);
			}
		}

		if(!$context)
		{
			$files =  getfiles("SQLlist");
			$files_num = count($files) -1;
      $num = rand(0,$files_num);
    	$context=file_get_contents("SQLlist/".$files[$num]);						
		}
		$sqlarray = explode(";",$context);
    $con = dbconnect();

		for($i = 0; $i<count($sqlarray) -1;  $i++)
		{
			$sql = $sqlarray[$i];
			echo $sql."<BR>";
    	trans_end($con,$sql);
		}
  }
?>