Trouble in search in Grocery CRUD library - mysql

While using search query through Grocery CRUD library in Codeigniter,search for "0" value of a data in a table results in the full table. why?
$crud = new grocery_CRUD();
$crud->set_table('listing');
$crud->field_type('SwimmingPool','dropdown',array('1'=>'Yes', '0'=>'No'));
$output = $crud->render();
Now searching in output of grocery_CRUD for the values of SwimmingPool = 0, results in the complete table (all values). While it works fine for SwimmingPool =1 and filter the results properly. I double checked the MySQL database table 'listing' and SwimmingPool has value 0 or 1 only. is this some kind of bug that search query results in the complete table if searched for 0. Any Solution?

This is likely a bug of grocery crud, interpreting 0 as null so it does not apply the search filter. I suggest filling a bug report at Grocery's bug tracker on github

Related

BigQuery view integer column read as Json when imported in PowerBI

I have created this view in BigQuery:
create view project.dataset.view1 as
SELECT
o.first
,o.id as theid
,p.id as otherid
FROM dataset.view2 as o
JOIN dataset.view3 as p on p.whatever = o.id
When i add the data in that view to PowerBi, the column p.id it shows as Json string with all the three columns, while it should be only an integer.
This is an example of what i see:
{""v"":{""f"":[{""v"":""name""},{""v"":""11""},{""v"":""9""}]}}
In BigQuery it just looks fine with the integer value I'm expecting.
Can somebody shed some light on this? It's driving me nuts. Thanks.
Ok, i don't know how much of a bug vs my fault this is. i have named the 3rd column just like the view.
Not sure here if it's a good thing to do, but again, Google Data Studio and KlipFolio didn't give me that result.
Changing the column name fixed it though in PowerBI.

Access Report from Query inexplicably multiplies columns

I have a weird problem. First off, I'm not well versed in Access, but I'm using it for a project to track visibility of log sources and detections and map them to the MITRE ATT&CK Framework. I tables such as Techniques to track the MITRE Techniques, Data_Sources to track the various sources used by those Techniques, and Data_Sources_Coverage that has a visibility ranking for each data source for the company. I have a query built with the below SQL (probably a little messy):
SELECT Technique.Name, Technique.ID, Technique.[Tactic ID], Count(Technique.[Data Sources].Value) AS Technique_Sources, Count(Data_Source_Coverage.[Data Source]) AS Sources_Visible
FROM (Data_Sources INNER JOIN Technique ON Data_Sources.Name = Technique.[Data Sources].Value) INNER JOIN Data_Source_Coverage ON Data_Sources.Name = Data_Source_Coverage.[Data Source]
WHERE (Data_Source_Coverage.Coverage)>0)
GROUP BY Technique.Name, Technique.ID, Technique.[Tactic ID];
The query works great, prints the results as I expect them. However, when I generate a report from that query things go off the rails. The report inexplicably (I did nothing to the data), multiplies the Technique_Sources column by the Sources_Visible column and displays that in the Technique_Sources Column, and then every entry in the Sources_Visible column becomes a '1'. Pics below. Thanks for the help.

yii2 query on 2 tables to return a grid view result

i am new to yii2 and want to do a simple query on 2 tables according to
policy_id.
The result is according to user_id on policyread table. The policyread table holds all policies already read by the user. I am trying to show a result of all unread policies. My controllers are PolicyController and PolicyreadController. I am from old oscom 2.3.4 days and trying to learn this new framework.
i figured it out. in my sleep deprived state i was asking for the query to return where user_idis equal .. i simply called a list of all policies then compared that array result with the user_id array of completed policies. in the end array_diff didnt work because i was using a mulidimesnional array .. instead array_diff_key gave me the answer. thanx again for muhammad for being patient. im a bit new here

Gerrit REST API: cannot use _sortkey to resume a query

I'm using Gerrit REST API to query all changes whose status is "merged". My query is
https://android-review.googlesource.com/changes/?q=status:merged&n=2
where "n=2" limits the size of query results to 2. So I got a JSON object like:
Of course there are more results. According to the REST document:
If the n query parameter is supplied and additional changes exist that match the query beyond the end, the last change object has a _more_changes: true JSON field set. Callers can resume a query with the N query parameter, supplying the last change’s _sortkey field as the value.
So I add the query parameter N with the _sortkey of the last change 100309. The new query is:
https://android-review.googlesource.com/changes/?q=status:merged&n=2&N=002e4203000187d5
With this new query, I was hoping that I'll get another 2 new query results, since I provided the _sortkey as a cursor of my previous search results.
However, it's really weird that this new query returns exactly the same results as the previous query, instead of the next 2 results as I expected. It seems like providing "N=002e4203000187d5" has no effect at all.
Does anybody know why using _sortkey to resume my query doesn't work?
I chatted with one of the developers at Google, and he confirmed that _sortkey has been removed from the newer versions of Gerrit they are running at android-review and gerrit-review. The N= parameter is no longer valid. The documentation will be updated to reflect this.
The alternative is to use &S=x to skip x results, which I tested and works well.
sortkey is deprecated in Gerrit v2.9 -
see the (Gerrit) ReleaseNotes-2.9.txt, under REST API - Changes:
[[sortkey-deprecation]]
Results returned by the [query changes] endpoint are now paginated using offsets instead of sortkeys.
The sortkey and sortkey_prev parameters on the endpoint are deprecated.
The results are now paginated using the --limit (-n) option to limit the number of results, and the -S option to set the start point.
Queries with sortkeys are still supported against old index versions, to enable online reindexing while clients have an older JS version.
See also here -
PSA: Removing the "sortkey" field from the gerrit-on-borg query interface:
...
Our solution is to kill the sortkey field and its related search operators (sortkey_before, sortkey_after, and resume_sortkey).
There are two ways you can achieve similar functionality.
Add "&S=" to your query to skip a fixed number of results.
(Note that this redoes the search so new results may have jumped ahead and
you might process the same change twice.
This is true of the resume_sortkey implementation as well,
so your code should already be able to handle this.)
Use the before/after operators.
Instead of taking the sortkey field from the last returned change and
using it in a resume_sortkey operator, you take the updated field from
the last returned change and use it in a before operator.
(This has slightly different semantics than the sortkey field, which
uses the change number as a tiebreaker when changes have similar updated times.)
...

MySQL - return one row from 2 rows in the same table, overwrite the contents of the first 'default' with the populated fields of the second 'override'

I am trying to make use of the mobile device lookup data in the WUFL database at http://wurfl.sourceforge.net/smart.php but I'm having problems getting my head around the MySQL code needed (I use Coldfusion for the server backend). To be honest its really doing my head in but I'm sure there is a straightforward approach to this.
The WUFL is supplied as XML (approx 15200 records to date), I have the method written that saves the data to a MySQL database already. Now I need to get the data back out in a useful way!
Basically it works like this: firstly run a select using the userAgent data from a CGI pull to match against a known mobile device (row 1) using LIKE; if found then use the resultant fallback field to look up the default data for the mobile device's 'family root' (row 2). The two rows need to be combined by overwriting the contents of (row 2) with the specific mobile device's features of (row 1). Both rows contain NULL entries and not all the features are present in (row 1).
I just need the fully populated row of data returned if a match is found. I hope that makes sense, I would provide what I think the SQL should look like but I will probably confuse things even more.
Really appreciate any assistance!
This would be my shot at it in SQL Server. You would need to use IFNULL instead of ISNULL:
SELECT
ISNULL(row1.Feature1, row2.Feature1) AS Feature 1
, ISNULL(row1.Feature2, row2.Feature2) AS Feature 2
, ISNULL(row1.Feature3, row2.Feature3) AS Feature 3
FROM
featureTable row1
LEFT OUTER JOIN featureTable row2 ON row1.fallback = row2.familyroot
WHERE row1.userAgent LIKE '%Some User Agent String%'
This should accomplish the same thing in MySQL:
SELECT
IFNULL(row1.Feature1, row2.Feature1) AS Feature 1
, IFNULL(row1.Feature2, row2.Feature2) AS Feature 2
, IFNULL(row1.Feature3, row2.Feature3) AS Feature 3
FROM
featureTable AS row1
LEFT OUTER JOIN featureTable AS row2 ON row1.fallback = row2.familyroot
WHERE row1.userAgent LIKE '%Some User Agent String%'
So what this does, is takes your feature table, aliases it as row1 to get your specific model features. We then join it back to itself as row2 to get the family features. Then the ISNULL function says "if there is no Feature1 value in row 1 (it's null) then get the Feature1 value from row2".
Hope that helps.