Posts

Showing posts with the label Mysql

Multiple DataBase Connections in Laravel

This article is about using databases with different data, not necessary for load balancing (or connection pooling) between databases. Define Connections Inside of your datbase configuration file - likely app/config/database.php - you can define more than one database connection of any type. In fact, you can define as many connections as you'd like. For instance, if your application has to pull data from 2 MySQL databases, you can define them both separately: <?php return array(     'default' => 'mysql',     'connections' => array(         # Our primary database connection         'mysql' => array(             'driver'    => 'mysql',             'host'      => 'host1',             'database'  => 'database1',             'username'  => 'user1',             'password'  => 'pass1'             'charset'   => 'utf

Set Up Master Slave Replication in MySQL

About MySQL replication MySQL replication is a process that allows you to easily maintain multiple copies of MySQL data by having them copied automatically from a master to a slave database. This can help for many reasons including facilitating a backup for the data, a way to analyze it without using the main database, or simply as a means to scale out. This tutorial will cover a very simple example of MySQL replication—one master will send information to a single slave. For the process to work you will need two IP addresses: one of the master server and one of the slave. This tutorial will use the following IP addresses: 12.34.56.789- Master Database 12.23.34.456- Slave Database Setup This article assumes that you have a user with sudo privileges and have MySQL installed. If you do not have MySQL, you can install it with this command: sudo apt-get install mysql-server mysql-client Step One—Configure the Master Database Open up the mysql configuration file on the

Mysql storedprocedure with pagination in laravel 5

You are working on laravel with MySQL database. you had created MySQL stored procedure for get data and you want to call procedure with pagination in laravel 5 then you can not directly make pagination as laravel document.If you are using directly MySQL stored Procedure in your controller, model or repository and you want to give pagination like this way :     $data = DB::select(DB::raw('CALL store("6pm")'))->paginate(5);   This way you found error in your Laravel 5 website. we can't give directly this way pagination because your procedure will get all the data from database. but we can give pagination this way :     $pageNumber = Input::get('pageNumber', 1);      $paginate = 2;             $data =  DB::select(DB::raw('CALL store("6pm")'));          $offSet = ($pageNumber * $paginate) - $paginate;      $itemsForCurrentPage = array_slice($data, $offSet, $paginate, true);      $data = new \Illuminate\Pagination\Le