exist versions info |
22 |
$info = $t->getClassVersion('table'); $t->check($info, !empty($info) AND $info >= 1.2);
|
[0.134 ms] 1.3 |
Ok |
create from 2 dim num. Array |
26 |
$data = [ [11,12,13], [21,22,23], ]; $html = Table::create($data)->getHtml(); $t->checkHTML($html,'11,23');
|
[0.037 ms]
|
Ok |
create from Array with std-class-objects |
34 |
$data = [ (object)[11,12,13], (object)[21,22,23], ]; $html = Table::create($data)->getHtml(); $t->checkHTML($html,'11,23');
|
[0.020 ms]
|
Ok |
create from std-class-objects |
42 |
$data = (object)[ (object)[11,12,13], (object)[21,22,23], ]; $html = Table::create($data)->getHtml(); $t->checkHTML($html,'11,23');
|
[0.014 ms]
|
Ok |
create from 1-dim-array with key => value |
50 |
$data = [ 'key1' => 'value1', 'key2' => 'value2', ]; $html = Table::create($data)->getHtml(); $t->checkHTML($html,'key1,value2');
|
[0.009 ms]
|
Ok |
create from 1-dim-array |
58 |
$data = ['Max','Alex','Susi']; $html = Table::create($data)->getHtml(); $t->checkHTML($html,'Max,Susi');
|
[0.009 ms]
|
Ok |
create from PDO-Statement |
64 |
//create Test Database $options = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ]; $db = new PDO("sqlite::memory:",null,null,$options);
$sql = "CREATE TABLE tab (id INTEGER PRIMARY KEY NOT NULL , name TEXT NOT NULL DEFAULT '')"; $db ->exec($sql);
$sql = "INSERT INTO tab ('id', 'name') VALUES (1,'Max'),(2,'Rosi'),(3,'Willi')"; $db ->exec($sql); // Query $sql = "SELECT id,name FROM tab"; $stmt = $db->query($sql);
$html = Table::create($stmt) ->title(Table::KEY) ->getHtml(); $t->checkHTML($html,'Max,Rosi,Willi');
|
[0.477 ms]
id |
name |
1 |
Max |
2 |
Rosi |
3 |
Willi |
|
Ok |
2 dim num. Array with title |
90 |
$data = [ [11,12,13], [21,22,23], ]; $html = Table::create($data) ->title(['Spalte1','Spalte2','Spalte3']) ->getHtml() ; $t->checkHTML($html,'Spalte1,Spalte3,11,23');
|
[0.012 ms]
Spalte1 |
Spalte2 |
Spalte3 |
11 |
12 |
13 |
21 |
22 |
23 |
|
Ok |
2 dim num. Array with keys as title |
101 |
$data = [ ['name' => 'A1', 'value' => 3], ['name' => 'A12', 'value' => 6], ['name' => 'A2','value' => 14], ['name' => 'A14','value' => 7], ]; $table = Table::create($data) ->title(Table::KEY) ->getHtml() ; $t->checkHTML($table,'name,value,A1,7');
|
[0.014 ms]
name |
value |
A1 |
3 |
A12 |
6 |
A2 |
14 |
A14 |
7 |
|
Ok |
2 dim num. Array with title = first Line data |
114 |
$data = [ ['Spalte 1','Spalte 2'], [11,12], [21,22], ];
$table = Table::create($data) ->title(Table::FIRSTLINE) ->getHtml() ; $t->checkHTML($table,'Spalte 1,Spalte 2,11,12,21,22');
|
[0.009 ms]
Spalte 1 |
Spalte 2 |
11 |
12 |
21 |
22 |
|
Ok |
2 dim num. Array without title, border 2 |
128 |
$data = array( array(11,12,13), array(21,22,23), ); $table = Table::create($data) ->attribute('border=2') ->getHtml(); $t->checkHTML($table,'border,11,12,21,23');
|
[0.010 ms]
|
Ok |
format values |
138 |
$data = array( array(11,12,'2018-01-23'), array(21,22,'2019-04-05'), ); $table = Table::create($data) ->format(['%03d','%5.2f','d.m.Y H:i']) ->getHtml() ; $t->checkHTML($table,'011,12.00,23.01.2018 00:00');
|
[0.082 ms]
011 |
12.00 |
23.01.2018 00:00 |
021 |
22.00 |
05.04.2019 00:00 |
|
Ok |
format values with user function |
149 |
$data = [120.33,4.77,3,1123.99,720]; //user function $specFormat = function($value){ //nbsp; -> \xc2\xa0 return str_replace(",00","\xc2\xa0\xc2\xa0\xc2\xa0",number_format($value,2,",","")); }; $table = Table::create($data) ->attribute('border=1 style="text-align:right; font:16px monospace;"') ->format([null,$specFormat]) ->title(['No','Value']) ->getHtml(); $t->checkHTML($table,"120,33,2,3\xc2\xa0");
|
[0.035 ms]
No |
Value |
0 |
120,33 |
1 |
4,77 |
2 |
3 |
3 |
1123,99 |
4 |
720 |
|
Ok |
2 dim num. Array with CSS |
163 |
$css1 = '.mytab { border: #5F5F5F 1px solid; border-collapse:collapse;} .mytab th, td {border: #5F5F5F 1px solid; padding:4px;} '; $t->addCss($css1); //add new style $data = array( array(11,12,13), array(21,22,23), ); $table = Table::create($data) ->attribute('mytab') //or 'class="mytab"' ->getHtml() ; $t->checkHTML($table,'mytab,11,12,21,23');
|
[0.010 ms]
|
Ok |
2 dim num. Array with escaped html |
192 |
$data = array( array(11,12), array(21,'html<br>html'), ); $table = Table::create($data) ->getHtml(); //default quote all rows $t->checkHTML($table,'21,html<br>html');
|
[0.008 ms]
|
Ok |
2 dim Array with non-escaped html row1 |
201 |
$data = array( array(11,12), array(21,'html<br>html'), ); $table = Table::create($data) ->quoteSpecialChars([true,false]) ->getHtml(); $t->checkHTML($table,'21,html<br>html');
|
[0.008 ms]
|
Ok |
2 dim num. Array with title + CSS |
213 |
//Styling with CSS $css2 = '.mytab2 th{ background-color: #338; color: white; }'; $t->addCss($css2); //add new style $data = array( array(11,12,13), array(21,22,23), ); $table = Table::create($data) ->attribute('border=1 class="mytab2"') ->title(['Col 1','Col 2','Col 3']) ->getHtml(); $t->checkHTML($table,'border,mytab2,11,23');
|
[0.012 ms]
Col 1 |
Col 2 |
Col 3 |
11 |
12 |
13 |
21 |
22 |
23 |
|
Ok |
Array with title + CSS for Cols |
230 |
$css3 = ' table.mytab3 {border:1px solid black;border-collapse:collapse; margin:0;} .mytab3 th, td{ border: 1px solid black; padding: 4px; margin:0;} .mytab3 .Col_0{background-color: #f88;} .mytab3 .Col_1{background-color: #8f8;} .mytab3 .Col_2{background-color: #88f;} '; $t->addCss($css3); //add new style $data = [ [11,12,13], [21,22,23], ]; $table = Table::create($data) ->attribute('class="mytab3"') ->title(['Col 1','Col 2','Col 3']) ->getHtml(); $t->checkHTML($table,'mytab3,11,23');
|
[0.011 ms]
Col 1 |
Col 2 |
Col 3 |
11 |
12 |
13 |
21 |
22 |
23 |
|
Ok |
Array with title + CSS for Rows |
249 |
$css4 = ' table.mytab4 {border:1px solid black;border-collapse:collapse; margin:0;} .mytab4 th, td{ border: 1px solid black; padding: 4px; margin:0;} .mytab4 th{background-color: #338; color: white;} .mytab4 tr:nth-child(odd) { background-color:inherit; } .mytab4 tr:nth-child(even) { background-color:#DDD; }'; $t->addCss($css4); //add new style $data = [ [11,12,13], [21,22,23], [31,32,33], [41,42,43], ]; $table = Table::create($data) ->attribute('mytab4') ->title(['Col 1','Col 2','Col 3']) ->getHtml(); $t->checkHTML($table,'mytab4,11,23');
|
[0.014 ms]
Col 1 |
Col 2 |
Col 3 |
11 |
12 |
13 |
21 |
22 |
23 |
31 |
32 |
33 |
41 |
42 |
43 |
|
Ok |