How to receive date values from a Sybase database?

Asked

Viewed 14 times

-1

Good, I need to search a database Sybase fields type Date to fill in my application.

When searching for the necessary information and debugging it, the fields in the Date format appeared to me empty instead of being filled with their respective value in the database.

I’m using ODBC to connect to the database.

Does anyone know why this is happening?

My model query is very simple:

public function recibo($codigo, $numero) {
    require(APPPATH . 'libraries/odbc_conn.php');
    $query = odbc_exec($db, "select * from GP_Web_Recibos where Codigo = 14 AND Numero = 3302");
    while ($row = odbc_fetch_array($query)) {
        $tudo[] = $row;
    }

    if (empty($tudo)) {
        $tudo = 0;
    }

    return $tudo;
}

Controller :

public function teste2() {
    $nrrecibo = $this->uri->segment(3);
    $codigo = $this->session->codigo;
    $campos = $this->Vencimentos_model->recibo($codigo, $nrrecibo);
    $abono = [];
    $descontos = [];
    foreach ($campos as $key => $campo) {
        if ($campo['Codigo_Paga_Desc'] == '1') {
            $abono[] = $campo['Resultado'];
        } elseif ($campo['Codigo_Paga_Desc'] == '2') {
            $descontos[] = $campo['Resultado'];
        }
        # code...
    }

    $campos['abonototal'] = array_sum($abono);
    $campos['descontostotal'] = array_sum($descontos) - $campos[0]['Vl_SSOC'] - $campos[0]['Vl_IRS'];
    $data['campos'] = $campos;
    echo "<pre>";
    print_r($campos);
    echo "</pre>";
}

1 answer

0

I created a new field with the value of each field i want with the converted value of it.

$query = odbc_exec($db, "select *, CONVERT(Varchar(50), Data, 1) as DATA  from GP_Web_Recibos where Codigo = 14 AND Numero = 3302");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.