Yadcf with Select2 puts empty selected option - yadcf

First of all, thanks a lot for amazing plugin!
I have Datatable with server-side processing. When I choose one option from dropdown, I got 2 selected options: one I choose, and another empty. I mean I got this:
<ul class="select2-selection__rendered">
<li class="select2-selection__choice" title=""></li>
<li class="select2-selection__choice" title="option1"></li>
<li class="select2-search select2-search--inline"></li>
</ul>
It makes wrong SQL query (in LIKE operator I got something like '|option1'). I can get correct query with php script, but it won't remove empty selected option from header of my table.
Would be appreciated for any help.

You are welcome,
Looks like you using a multi select filter on some column, and thats why yadcf sends strings with | (OR) to your server.
On your server side you have to do the split of the string into array/list of string and construct a proper sql query.
Split in Java
Split in PHP(see code sample in bottom
p.s I'm the author of yadcf

Related

Replace part of serialized data "resets" data to standard settings

I'm managing a couple of hundreds of websites and need to change part of a serialized data.
It's a wordpress child theme and inside of the theme's "Options" settings.
Using this script
UPDATE wp_e4e5_options
SET option_value = REPLACE(option_value, 'Copyright | by <a href="https://company.com"', ' ')
a:1:{s:3:"copyright";s:17:"Copyright | by <a href="https://company.com"";}
I was certain, it would just find that part of the serialized data and replace. But it doesn't.
It reset the setting to the theme's standard setting. Even when I edit it manually by using Adminer.php in the table, it resets.
I'm aware, that this might be in the wrong forum, since it's Wordpress related, but I believe it's SQL that's the issue here.
So my question is:
If i edit it manually using Adminer.php (simple version of
phpMyAdmin), it resets all the settings back to standard. How can I
edit only part of the serialized data and only the part shown above?
What makes it "reset" to standard settings?
UPDATE:
Thanks to #Kaperto I got this working code now, which gave me a new issue.
UPDATE wp_e4e51a4870_options
SET option_value = REPLACE(option_value, 's:173:"© Copyright - Company name [nolink] | by <a href="https://company-name.com" target="_blank" rel="nofollow">Company Name</a>";', 's:40:"© Copyright - Company name [nolink]";')
The problem is, it's gonna be used as a code snippet with ManageWP looping through several hundreds of websites which all have different company names. So the first part of the string is unique but the rest is the same on all sites, after the pipe |.
So I somehow need to do this:
Find whole series where this string is included | by <a href="https://company-name.com" target="_blank" rel="nofollow">Company Name</a>"
Get the whole series s:173:"© Copyright -
Company name [nolink] | by <a href="https://company-
name.com" target="_blank"
rel="nofollow">Company Name</a>
Replace with new series with updated character count, since company name is different
Is this even achievable with pure SQL commands?

HTML not rendering through EJS

so basically I have a bunch of HTML strings in a MySQL table and I am trying to display then through EJS.
For instance, I have a string that looks like this is a link with some <code>code</code> next to it. In my code I try to display it in that way.
<%- listOfStrings["myString"] -%>
However, as you probably guessed when reading the title, the string seems to be escaped when displaying on the screen.
What's even weirder to me is that I have two tables with such strings, and it works for the first one, while it doesn't for the second one. One difference though, is that the first one is hardcoded, while the second one can be edited through some tool on my website. Encoding is utf32_unicode_ci for both tables, if that matters.
For debugging purposes I tried to store the aforementioned strings in a js variable and display them in the console: then it seems like <and > characters are all escaped for some reason. Is there an explanation to this behavior, and if so how to fix it so that HTML renders correctly?
Thanks for your help!
You can try it :
<%=listOfStrings["myString"]%>

#Dblookup and formatting on web

I have been developing a web application using domino, therein I have dblookup-ing the field from notes client; Now, this is working fine but the format of value is missing while using on web.
For example in lotus notes client the field value format is as above
I am one, I am two, I am one , I am two, labbblallalalalalalalalalalalalalalalalalalaallllal
Labbbaalalalallalalalalalaalallaal
Hello there, labblalalallalalalllaalalalalalalalalalalalalalalalalalalalalalalala
Now when I retrieve the value of the field on web it seems it takes 2 immediate after 1. and so forth, I was expecting line feed here which is not happening.
The field above is multi valued field. Also on web I have used computed text which does db lookup from notes client.
Please help me what else could/alternate solution for this case.
Thanks
HD
Your multi-valued field has display options associated with it and the Notes client honors those. Obviously, your options are set up to display entries separated by newlines.
The computed text that you are using for the web does not have options like that and the field options are irrelevant because you aren't displaying the field. Your code has to insert the #Newlines. That's pretty easy because #DbLookup returns a list, and if you concatenate a list and a scalar, the scalar will be appended to each element of the list. (Look at the third example under "concatenation, pairwise" here to see what I mean.
The way you've worded your question is a little unclear to me, but what you need in your computed text formula is either something like this:
list := #DbLookup(etc,. etc.);
list + #Newline;
Or something like this:
multiValueFieldContainingListWithDbLookupResult + #NewLine;
I used #implode(Dblookupreturnedvalue;"");
thanks All :)

Deleting SPAM found in SQL query results, using jQuery

My website is getting spammed with entries such as:
<a style="text-decoration:none" href="/amoxicillin-kamagra-shop">.</a>
I want to filter those out with jQuery, as there are too many to do it manually through the UI (wayyy too tedious). The challenge is determining the SPAM-matching criteria, such as the HTML tag info.
So, for example, if I determine that most or all spam is of the form
<a style="text-decoration:none ... >.</a>
How would I delete those entries with jQuery?
DELETE from yourtable WHERE string like '<%a style="text-decoration:none%>.%'

Deleting a value from sql database using jsp

I'm trying to use jsp to rendering a simple database and have the ability to delete a row using a button. I'm running into the trouble of not being able to fetch the primary key from the row because I've been using to iterate through the table. I've tried passing just simple numbers to denote the primary key (integers) but its not grabbing it.
Lets say I want to delete the row with the primary key of 12.
<form action="deleteResponse.jsp">
<c:set var="numId" value="12"/>
<input type="submit" name="delete" value="Delete"/>
</form>
This generates a button which opens up deleteResponse.jsp which has the following to catch the value.
<sql:update var="counselorDelete" dataSource="jdbc/IFPWAFCAD">
DELETE FROM Counselor
WHERE counselor_id = ?<sql:param value="${param.numId}"/>
</sql:update>
It's not doing anything, and I'm not sure whats going on with it. If I manually put in the value 12 in the sql query it will delete the row but it won't do it if I try to fetch the value.
Thanks very much in advance!
Also as a side note. I'm having a hard time understanding how to properly write JSPs. I see that most of the time people use <% Java code %> but in the netbean tutorial, it uses the and functions. Could someone explain that to me? I'm also using glassfish as a localhost sql server. Netbean generates a glassfish xml but I also see people using DriverManager.getConnection methods. Which one is conventionally better?
I would try to separate the UI/JSP code from the DAO layer, using a seperate Bean to handle all the insert/uodate/delete operations.
Take a look at the logfiles of your Applicationserver, this might give you some hints.
Kr, R
Edit: Concerning the sql:
<sql:update var="counselorDelete" dataSource="jdbc/IFPWAFCAD"
sql="DELETE FROM Counselor WHERE counselor_id = ?" >
<sql:param value="${param.numId}"/>
</sql:update>