Secure row insertion using a position-based prepared statement
As noted in your other question, that exception handling completely masks the true exception.  It adds no value yet detracts.  There's no reason to do that.  Just allow the exception to throw out of the function.



As for 'security', assuming you properly control the table name, it is safe.  (A better way to phrase that may be that SQL injection is not possible as long as you control $table.)



I might consider writing it a bit differently though:

public function database_add_row($table, $data) {
    $placeholders = implode(', ', array_fill(0, count($data), '?'));
    $sql = "INSERT INTO {$table} VALUES ({$placeholders})";
    $stmt = $this-&gt;database-&gt;prepare($sql);
    if ($stmt-&gt;execute($data)) {
        return $this-&gt;database-&gt;lastInsertId();
    } else {
        return false;
    }
}




I also might consider using associative arrays.  That would allow you to specify columns (which could be useful if you had default-valued columns or auto incrementing columns).

public function database_add_row($table, $data) {
    $cols = array_keys($data);
    $columns = implode(', ', $cols);
    $placeholders = implode(', ', array_map(function($c) { return ":{$c}"; }, $cols));
    $sql = "INSERT INTO {$table} ({$columns}) VALUES ({$placeholders})";
    $stmt = $this-&gt;database-&gt;prepare($sql);
    if ($stmt-&gt;execute($data)) {
        return $this-&gt;database-&gt;lastInsertId();
    } else {
        return false;
    }
}


Then you would use it like:

$obj-&gt;database_add_row("table1", array('column1' =&gt; 'val1', 'column2' =&gt; 'val2'));




Depending on how far you plan to go with your DB abstractions, you might want to consider a DBAL or ORM library.  The Doctrine Project has quite widely used versions of both of those.