PDO PHP esta inserindo null

0 respostas
php5.3
F

Galera, estou a 4 dias tentando resolver e não consigo.

function ExecuteSql($query, array $params = null) {

    $this->obj = $this->Conectar()->prepare($query);

    //contagem dos elementos do array
    if (count($params) > 0):
        //pega chave e valor :cor , $cor
        foreach ($params as $key => $value):
            $this->obj->bindParam($key, $value);
        endforeach;
    endif;
     
    
    return $this->obj->execute();
     
}



function GravarPedido($cliente,$cod,$ref){
  try {
        $sql  = "INSERT INTO ".$this->prefx."pedidos ";
        $sql .= "(ped_data,ped_hora,ped_cliente, ped_cod, ped_ref)";
        $sql .= " VALUES";
        $sql .= "( :data, :hora, :cliente, :cod, :ref)";

    } catch (Exception $exc) {
        echo $exc->getTraceAsString();
        echo $exc->getMessage();
    }

    $params = array (
                 
        ':data'    => Sistema::DataAtualUS(),
        ':hora'    => Sistema::HoraAtual(),
        ':cliente' =>(int)$cliente,
        ':cod'     =>$cod,
        ':ref'     =>$ref
         ); 
    
    echo '<pre>';
    var_dump($params);
    echo '<pre>';
    
 $this->ExecuteSql($sql,$params);       

}

CHAMO O OBJ E METODO
$pedido = new Pedido();

$cliente = 10;
$cod     = $_SESSION['pedido'];
$ref     = '20';

$pedido->GravarPedido($cliente,$cod,$ref);
RESULTADO

array(5) {

[":data"]=>

string(10) 2017-06-23

[":hora"]=>

string(8) 23:21:04

[":cliente"]=>

int(10)

[":cod"]=>

string(8) 58964521

[":ref"]=>

string(2) 20

}

ATUALIZAçÃO MYSQL
0000-00-00
00:00:20
20
20
20

Criado 23 de junho de 2017
Respostas 0
Participantes 1