Parte del codigo clase.php
Código PHP:
       function lista($fields, $table){
        $query= "
            SELECT
                $fields
            FROM
                $table
        ";
        
        $consulta = $this->conexion->query($query);
        $consulta = $consulta->fetchAll();
 
        $rows = explode(",", $fields);
        #print_r($rows);
        $num_rows = count($rows);
 
        $impresion = "<tbody>";
        foreach ($consulta as $cons => $value) {
            echo "$impresion";
            $impresion .= "<tr>";
            for($i = 0; $i < 1; $i++){
                $impresion .= "<td>".utf8_encode($cons[$rows[$i]])."</td>";
            }
            $impresion .= "</tr>";
        }
        $impresion .= "</tbody>"; 
    Código PHP:
   function conexion()
    {
        try{
#$this->conexion = new PDO($this->datos, $this->usuario, $this->password);
#no me funciona cuando hago la llamada desde otro .php
#    $db = new baseDeDatos("mysql:dbname=corralon;host=localhost","root","root123");
#$db->conexion();
#pero si lo pongo como esta aca
 
            $this->conexion = new PDO("mysql:dbname=corralon;host=localhost","root","root123");
            
        }catch(PDOException $e){
            echo "Problemas Tecnicos: ".$e->getMessage();
        }
    } 
    Aca se llama la funcion
Código PHP:
   <?php 
    require_once("../datos/clase.php");
 
    $listado = new baseDeDatos("mysql:dbname=corralon;host=localhost","root","root123");
    $listado->conexion();
 
    $columnas="idArt,nameArt,descArt,rubroId,subrubroId,precioEntradaArt,precioSalidaArt,unidadVentaArt,proveedorId";
 ?>
 
<?php $listado->lista($columnas, "articulo"); ?>     
 


