How to show DBMS name and version in laravel view? - laravel

I want to show a status bar in a laravel website. Which will show the DBMS name and version number. The output I want is like
PostgreSQL 9.2.24
Or
MySQL 5.6
I can get the name of database by using env('DB_CONNECTION'). It is giving me the name(although, it is showing 'pgsql'; not 'PostgreSQL ').
However, I don't understand how can I get the version number in view. What is the way to get the version number?

You can use DB::raw() to create database raw expression.
$version = DB::select( DB::raw("select version()"));
pass the value to your view.

Related

Laravel Datatable Show Different data from database

Hi Guys i wanna ask something
I have column in database mysql like :
199910192022032006
but when laravel datatable show that data column, its change like:
199910192022032000
why its can be happen ?
what data type are you using? integer? try to change into float or double or maybe varchar

PrestaShopDatabaseException - Unknown column 'cf.show_invoice' in 'field list'

After migrating a prestashop 1.7 from one server to another, quite everything works fine.
Ordering / paying is ok
Order displays for the customer and the shop-owner.
But when clicking on the order to view the details, there is a big failure with messages =
SELECT fd., cfl., cf.type, cf.show_invoice FROM is_velsof_supercheckout_fields_data fd JOIN is_velsof_supercheckout_custom_fields_lang cfl ON fd.id_velsof_supercheckout_custom_fields = cfl.id_velsof_supercheckout_custom_fields JOIN is_velsof_supercheckout_custom_fields cf ON cf.id_velsof_supercheckout_custom_fields = cfl.id_velsof_supercheckout_custom_fields WHERE id_order = "3059" AND cfl.id_lang = "1"
at line 769 in file classes/db/Db.php
https://snipboard.io/tOELSc.jpg
Does anyone have a clue about this please ?
PS : the 6 mysql tables used by supercheckout are the same between old server and new server
The error is quite clear,
a module query is looking for a field that is not present in the DB.
Check in your DB that the table "is_velsof_supercheckout_custom_fields" contains the field "show_invoice".
If the module version on the "new" server is different from the one on the old server, make sure the module upgrade procedure has been triggered, maybe some new field had been added in a recent version.

Oracle apex - Interactive Grid setSelectedRecords does not work

I am trying to set selected records in apex Interactive Grid following documentation
API documentation but it does not work.
I have an array of records and when I am trying to set selected records using
apex.region("grid").widget().interactiveGrid("setSelectedRecords", records);
or
grid.setSelectedRecords(records);
when I check it via console the output is like below but the rows are not selected (selection is empty as I would pass the empty array.
console output image
I am using APEX 19.2, anyone faced a similar issue? Any suggestions?
Try this:
apex.region("gridId").widget().interactiveGrid("getViews","grid").setSelectedRecords(records, true);
Perhaps must be the record between '[]' example:
var record = apex.region("gridId").widget().interactiveGrid("getViews", "grid").model.getRecord("4551");
apex.region("gridId").widget().interactiveGrid("getViews", "grid").setSelectedRecords([record],true);

JSON_CONTAINS doesn't recognize my column mysql v.8.0.17 laravel 5.6

I have to do a query similar to this:
SomeModel::whereRaw("JSON_CONTAINS(column, '', '$.a')")->get();
column contains JSON *{"a":null}*;
With mysql version 5.7 everything works fine, i get empty collection but on a database on digitalocean which is mysql v8.0.17 i get this error:
Illuminate/Database/QueryException with message 'SQLSTATE[22032]: <>: 3141 Invalid JSON text in argument 1 to function json_contains: "The document is empty." at position 0. (SQL: select * from 'table' where JSON_CONTAINS(column, '', '$.a'))'
I'm stuck on this for days, please help! :)
The problem is empty string that you are passing as argument.
Try:
SomeModel::whereRaw("JSON_CONTAINS(column, null, '$.a')")->get();
The problem is you want to search a json field inside a json column, so you need a json array for that an not just an empty value.
Try something like:
SomeModel::whereRaw("JSON_CONTAINS(`column`, cast('[]' as json), '$.a')")->get();
Also use `` for your column names.
Since you are using laravel 5.7, you could also use the eloquent functions that are shipped with laravel like:
SomeModel::whereJsonContains('your_json_field','your_value')->get();

only show events who are greater than or equal laravel

Im working in a project where I display different events in my view. The goal for now is to only show events that are upcoming, so it doesn't show events that are older than today.
The users of my page can create an event and set a sertain date for it.
The data is stored into my db like this:
$table->string('datum');
In the view it return it like this:
06.03.2019
My controller to return the data looks like this:
$date = date('d.m.Y');
$evententries = Event::where('datum', '>=', $date)->orderBy('datum', 'asc')->take(3)->get();
but it's somehow not working..
Anyone got any Ideas of how to fix this and what my issue is here?
btw, I'm using laravel 5.7.
Thank you :)
Hmm you are doing it on wrong way from begin...
First: why you are using string to store date value? there is much better options to store date within database...
Second: you are using date format which cannot be compared on that way (using < > =)
when you are comparing strings ie 08.03.2019 will be always smaller than 10.01.2016 because 1 > 0... so if you are comparing dates use:
db format for storing dates
for comparing use format yyyy-mm-dd because on that way even simple string comparison will give you correct result...

Resources