1
I have been a few days having trouble searching my app using AngularJS
and today I was able to discover the reason: During the consultation SQL
with LIKE
, it is simply not receiving the parameter as it should.
My job is like this:
self.searchAll = function(text) {
var parameters = [text];
return DBA.query("SELECT id, place_name FROM tblPlaces WHERE place_name LIKE '%(?)%'", parameters)
.then(function(result) {
return DBA.getAll(result);
});
}
I think because of (?)
be glued to the %%
, it does not recognize that there should fit the text parameter. I decided to do some tests and put some direct text in the query, without coming by parameter and it worked.
I also tried to concatenate the text, to see if this way would work, because if it worked I could try to pass the parameter this way. But also didn’t work, it returns me an error of Sqlite.
Then I had two questions: Is there the possibility of doing this search using LIKE and receiving this text by parameter the way it is there in the function? Or it would be better if I made a general SELECT, turned it into a JSON object and made use of the Angular filter?
Obs: This search I’m trying to do is on a screen that lists several categories and the user will be able to search for products in general.
your database is Sqlite? and your Angularjs application ?
– Marco Souza
Try to reverse the single aces with the doubles
– Julyano Felipe
@GOKUSSJ4 Yes. It is an app with Ionic.
– Altemberg Andrade
@Julyanofelipe Inverti the quotation marks, but the problem persists.
– Altemberg Andrade