Page 241 - Open Soource Technologies 304.indd
P. 241
Unit 10: Database
if (!$con) Notes
{
die(‘Could not connect: ‘ . mysql_error());
}
// some code
mysql_close($con);
?>
If you use a database-specific extension, your code is intimately tied to that
database.
Self Assessment
Multiple choice questions:
1. get_user_record( ) function is use to
(a) Insert a record (b) Delete a record
(c) Search a record (d) None of these
2. phpinfo( ) function is use for
(a) Check the functionality
(b) Check for database support in your installation of PHP
(c) Check the connectivity
(d) None of these
3. …………………. allows you to define your database connections for your site.
(a) Databases panel (b) Database security
(c) Database channel (d) None of these
10.2 Relational Databases and SQL
One of the most powerful tool computer gives us is the ability to store and search data. Early
applications stored data for programs in files and used indexes to search the files for particular
bits of data. These programs did not fare very well on networks because there are problems
with more than one computer trying to update data in a file simultaneously. This fact and
the lack of standard database structure and command, syntax encouraged the creation of the
networked relational database.
When you write a program and want to be able to manipulate and search data you often have
to construct the data files and the code to perform the manipulation and searches. This is a time
consuming task and if you are developing many different applications you have to reinvent the
data handling routines for every job. By removing the database functions such as file management,
indexing, searches and simultaneous data access, you speed up development of applications
and allow for these specialized database programs to become highly optimized and scalable.
10.2.1 How it works?
A relational database can be seen as the data handling part of another application. The application
instructs the database to perform searches, as well as add, delete and modify data via the
Structured Query Language or SQL. The SQL standard is supported by all major database
LOVELY PROFESSIONAL UNIVERSITY 235