-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtable_inspector.class.php
More file actions
32 lines (26 loc) · 945 Bytes
/
table_inspector.class.php
File metadata and controls
32 lines (26 loc) · 945 Bytes
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
<?php
namespace PluSQL;
class TableInspector
{
private $workers;
private $links;
private static $instance = NULL;
private function __construct()
{
$this->workers = array();
$this->links = array();
}
public static function forTable($table_name,$link)
{
if(self::$instance === NULL)
self::$instance = new TableInspector();
if(($key = array_search($link,self::$instance->links,TRUE)) === FALSE)
{
$key = microtime(true).rand(0,9999);
self::$instance->links[$key] = $link;
}
if(!isset(self::$instance->workers[$table_name.$key]))
self::$instance->workers[$table_name.$key] = new TableInspectorWorker($table_name,$link);
return self::$instance->workers[$table_name.$key];
}
}