1. Click on the database (from list of databases on the phpMyAdmin home screen) in which you want to rename table name.
2. You will see a list of tables on click of the database.
3. Select the table and there is a dropdown below the tables with Read more…
PDO stands for PHP Data Objects. PDO is a consistent way to access databases.
Today, mostly websites or desktop based applications store their data in databases. Therefore, PHP has also provided the way to connect with databases.
PHP supports following ways to connect to the database:
1. Mysql Read more…
Problem: In our application, we have created the session token to provide secure access. We were using current system time stamp in our token as one of the key component. But after upgrading MySQL 5.5 to MySQL 5.7, we were getting random results. Most of the Read more…
In Postgresql we can save the default timestamp with now() method:
CREATE TABLE test
id serial NOT NULL,
name character varying(255),
last_modified_time timestamp without time zone DEFAULT now()
This will save the date timestamp in this format:
If we want to use the last_modified_time in code we usually convert Read more…
How to enable or disable autocommit of changes in MySQL using MySQL workbench?
Go to Edit->Preferences->SQL Editor->SQL Execution and check your current settings:
Also commit/rollback can be done with the buttons on SQL tab Read more…
AWS: Upgrading MySQL version
Below are few step to upgrade Mysql version very easily on AWS-RDS:
1. Log on to AWS console.
2. Open AWS RDS from Database section:
3. Click on Instances:
4. Select the Database Instance which you want to upgrade:
5. Right Click on Read more…
While working on two servers, we can take the backup of database on one server using mysqldump command in php.
exec(‘mysqldump –host ‘.$dbhost.’ –user ‘.$dbuser.’ –password=’.$dbpass.” “. $dbname.’ > ‘.$dbname.’.sql’);
After creating dump of database, user can move the dump database file from one server to another Read more…
Scaffolding in CakePHP
Application scaffolding in CakePHP is a technique that allows the developer to define and create a basic application that can create, retrieve, update and delete objects. Basically CRUD (create, Read, Update, Delete) data operations are common in most of the applications.
Scaffolding basically provides temporary structure or Read more…
You can create a dblink to a remote database in postgresql and query both local and remote together. Steps and an example below:
1. Enable dblink in postgresql
CREATE EXTENSION dblink;
2. Create connection with database server
SELECT dblink_connect(‘dbname=abc port=1234 host=abc user=abc password=abc’);
3 Read more…
1. Always define hashCode() and equals() methods in your Persistent classes.
2. Persistent class method’s equals() and hashCode() must access its fields through getter methods. It is a good practice to use accessor methods instead of direct instance variable access.
3. Always Implement Serialization with your entity classes. It Read more…
In Amazon Linux, it is not yet packaged with php5.6. When we install PHP by a standrad command:
$yum install php*
1. It will install PHP version 5.3
Below are the steps to update PHP version from 5.3 to 5.6 in Amazon Linux:
Remove Read more…
In the program of uploading files to a server location, instead of using absolute location for saving file to that path, relative path needs to be used. Program was working correctly for absolute path.
In the maven project with the following directory structure , I created a resources folder in the Read more…
Introduction to DataBase Isolation Levels
Transaction specifies an isolation level that defines the degree to which one transaction must be isolated from resource or data modifications made by other transactions. Isolation Levels are described in terms of side-effects of concurrent access or modification by number of users at a Read more…
Problem: How to insert csv data into mysql table with mysql query in php. What problems usually you face with this and how to resolve them.
Description: I have csv file with thousands of records. I want to insert these records in mysql table with php Read more…
When you do svn update or commit in Eclipse you may face this problem- “working copy xxxxx locked”
Solution: Sometimes the problem can be solved with “project cleanup” or “move the project to some other location without .project and .svn files”. But you may have to solve it Read more…
Heroku throwing ERROR: “The datasource configuration “default” was not found in database.php” with database configuration already present for cakephp app.
In one of our cakephp projects hosted on Heroku we used PostgreSql database. For configuring the database to connect to app code we renamed the database.php.default file Read more…
While fetching data from database, in SQL query I had ‘order by’ clause but the results were not sorted when the data was in alphanumeric form. The reason for this is that SQL sorts character by character from left to right. So it places c10 before c2 as 1< Read more…
Let us take an example:
We have table employees with following fields:
id int primary key,
We have following records in the table:
(1, isha, amr);
(2, Hamlet’s, ghy);
(3, éhjj, amr);
2nd and 3rd records have special characters in their Read more…
We have two tables say table1 and table 2. In table 1, there is a field named Id and this field is set as primary key in table 1. We want to use it as foreign key in table 2.
Fields in both the tables:
Id Read more…
Steps to create a connection to a local postgres database in pgAdmin ||| :
1. Make sure PostgresSql and its components should be installed in ubuntu system.
2. Check what databases are available in postgresSql through terminal
3. Login to PostresSql server in terminal using following command:
sudo -u postgres psql
With Read more…