Database
How to calculate age (in years) based on Date of Birth and getDate()
There are issues with leap year/days and the following method, see the update below: try this: OUTPUT: UPDATE here are some more accurate methods: BEST METHOD FOR YEARS IN INT you can change the above 10000 to 10000.0 and get decimals, but it will not be as accurate as the method below. BEST METHOD FOR … Read more
How to do a batch insert in MySQL
From the MySQL manual INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of column values, each enclosed within parentheses and separated by commas. Example:
Equivalent of explode() to work with strings in MySQL
MYSQL has no explode() like function built in. But you can easily add similar function to your DB and then use it from php queries. That function will look like: Usage: The example above will return apple. I think that it will be impossible to return array in MySQL so you must specify which occurrence … Read more
DATEDIFF function in Oracle
In Oracle, you can simply subtract two dates and get the difference in days. Also note that unlike SQL Server or MySQL, in Oracle you cannot perform a select statement without a from clause. One way around this is to use the builtin dummy table, dual:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
9 I download from https://github.com/luciddreamz/laravel Laravel for openshift then upload over my repository over github. This code for connect to database not work. The problem is that load variable from .env file that locate in root of project for solve this problem change.env my error :
Create boolean column in MySQL with false as default value?
I want to create a table in MySQL with a boolean column whose default value is false. But it’s accepting NULL as default…
Can you do a For Each Row loop using MySQL?
The closest thing to “for each” is probably MySQL Procedure using Cursor and LOOP.
Oracle: If Table Exists
The best and most efficient way is to catch the “table not found” exception: this avoids the overhead of checking if the table exists twice; and doesn’t suffer from the problem that if the DROP fails for some other reason (that might be important) the exception is still raised to the caller: ADDENDUM For reference, … Read more
Cannot create an instance of OLE DB provider Microsoft.Jet.OLEDB.4.0 for linked server null
I have MS Sql server 2012, and Office 2013. This seems to be very finicky, so you may have to adjust to your particular versions. Download the Microsoft.ACE.OLEDB.12.0 for Windows, 64 bit version found here: https://www.microsoft.com/en-us/download/details.aspx?id=13255 Install it on your server. Check the user running SQL Server and make sure that user has access to the … Read more