LoganK wrote:1. What is a "database abstraction layer"?
- What can it do for me?
- What are the advantages of it?
- Do I have to write it myself?
What is the purpose of "Smarty"?
..... is Smarty a second/alternative method of presenting data?
..... Does it give me any advantages?
How does caching work in PHP? How can I implement it?
1. Data Abstraction Layer.
Say you have a forum application scipt in PHP. Run by php.exe.
And you have an External database program: Oracle.bin
You can write your php forum to use Oracle Database data.
But if you want to share your forum application script with others.
They might use one of like 10 different database programs.
That is about how many it is out there. Which are worth to mention.
Postgree, mssql, msaccess or whatever their names.
( Iuse only php own capability to store data by creating files.
See: [man]fopen[/man] - [man]fwrite[/man] - [man]fread[/man] - [man]fclose[/man]
This is also called flat file - or flat text file database technique.
So for me is NOT THIS PROBLEM, with adjusting to exrternal programs.
My code will work, as is, for anyone with ONLY PHP)
Now you can save all functions that 'talks directly' with that database,
and have one such set of functions for each database users want to add-on.
But in your forum script these functions have same names:
create_table( $table_name )
add_record( $data_row )
delete_record( $id )
find_record( $column_name, $value );
Now in config.php settings, admin selects a database or database type he wants to use.
And php reads settings, and get that set of functions beloninging to that specific database.
And NO CHANGES in your forum scipt is needed to run different databases
along with your forum.
I have more than 100 different PHP Scripts: Forums, CMS, Blogs, Guestbooks
and whatver application,
that I have downloaded, have had a look at and stored in my PC. For FREE.
From this my collection of php scripts,
here is a bit of code from such a db-layer (database layer)
<?php
/*****
This is a part of 'common.php'
which can be included by any php page like 'index.php'
*****/
// get settings for this forum
include 'config.php';
// get the specific dB layer set of functions
// that should be used from: '$dbtype'. '.php'
if(!file_exists($config['path']."core/database/".$config['dbtype'].".php"))
{
// if no valid DB tell user that no valid DB type was found
require_once($config['path']."core/includes/nodb.php");
}
require_once($config['path']."core/database/".$config['dbtype'].".php");
$dbconn =& new database($config['dbhost'], $config['dbname'], $config['prefix'],
$config['dbuser'], $config['dbpass'], $config['persistent']);
// Lets connect to our database
if(!$dbconn->connect())
{
// Was unable to connect to specified DB
require_once($config['path']."core/includes/nodb.php");
}
?>
-----
2. Smarty template engine add-on class
3. Caching in PHP
-----
I am sure I could write an easy enough to understand explaination
to those 2 issue also.
But I am not alone here, to answer questions and to educate people,
who want to increase their knowledge in how to get independent from software dealers,
and write their own scripts using fairly simple programming language of PHP.
I leve it up to my partners here at http://www.phpbuilder.com
to try to give you food for your hunger in knowing more.
To LoganK
from your php friend
/halojoy
🙂
knowledge is an easy burdon, compared to other hardships we have to carry in life