public function truncate($table = '')
    {
        // if table name not pass
        if (!empty($table)) {
            // create count query
            $this->sql = "TRUNCATE TABLE `$table`;";
            // pdo prepare statement
            $this->STH = $this->prepare($this->sql);

            try {
                if ($this->STH->execute()) {
                    // close pdo
                    $this->STH->closeCursor();
                    // return number of count
                    return true;
                } else {
                    self::error($this->STH->errorInfo());
                }
            } catch (\PDOException $e) {
                // get pdo error and pass on error method
                self::error($e->getMessage() . ': ' . __LINE__);
            }
        } else {
            self::error('Table name not found..');
        }
    }
public function truncate($table = '')
    {
        // if table name not pass
        if (!empty($table)) {
            // create count query
            $this->sql = "TRUNCATE TABLE `$table`;";
            // pdo prepare statement
            $this->STH = $this->prepare($this->sql);

            try {
                if ($this->STH->execute()) {
                    // close pdo
                    $this->STH->closeCursor();
                    // return number of count
                    return true;
                } else {
                    self::error($this->STH->errorInfo());
                }
            } catch (\PDOException $e) {
                // get pdo error and pass on error method
                self::error($e->getMessage() . ': ' . __LINE__);
            }
        } else {
            self::error('Table name not found..');
        }
    }
public function truncate ( $ table = '' ) { // if table name not pass if ( ! empty ( $ table ) ) { // create count query $ this -> sql = "TRUNCATE TABLE `$table`;" ; // pdo prepare statement $ this -> STH = $ this -> prepare ( $ this -> sql ) ; try { if ( $ this -> STH -> execute ( ) ) { // close pdo $ this -> STH -> closeCursor ( ) ; // return number of count return true ; } else { self :: error ( $ this -> STH -> errorInfo ( ) ) ; } } catch ( \ PDOException $ e ) { // get pdo error and pass on error method self :: error ( $ e -> getMessage ( ) . ': ' . __LINE__ ) ; } } else { self :: error ( 'Table name not found..' ) ; } }
Truncate a MySQL table.

@param string $table

@return bool
Truncate a MySQL table .