/
TruncateTable.php
50 lines (43 loc) · 1.01 KB
/
TruncateTable.php
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
<?php
/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011
TASK
***********************************************/
class TruncateTable extends task
{
protected static $description = "I will truncate a table provided with --table, and optionally --DB";
public function run($PARAMS = array())
{
global $CONFIG, $DBOBJ;
$stop = false;
if (strlen($PARAMS['table']) == 0)
{
$this->task_log('Provide a table name with --table');
$stop = true;
}
if (strlen($PARAMS['DB']) > 0)
{
$ThisDB = $PARAMS['DB'];
}
else
{
$ThisDB = $CONFIG['DB'];
}
if (self::check_DBObj() && $stop == false)
{
$SQL= 'TRUNCATE TABLE `'.$ThisDB.'`.`'.$PARAMS['table'].'`;';
$DBOBJ->Query($SQL);
if ($DBOBJ->NumRowsEffected() == 0)
{
$this->task_log($PARAMS['table']." table truncated from the ".$ThisDB." DB");
}
else
{
$this->task_log("Table ".$PARAMS['table']." cannot be found in ".$ThisDB);
}
}
}
}
?>