query function with named placeholders
===

I'm using PDO and currently this function for inserting data to database. But PDO is nothing without `BindParam` or `BindValue`. I want to use named placeholders with `BindValue` to make it more secure, but i dont know how to accomplish that. 

    function insert($table, $data, $secure = false) {
    
            // If the insert data is not an array
            if (!is_array($data))
                return;
    
            // Filter the input data
            foreach ($data as $col => $val) {
                $cols[] = $col;
    
                if ($secure == true) {
                    if (is_float($val)) {
                        $vals[] = htmlspecialchars(addslashes(trim($val)));
                    } else {
                        $vals[] = "'" . htmlspecialchars(addslashes(trim($val))) . "'";
                    }
                } else {
                    if (is_float($val)) {
                        $vals[] = $val;
                    } else {
                        $vals[] = "'" . $val . "'";
                    }
                }
            }
    
            // Form the SQL query
            $query = "INSERT INTO " . $table . ' (' . implode(', ', $cols) . ') '
                    . 'VALUES (' . implode(', ', $vals) . ')';

            // Execure the query		
            $sth = $this->_connection->prepare($query);
            $result = $sth->execute();
    
            // If the query is not executed properly
            if (!$result)
                return false;
            else
                return true;
        }


