The software that I write is not intended for just one customer who is locked into a single RDBMS. Instead it can be used by virtually any customer using the RDBMS of their choice. How is this possible? I deliberately designed and built my infrastructure around the 3 Tier Architecture which breaks down application code into three distinct areas of responsibility:
1. Presentation logic = User Interface, displaying data to the user, accepting input from the user.
2. Business logic = Business Rules, handles data validation and task-specific behaviour.
3. Data Access logic = Database Communication, constructing SQL queries and executing them via the relevant API.
It is only the Data Access layer which communicates with the database, therefore it should be possible to communicate with another database simply by changing the component which exists within this layer. I have already produced two versions of my Data Access Object for MySQL:
One for versions up to 4.0 which uses the original mysql_* functions.
Another for version 4.1 and above which uses the 'improved' mysqli_* functions.
The purpose of this article is to document my experiences while producing a DAO for a totally different RDBMS, in this case for PostgreSQL (version 8.0.3).
[source]
Showing posts with label Mysql. Show all posts
Showing posts with label Mysql. Show all posts
Understand, Why Stored Procedures are Evil!!!!!
A lot of developers are taught to use database stored procedures, triggers and database constraints at every possible opportunity, and they cannot understand why an old dinosaur like me should choose to take an opposite view.
The reason can be summed up quite simply:
You only know what you have been taught, whereas I know what I have learned.
I was weaned on file systems and databases which did not have any facilities for stored procedures and triggers, so I learned how to build applications without them. When such facilities became available my colleagues and I still never used them for practical reasons:
Continue Reading the tutorial
The reason can be summed up quite simply:
You only know what you have been taught, whereas I know what I have learned.
I was weaned on file systems and databases which did not have any facilities for stored procedures and triggers, so I learned how to build applications without them. When such facilities became available my colleagues and I still never used them for practical reasons:
Continue Reading the tutorial
How to Handle MySQL Data Handling Through PHP!!!!!
Most interactive websites nowadays require data to be presented dynamically and interactively based on input from the user. For example, a customer may need to log into a retail website to check his purchasing history. In this instance, the website would have stored two types of data in order for the customer to perform the check – the customer’s personal login details; and the customer’s purchased items. This data can be stored in two types of storage – flat files or databases
Flat files are only feasible in very low to low volume websites as flat files have 3 inherent weaknesses:
1. The inability to index the data. This makes it necessary to potentially read ALL the data sequentially. This is a major problem if there are a lot of records in the flat file because the time required to read the flat file is proportionate to the number of records in the flat file.
2. The inability to efficiently control access by users to the data
3. The inefficient storage of the data. In most cases, the data would not be encrypted or compressed as this would exacerbate the problem no. 1 above
Continue Reading The Tutorial
Flat files are only feasible in very low to low volume websites as flat files have 3 inherent weaknesses:
1. The inability to index the data. This makes it necessary to potentially read ALL the data sequentially. This is a major problem if there are a lot of records in the flat file because the time required to read the flat file is proportionate to the number of records in the flat file.
2. The inability to efficiently control access by users to the data
3. The inefficient storage of the data. In most cases, the data would not be encrypted or compressed as this would exacerbate the problem no. 1 above
Continue Reading The Tutorial
How to Install MySQL on Windows!!!!!
As Web sites and Web-based applications become more important to commercial firms and other organizations, so too does the methods used for storing data online, such as customer contact information, system login details, product data, and much more. Rewritable flat files may be sufficient for extremely limited data for which security is not an issue. But for most Web sites and applications, a robust database is called for.
There are several relational database management systems (RDBMSs) from which you the developer can choose, ranging from expensive systems that can prove quite difficult to administer, to free and open source alternatives that may not have as many features as the proprietary RDBMSs, but can be much faster to set up and work with. Of these, MySQL is the hands-down favorite.
Continue Reading The Tutorial
There are several relational database management systems (RDBMSs) from which you the developer can choose, ranging from expensive systems that can prove quite difficult to administer, to free and open source alternatives that may not have as many features as the proprietary RDBMSs, but can be much faster to set up and work with. Of these, MySQL is the hands-down favorite.
Continue Reading The Tutorial
MySQL Database Backup and Recovery Tips!!!!
Tip #1
Making Backups by Copying Files
Tip #2
To make an SQL-level backup of a table's contents, you can use SELECT * INTO OUTFILE 'file_name' FROM tbl_name. The file is created on the MySQL server host, not the client host. For this statement, the output file cannot already exist because allowing files to be overwritten would constitute a security risk
Tip #3
Another technique for backing up a database is to use the mysqldump program or the mysqlhotcopy script. mysqldump is more general because it can back up all kinds of files. mysqlhotcopy works only with some storage engines.
Tip #4
Backing Up Replication Slaves
These are some of the simple ways how we can take backup from MySQL database.
Continue Reading the Tutorial Here
Making Backups by Copying Files
Tip #2
To make an SQL-level backup of a table's contents, you can use SELECT * INTO OUTFILE 'file_name' FROM tbl_name. The file is created on the MySQL server host, not the client host. For this statement, the output file cannot already exist because allowing files to be overwritten would constitute a security risk
Tip #3
Another technique for backing up a database is to use the mysqldump program or the mysqlhotcopy script. mysqldump is more general because it can back up all kinds of files. mysqlhotcopy works only with some storage engines.
Tip #4
Backing Up Replication Slaves
These are some of the simple ways how we can take backup from MySQL database.
Continue Reading the Tutorial Here
How to use Scriptaculous Effects in a better way?

How to use Scriptaculous Effects in a better way?
Here is a simple snapshot from the demo page from 24ways.
Gather around kids, because this year, much like in that James Bond movie with Denise Richards, Christmas is coming early… in the shape of scrumptuous smooth javascript driven effects at your every whim.
Now what I’m going to do, is take things down a notch. Which is to say, you don’t need to know much beyond how to open a text file and edit it to follow this article. Personally, I for instance can’t code to save my life.
Well, strictly speaking, that’s not entirely true. If my life was on the line, and the code needed was really simple and I wasn’t under any time constraints, then yeah maybe I could hack my way out of it But my point is this: I’m not a programmer in the traditional sense of the word. In fact, what I do best, is scrounge code off of other people, take it apart and then put it back together with duct tape, chewing gum and dumb blind luck.
No, don’t run! That happens to be a good thing in this case. You see, we’re going to be implementing some really snazzy effects (which are considerably more relevant than most people are willing to admit) on your site, and we’re going to do it with the aid of Thomas Fuchs’ amazing Script.aculo.us library. And it will be like stealing candy from a child.
Check out the code and Demo on this page Here
If you like this tutorial, drop in comments.
How to get last inserted record ID in mysql?
How to get last inserted record ID in mysql?
mysql_insert_id function is used to "Get the ID generated from the previous INSERT operation"
How to use the function?
Example code:
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');
mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
?>
mysql_insert_id function is used to "Get the ID generated from the previous INSERT operation"
How to use the function?
Example code:
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');
mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
?>
Subscribe to:
Posts (Atom)