Dataface is an Open Source application for developers, which is used for
creating frontend in PHP for MySQL in minutes with all those functionalities. It
automatically generates a webpage with appropriates forms, lists and menus,
which helps users to interact with the database without having to remember any
SQL command.
You can configure its features and behavior by modifying its configuration
file. If in future you have the requirement to modify the database, for eg,
adding one more column to it, you don't have to care about the frontend part.
This is because the page associated to it will automatically get updated as they
are dynamically generated using the database schema. This will reduce the effort
of maintaining the website. Let's see how you can make data driven applications
using Dataface.
Direct Hit! |
Applies To: Developers |
Setup
Before starting you need to have PHP 4.3 and MySQL 3.2.3 or higher version
installed on your Linux system. If you do not have these packages installed on
the system, then you can simply download XAMPP package and install it. Download
'dataface-0.7.1.tar' file from the Dataface website, unpack this file and place
it in Web server root directory. Make the 'templates_c' directory writable by
the Web server which you will find inside Dataface directory. You can do so by
the following command:
# chmod 777 Dataface/templates_c
Now, check if the installation is successfully done. You can do it by simply
writing the following path on your Web browser:
http://your-web-server-ipaddress/path-of-dataface-directory/dataface_info.php
If it is successfully installed on the system, then you will see installation
status as 'INSTALLED CORRECTLY.' It also provides you with some additional
information. It shows you the path to template directory and the path to
template compile directory.
Use myPHPAdim to create a sample database for testing purpose |
Whenever a table is created in myPHPAdim, it also creates the SQL codes simultaneously |
Creating database
Before starting with the frontend part, let's make a simple test database.
Create database using PHPMyAdmin and type the desired table name in the 'Create
new database field.' For eg, we gave the name of the database as 'test_database.'
Now click on Create. Click on Structure button and provide a suitable name for
your table ( say, 'test_table'), give the number of columns and click on Go.
Now, specify the field names, the field types and size, etc and finally click on
Save. This will create a code which you can see after clicking on Save. After we
have created the database and the table that will be required, we will move on
to the next part that is the frontend design or the face.
|
|
Select the records-to-change from left side pane and then to replace value of particular field use 'Add Field to update' |
Apart from the row view of data, it also provides a detailed view of a query result to the users |
Creating the frontend
For this, make up a directory for example 'mysite' inside your Web server
directory . This you can do by issuing the following command:
# mkdir mysite
After you make the directory, make a PHP file named 'index.php', and place
the following content into it:
require_once '/path/to/dataface/dataface-public-api.php';
df_init(__FILE__, 'http://yourdo
main.com/dataface');
$app =& Dataface_Application::getInstance();
$app->display();
?>
Here the first line is for importing all the public functions from the 'dataface-public-api.php',
while the next line initializes the application for the current directory and
specifies the URL of the dataface installation. The third one is used to obtain
an instance of the application object.
After this make another file named 'conf.ini', which will contain the datab
ase connection information and the table name that will be used. Write the
following set of lines to this newly created file:>
<_database>
host = "localhost"
user = "rootr"
password = ""
name = "test_database"
<_tables>
Table = "table”
Now your website is ready, browse the index.php through your browser. The
conf.ini contains the user-id and password which need to be restricted from
other users. So, add '.htaccess' file so that the Apache Web server should not
save this file on the server.
Deny from all
And finally you have a website that is fully secure and up. Apart from
inserting, deleting and modifying data you can also search for a specified
data. You can also export the data in CVS format which you can use at other
places.