Archive

Archive for the ‘php’ Category

Easier And Better Mysql/Sqlite in PHP

September 3rd, 2009

Update: fixed Mysql Class

Most websites that use php mostly use MySql, People use it because it’s dynamic, fast(in most cases) and popular.
But most of you don’t know that there’s also something called “Sqlite” it’s also an Sql database, but it stores the database in a file.

Problem

There are two main problems with using mysql and sqlite these days:

  1. To switch between mysql and sqlite you have to go and replace mysql_query with sqlite_query in every file that uses mysql.
  2. If your’e obfuscating your code then you can’t obfuscate functions.
  3. If you want to process some code or an sql query before each time a mysql or an sqlite function is run like counting the number of queries in a page, and a lot of other uses.

There are a lot of inconvenience when using mysql or sqlite functions, everyone with their own problems, and this should help you solve most of them.
Read more…

admin mysql, php, sqlite , ,

Easy templating in PHP

August 8th, 2009

Even though the subject of “Using templates in php” is everywhere, it still didn’t reach it’s true potential.

Most people who are new to php(not sure about more advanced php developers) use methods like this to put templates in their website:

1
2
3
< ?php
include 'header.txt'; // A simple include
?>

As you can see it’s not very sophisticated, and you can use it only with normal HTML files.

People who are more advanced use this:

1
2
3
< ?php
include 'header.php';
?>

It’s almost the same as the first one, only that you can also put in there PHP code.

The problem with all of those is that as more parts in your template you have the more files your’e going to need.

So if you have three parts like:
head
menu
footer

Then your’e going to need three files:
head.php
menu.php
footer.php

And the more parts the more the files to maintain, So if you’ll need to change one of those file’s name on a 100 paged website your’e doomed.

So what I came up with about one year after I learned php is using one file for all your templating needs.
Read more…

admin php ,