Skip to content

Commit 00f3a33

Browse files
author
mimidots
committed
Done with sanitize tables todos
1 parent 1013f48 commit 00f3a33

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Builder.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public static function table($table)
2626
if(Connect::getConn()==null){
2727
self::terminate(self::$response);
2828
}
29-
//TODO sanitize the table name
30-
self::$table = $table;
29+
self::$table = self::sanitize($table);
3130

3231
return new static;
3332
}
@@ -393,8 +392,8 @@ protected function exec($query)
393392

394393
public function drop()
395394
{
396-
//todo validate the table name
397395

396+
static::valTable();
398397
$sql = /** @lang text */
399398
"DROP TABLE " . self::$table;
400399
try {
@@ -418,4 +417,20 @@ private static function sanitize($data)
418417
$data = htmlspecialchars($data);
419418
return $data;
420419
}
420+
421+
422+
/**
423+
*Validate that the table name has been provided and is a string
424+
*/
425+
private static function valTable(){
426+
if(static::$table==null || ! is_string(static::$table)){
427+
static::$response["status"] = "error";
428+
static::$response["response"] = "check the table name provided";
429+
static::$response["code"]=5000;
430+
return self::terminate(static::$response);
431+
432+
}else{
433+
static::$table=self::sanitize(static::$table);
434+
}
435+
}
421436
}

0 commit comments

Comments
 (0)