问题
I´m using blueimp with MySQL integration ( https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration ) and i want to choose some rows, I want to show only the pictures that match with “title=lademo” , and I think that i should to use the Select..Where that there are inside on index.php. I´ve added in "Select..Where" a condition and the JSON output show me 3 rows with (id=77). only a row is correct (json output #2), rest of output json (#0 and #1) are wrong (id=29 and id=30). Perhaps I need to break the loop (exit when I found id=77) , but I don’t know how to do it . Any idea?. Any comments are welcome and Happy New year!!
My Table:
id name size type url title description
29 jacuzzi.jpg 107975 image/jpeg NULL launo en playa
30 honeymoon-4.jpg 85334 image/jpeg NULL lados en ciudad
36 honeymoon2.jpg 38860 image/jpeg NULL en el extranjero
77 honeymoon.jpg 48291 image/jpeg NULL lademo en el campo
Index.php
protected function set_additional_file_properties($file) {
parent::set_additional_file_properties($file);
$mytitle='lademo';
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$sql = 'SELECT `id`, `type`, `title`, `description` FROM `'
.$this->options['db_table'].'` WHERE `title`="'.$mytitle.'"';
$query = $this->db->prepare($sql);
$query->bind_param('s', $file->name );
$query->execute();
$query->bind_result(
$id,
$type,
$title,
$description
);
while ($query->fetch()) {
$file->id = $id;
$file->type = $type;
$file->title = $title;
$file->description = $description;
}
}
}
json output are 3 rows (should be only one row). NOTE that ONLY the JSON output #2 is the correct: your id and *.jpg is true - same on the table (id=77) -. JSON output with #0 and #1, your *.jpg are wrong (I don't understand).
JSON output:
files
#0
name "jacuzzi.jpg"
id 77
.....
#1
name "honeymoon-4.jpg"
id 77
......
#2
name "honeymoon.jpg"
id 77
来源:https://stackoverflow.com/questions/27741899/blueimp-choose-only-some-rows-with-select-where-it-doesn-t-work