http://www.webupd8.org/2010/09/make-ubuntu-look-like-mac-osx-in.html
apache , php , mysql , phpmyadmin on ubuntu
http://ubuntuexperiment.wordpress.com/2008/11/10/installing-apache-php-mysql/
--------------------------------------
Headers Already Sent Error:
(ob_start, ob_end_clean, ob_end_flush)
--------------------------------------
First of all you need to uninstall the vShare toolbar:
Open Firefox.
Click Tools in the upper-left side on the Firefox bar.
Click Add-ons.
Click the vShare icon and delete uninstall it.
Restart Firefox.
To fix the search redirect issue, follow these steps:
Open Firefox.
In the address field, type about:config.
You will be prompted to be careful. Just confirm it by clicking the “I’ll be careful, I promise!” button.
In the filter field, type keyword.URL and press Enter.
Double click the value and change the default web address (which causes all those annoying redirects) to:
http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=
If you use Internet Explorer, all you’ll have to do is uninstall the vShare Toobar:
Open Internet Explorer.
Click Tools – Manage Add-ons.
Remove the toolbar from the list of installed add-ons.
Download and run Combofix to eliminate further vShare leftovers and fix redirect issues.
------------------------------------------------------
The MVC Pattern
Figure 2-1 illustrates the MVC pattern.
The MVC architecture separates the business logic (model) and the presentation (view), resulting in greater maintainability. For instance, if your application should run on both standard web browsers and handheld devices, you just need a new view; you can keep the original controller and model. The controller helps to hide the detail of the protocol used for the request (HTTP, console mode, mail, and so on) from the model and the view. And the model abstracts the logic of the data, which makes the view and the action independent of, for instance, the type of database used by the application.
Figure 2-1 - The MVC pattern
MVC Layering
To help you understand MVC's advantages, let's see how to convert a basic PHP application to an MVC-architectured application. A list of posts for a weblog application will be a perfect example.Flat Programming
In a flat PHP file, displaying a list of database entries might look like the script presented in Listing 2-1.
Listing 2-1 - A Flat Script
// Connecting, selecting database
$link = mysql_connect('localhost', 'myuser', 'mypassword');
mysql_select_db('blog_db', $link);
// Performing SQL query
$result = mysql_query('SELECT date, title FROM post', $link);
?>
List of Posts
List of Posts
// Printing results in HTML
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "\t\n";
printf("\t\t\n", $row['date']);
printf("\t\t\n", $row['title']);
echo"\t\n";
}?>
Date Title
%s %s
// Closing connection
mysql_close($link);
?>
That's quick to write, fast to execute, and impossible to maintain. The following are the major problems with this code:- There is no error-checking (what if the connection to the database fails?).
- HTML and PHP code are mixed, even interwoven together.
- The code is tied to a MySQL database.
Isolating the Presentation
Theecho
and printf
calls in Listing 2-1 make the code difficult to read. Modifying the HTML code to enhance the presentation is a hassle with the current syntax. So the code can be split into two parts. First, the pure PHP code with all the business logic goes in a controller script, as shown in Listing 2-2.
Listing 2-2 - The Controller Part, in
index.php
The HTML code, containing template-like PHP syntax, is stored in a view script, as shown in Listing 2-3.
Listing 2-3 - The View Part, in
view.php
List of Posts
foreach ($posts as $post): ?> endforeach; ?>Date | Title |
---|---|
echo $post['date'] ?> | echo $post['title'] ?> |
A good rule of thumb to determine whether the view is clean enough is that it should contain only a minimum amount of PHP code, in order to be understood by an HTML designer without PHP knowledge. The most common statements in views are echo, if/endif, foreach/endforeach, and that's about all. Also, there should not be PHP code echoing HTML tags.
All the logic is moved to the controller script, and contains only pure PHP code, with no HTML inside. As a matter of fact, you should imagine that the same controller could be reused for a totally different presentation, perhaps in a PDF file or an XML structure.
Isolating the Data Manipulation
Most of the controller script code is dedicated to data manipulation. But what if you need the list of posts for another controller, say one that would output an RSS feed of the weblog posts? What if you want to keep all the database queries in one place, to avoid code duplication? What if you decide to change the data model so that thepost
table gets renamed weblog_post
? What if you want to switch to PostgreSQL instead of MySQL? In order to make all that possible, you need to remove the data-manipulation code from the controller and put it in another script, called the model, as shown in Listing 2-4.
Listing 2-4 - The Model Part, in
model.php
The revised controller is presented in Listing 2-5.
Listing 2-5 - The Controller Part, Revised, in
index.php
The controller becomes easier to read. Its sole task is to get the data from the model and pass it to the view. In more complex applications, the controller also deals with the request, the user session, the authentication, and so on. The use of explicit names for the functions of the model even makes code comments unnecessary in the controller.
The model script is dedicated to data access and can be organized accordingly. All parameters that don't depend on the data layer (like request parameters) must be given by the controller and not accessed directly by the model. The model functions can be easily reused in another controller.
Layer Separation Beyond MVC
So the principle of the MVC architecture is to separate the code into three layers, according to its nature. Data logic code is placed within the model, presentation code within the view, and application logic within the controller.Other additional design patterns can make the coding experience even easier. The model, view, and controller layers can be further subdivided.
Database Abstraction
The model layer can be split into a data access layer and a database abstraction layer. That way, data access functions will not use database-dependent query statements, but call some other functions that will do the queries themselves. If you change your database system later, only the database abstraction layer will need updating.A sample database abstraction layer is presented in Listing 2-6, followed by an example of a MySQL-specific data access layer in Listing 2-7.
Listing 2-6 - The Database Abstraction Part of the Model
Listing 2-7 - The Data Access Part of the Model
You can check that no database-engine dependent functions can be found in the data access layer, making it database-independent. Additionally, the functions created in the database abstraction layer can be reused for many other model functions that need access to the database.
The examples in Listings 2-6 and 2-7 are still not very satisfactory, and there is some work left to do to have a full database abstraction (abstracting the SQL code through a database-independent query builder, moving all functions into a class, and so on). But the purpose of this book is not to show you how to write all that code by hand, and you will see in Chapter 8 that symfony natively does all the abstraction very well.
View Elements
The view layer can also benefit from some code separation. A web page often contains consistent elements throughout an application: the page headers, the graphical layout, the footer, and the global navigation. Only the inner part of the page changes. That's why the view is separated into a layout and a template. The layout is usually global to the application, or to a group of pages. The template only puts in shape the variables made available by the controller. Some logic is needed to make these components work together, and this view logic layer will keep the name view. According to these principles, the view part of Listing 2-3 can be separated into three parts, as shown in Listings 2-8, 2-9, and 2-10.
Listing 2-8 - The Template Part of the View, in
mytemplate.php
List of Posts
foreach ($posts as $post): ?> endforeach; ?>Date | Title |
---|---|
echo $post['date'] ?> | echo $post['title'] ?> |
Listing 2-9 - The View Logic Part of the View
$title = 'List of Posts'; $posts = getAllPosts();
Listing 2-10 - The Layout Part of the View
-------------------------------------------
What's algorithm? What's OS(operating system)? How do i format my computer?, What's new in MAC OS?, How about MAC OS?, What's MAC OS?, computer network?, what's network?, how to manage my network? what's internet marketing, Iphone, android mobile programming lesson
-------------------------------------------
public function setValue($field, $value){
if(!in_array($field, array_keys($this->values))){
throw new sfException(sprintf('Unkown field" "%s" in "%s" object.', $field, get_class($this))); }
$this->values[$field] = $value; }
-------------------------------------------
dsn: mssql:host=ADMIN-PC;dbname=mssqldb
username: sa
password: password
xampp 1.6.8
replace ntwdblib.dll in php/
enable php_pdo_mssql.dll in both php.ini
apache restart
-----------------
backup
mysqldump -u root -ptecmint --all-databases > alldb_backup.sql
restore
mysql -u root -p < alldb_backup.sql