SQL query does not return even having values

Asked

Viewed 58 times

0

I didn’t mean that

Returns

SELECT * FROM tbl_temporadas WHERE serie_id = '2' AND serie_slug = 'dois-homens-e-meio' AND temp_audio = 'l'

inserir a descrição da imagem aqui

Does not return

SELECT * FROM tbl_temporadas WHERE serie_id = '2' AND serie_slug = 'dois-homens-e-meio' AND temp_audio = 'd'

inserir a descrição da imagem aqui

My table

inserir a descrição da imagem aqui

CRUD

private $query;

private function prep_exec($prep, $exec) {          
    $this->query = $this->get_con()->prepare($prep);
    $this->query->execute($exec);
}

public function select($fields, $table, $prep, $exec) {
    $this->prep_exec("SELECT ".$fields." FROM ".$table." ".$prep."", $exec); 
    return $this->query;
}

$open_serie = $ctlr->select("*", "tbl_seriados", "WHERE serie_slug = ?", array($sep[0]));

foreach ($open_serie as $list) :
   $serie_id = (int)$list['serie_id'];

   $open_temp_dub = $ctlr->select("*", "tbl_temporadas", "WHERE serie_id = ? AND serie_slug = ? AND temp_audio = ?", array($serie_id, 'dois-homens-e-meio', 'D'));

endforeach;
  • Try to repair your database.

  • try to make the id whole by removing the quotation marks of the number 2 SELECT * FROM tbl_temporadas WHERE serie_id = 2 AND serie_slug = 'two-men-and-a-half' AND temp_audio = 'l'

  • @Anonimo It wasn’t, strange

  • @Andersonhenrique In my code I already define the id int $serie_id = (int)$list['serie_id']; still won’t

  • Put your php code too

  • There is a chance to have a blank space before the’d'?

  • @goio: what do you mean by "It wasn’t" when trying to repair the database?

  • Truth may be what @Ronaldoaraújoalves said, in this case to test, run this query SELECT * FROM tbl_temporadas WHERE serie_id = '2' AND serie_slug = 'two-men-and-a-half' AND temp_audio LIKE '%d%'

  • If return is because there is space between the d

  • @anonimo Remains the same http://prntscr.com/nyyr75

  • 1

    @Anderson Henrique http://prntscr.com/nyysvg. Ronaldo has no whitespace

  • try the quotes again at number 2 using like, because your first query that worked you used quotes

  • @Andersonhenrique Even if you select only the id after the Slug together it only pulls the first 3 http://prntscr.com/nyyvbi http://prntscr.com/nyyvom

  • If the class $ctrl do not have a debug method to print which query is being formatted, I would put a echo $sql; exit; somewhere inside $ctrl->select to see which query is being formed.. may sometimes be formatting incorrectly.

Show 10 more comments

1 answer

1


Your problem is in the serie_slug column, may have some space or character that is breaking, update everyone with the query and in php D is higher

UPDATE tbl_temporadas SET serie_slug='dois-homens-e-meio' WHERE serie_id = 2;

And test the SELECT again

SELECT * FROM tbl_temporadas WHERE serie_id = '2' AND serie_slug = 'dois-homens-e-meio' AND temp_audio = 'd'

Browser other questions tagged

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