Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

312
Visualizações
How to catch sql exceptions in php

I am writing rest apis in php, but the errors are thrown when there are some null values are inserted in the api.It shows the sql query into the response page, how do I stop it from being displayed, what is the best exception handling in this case.I am bit new to php, so any help is appreciated. Below is the sample code I write to query.

  $limit = " LIMIT ".$post_data['offset'].",".$post_data['limit'];
    $sql = "SELECT record_id from ";
    $shareResult= $this->db->query($sql)->result_array();
    if(empty($shareResult[0]['record_id']) || $shareResult[0]['record_id'] != 0){
        $query="SELECT *";

        $result= $this->db->query($query);
        if($result->num_rows()>0){
            $res1=$this->db->query($qry)->result_array();
            $res[0]=$res1[0];
            $res[1]=$result->result_array();
            return $res;
        }
    }else if($shareResult[0]['record_id'] === 0){
        return false;
    }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

if you are talking about Codeigniters default debug option you should take a closer look @your db config

Something like that should appear

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'database_name',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => TRUE,
    'db_debug' => TRUE,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array()
);

Take a look at db_debug and set it to false.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda