Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel database connection check

use IlluminateSupportFacadesDB;

// Test database connection
try {
    DB::connection()->getPdo();
} catch (Exception $e) {
    die("Could not connect to the database.  Please check your configuration. error:" . $e );
}
Comment

laravel get db connection info

if(DB::connection()->getDatabaseName())
   {
     echo "conncted sucessfully to database ".DB::connection()->getDatabaseName();
   }
Comment

check which database connect laravel

DB::connection();
Comment

connect database to laravel

1) go to http://localhost/phpmyadmin .
2) create a new table called job for example 
3) go to .env file in your laravel project then change these lignes:
DB_CONNECTION=mysql  
DB_HOST=127.0.0.1. 
DB_PORT=3306    
DB_DATABASE=name_of_database // => name should be exact as the table name you created .. in our example its job 
DB_USERNAME=root         
DB_PASSWORD=choose_your_password         

Comment

PREVIOUS NEXT
Code Example
Php :: php in html attributes 
Php :: delete all cookies in php 
Php :: laravel validator make custom message 
Php :: laravel query select from table where id != to another table id 
Php :: php error reporting 
Php :: remove notices php 
Php :: remove foreign key constraint laravel 
Php :: codeigniter table list 
Php :: set timezone in php 
Php :: how send user to 404 page if not exist page in laravel 
Php :: load database in codeigniter 
Php :: php define object 
Php :: wp get tagline php 
Php :: twig is in string 
Php :: php isset post 
Php :: PHP money_format — Formats a number as a currency string 
Php :: round up built in function php 
Php :: how to get yesterday date in laravel 
Php :: turn off deprecated warnings php 
Php :: php convert string to int in array 
Php :: laravel get items by ids 
Php :: PHP scandir() Function 
Php :: how to prompt user for input in php 
Php :: php typecast to int 
Php :: show alert in php 
Php :: File Reading Mode PHP 
Php :: types of controller in laravel 
Php :: php get url parameter 
Php :: php catch all exceptions 
Php :: wpdb num_rows 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =