Sunday, May 29 2016

Export XLS file using Pear with PDO

We had published article about Pear library. Why we are using pear library because in export option they gave simple and flexible with ease of code implementation. In also their documentation clear to understand. Here we gave sample of how to Export XLS file using Pear with PDO and to export the users information as excel file with PDO OOPs .  Once you do with our sample code and if you are got idea you can customize code as your wish. 

 

export_excel_pdo

Read More

Thursday, May 05 2016

Create Multiple Database Connection in Codeigniter

In this post we have explained about how to create multiple database connection in codeigniter. Please do the following changes in your files.

Config.php:

Change the below following things in your config.php

$active_group = 'default';
$active_record = TRUE;

Read More

Monday, April 25 2016

How to Prevent SQL Injection in PHP

We had published after long time back article about SQL injection. First of all explain what is sql injection.To avoid the unwanted peoples are access your database without your knowledge i.e hacking.When the system (website) to ask the input from users in that time we won’t directly pass the input to the database we must validate the inputs.

Following things are to prevent the user input :

If you got the input from users, you have to validate using regular expressions for example.

Read More

Friday, April 22 2016

Custom order by query by field name in mysql

In MySql select query we can customize the order of display the result as our wish. The following query I hope it will give some clear ideas do more thoughts in your future queries.

For example:

SELECT * FROM users_ranking 
ORDER BY field(rank_position,'1','2','3','6','4','5'),email ASC

 

 

Friday, April 22 2016

SQL Insert into Select Query Example

Guys you are trying to insert data from one of your existing table to another existing table or same table in mysql you can use SQL Insert into Select Query. The following query will explain

INSERT INTO users (user_id,username,email,password)
SELECT user_id,username,email,password FROM users;

You can add where clause too,

INSERT INTO users (user_id,username,email,password)
SELECT user_id,username,email,password FROM users
Where user_id <= 5;