<!-- $Platon: phpMyEdit/doc/sgml/hints-and-tips.sgml,v 1.2 2004/11/28 22:30:31 nepto Exp $ -->
<chapter id="hints-and-tips">
<title id="hints-and-tips.title">Hints & tips</title>
<sect1 id="hints-and-tips.overview">
<title id="hints-and-tips.overview.title">Overview</title>
<para>
In this chapter you can find several useful tips, hints and other advices on
how to accomplish more or less difficult database tasks using &name; project.
</para>
<para>
&name; is an open-source application developed by open community. This
community is proud of this project and is happy to share its knowledge with
others. Please share with us your knowledge and contribute
interesting examples of &name; usage, if you found some. You can do so by
using our <xref linkend="other-information.bug-tracking-system"
endterm="other-information.bug-tracking-system">.
</para>
</sect1>
<sect1 id="hints-and-tips.national-characters">
<title id="hints-and-tips.national-characters.title">Handling national characters</title>
<para>
&name; is used across the whole world by many users of various nationalities
speaking and writing several different languages. The most common problem
that occured for people located in the east, central or north Europe, Asia
and other countries is, that &name; does not handle their national
language characters correctly.
</para>
<para>
The reason for this is very simple. In order to simplify &name; integration
into larger production systems, the generated code does not contain by default
any HTML header or footer. But even if the HTML header and footer is turned
on, the generated META tags do not contain any entry defining the proper type
of content and character set. It's up to you to send this kind information
with the served page. You can do this using HTTP protocol headers or HTML META
tags.
</para>
<para>
Below are two examples how to define an <constant>iso-8859-2</constant>
character set for the HTML page. This charset is most suitable for countries
in central Europe, such as Slovakia, Czech republic, Poland, and so on.
For your country you will certainly need to determine the appropriate
character set.
<example><title>Charset defined with META tag</title>
<programlisting><![CDATA[
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
]]></programlisting>
</example>
<example><title>Charset defined with HTTP header</title>
<programlisting><![CDATA[
<?php
header('Content-Type: text/html; charset=iso-8859-2');
?>
]]></programlisting>
</example>
</para>
</sect1>
<sect1 id="hints-and-tips.data-removal-protection">
<title id="hints-and-tips.data-removal-protection.title">Data removal protection</title>
<para>
One very old database maintenance rule basically says:
</para>
<para>
<blockquote>
<attribution>unknown author</attribution>
<simpara>No entry should by removed from a database, but just marked as deleted.</simpara>
</blockquote>
</para>
<para>
According to this rule, we may want to implement similar functionality also in
&name; and it is possible, of course.
</para>
<para>
First of all we need to set-up &name; to list only valid non-deleted records.
This can be accomplished using <varname>$opts['filters']</varname>
configuration option. We suppose that we have table where a column named
<varname>deleted</varname> indicates if record is deleted or not.
<example><title>Non-deleted records listing</title>
<programlisting><![CDATA[
$opts['filters'] = 'deleted IS NULL OR deleted = 0';
]]></programlisting>
</example>
</para>
<para>
Than we have to create a "delete before" trigger and we are done. Trigger PHP code
should look similar to this example:
<example><title>Trigger for marking records as deleted</title>
<programlisting><![CDATA[
$query2 = sprintf('UPDATE %s SET deleted = 1 WHERE id = %d',
$this->tb, $newvals['id']);
$this->MyQuery($query2);
return false;
]]></programlisting>
</example>
</para>
<para>
To recover a particular record just change the value in the <varname>deleted</varname>
column from <constant>1</constant> to <constant>0</constant>
using your SQL client or interface (for example using
<application>phpMyAdmin</application>).
</para>
</sect1>
<sect1 id="hints-and-tips.integration">
<title id="hints-and-tips.integration.title">Integration into other systems</title>
<bridgehead id="hint-and-tips.integration.php-nuke">PHP-Nuke integration</bridgehead>
<para>
To integrate &name; into <ulink url="http://www.phpnuke.org/">PHP-Nuke</ulink>
content management system, just add a <varname>name</varname> variable
with a <varname>$module_name</varname> value into a set of &name;
persistent variables.
<example><title>&name; integrated into PHP-Nuke</title>
<programlisting><![CDATA[
$opts['cgi']['persist']['name'] = $module_name;
]]></programlisting>
</example>
</para>
<bridgehead>PostNuke integration</bridgehead>
<para>
Integration into <ulink url="http://www.postnuke.com/">PostNuke</ulink>
content management system is most likely very similar to <xref
endterm="hint-and-tips.integration.php-nuke"
linkend="hint-and-tips.integration.php-nuke">.
</para>
<bridgehead>other systems</bridgehead>
<para>
If you know useful information about how to integrate &name; with a particular
system, please notify project developers.
</para>
</sect1>
</chapter>
Platon Group <platon@platon.sk> http://platon.sk/
|