Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, October 14, 2026

Diff for phpMyEdit/doc/sgml/configuration.fields.sgml between version 1.31 and 1.32

version 1.31, 2003/08/16 01:41:26 version 1.32, 2003/12/08 09:17:30
Line 1 
Line 1 
 <!-- $Platon: phpMyEdit/doc/sgml/configuration.fields.sgml,v 1.30 2003/07/29 19:50:43 nepto Exp $ -->  <!-- $Platon: phpMyEdit/doc/sgml/configuration.fields.sgml,v 1.31 2003/08/16 01:41:26 nepto Exp $ -->
   
 <!-- Categories:  <!-- Categories:
   
Line 240  More information about CSS handling can
Line 240  More information about CSS handling can
 linkend="configuration.css" endterm="configuration.css.title"> section.  linkend="configuration.css" endterm="configuration.css.title"> section.
   
 </para>  </para>
 <bridgehead id="configuration.fields.sql">SQL expression</bridgehead>  
 <para>  
   
 There is a possibility to define a SQL expression that should be applied to  
 particular field when selecting data from database. This is very useful when  
 you want to interpret the field's content in different way than it is stored  
 in database. To be more clear, see following examples.  
   
 <example><title>SQL expressions</title>  
 <programlisting><![CDATA[  
 $opts['fdd']['surname']['sql'] = 'CONCAT(surname, ', ', firstname)';  
 $opts['fdd']['title']['sql'] = 'IF(TRIM(title) != "", title, title2)';  
 ]]></programlisting>  
 </example>  
   
 </para>  
 <para>  
   
 First example appends content of <varname>firstname</> field to  
 <varname>surname</> field. Because this is done on the database level, sorting  
 and searching (in table filtering page) on this field will properly work.  
 Similarly in the second example, the <varname>title2</> field will be used if  
 <varname>title</> field is empty. In this manner you can define some special  
 static string, which should be printed in case a field is empty. Just  
 substitute a quoted string in place of <varname>title2</>.  
   
 </para>  
 </sect1>  </sect1>
   
 <sect1 id="configuration.booleans">  <sect1 id="configuration.booleans">
Line 760  preceding "http://".
Line 733  preceding "http://".
   
 </para>  </para>
 </sect1>  </sect1>
   <sect1 id="configuration.fields.sql">
   <title id="configuration.fields.sql.title">SQL expressions</title>
   <para>
   
   There is a possibility to define a SQL expression that should be applied to
   particular field when reading or writting data from database. This is very
   useful when you want to interpret the field's content in different way than it
   is stored in database. To be more clear, see following examples.
   
   <example><title>Read SQL expressions</title>
   <programlisting><![CDATA[
   $opts['fdd']['surname']['sql'] = 'CONCAT(surname, ', ', firstname)';
   $opts['fdd']['title']['sql'] = 'IF(TRIM(title) != "", title, title2)';
   ]]></programlisting>
   </example>
   
   </para>
   <para>
   
   First example appends content of <varname>firstname</> field to
   <varname>surname</> field. Because this is done on the database level, sorting
   and searching (in table filtering page) on this field will properly work.
   Similarly in the second example, the <varname>title2</> field will be used if
   <varname>title</> field is empty. In this manner you can define some special
   static string, which should be printed in case a field is empty. Just
   substitute a quoted string in place of <varname>title2</>.
   
   </para>
   <para>
   
   Similarly, you can use SQL expression for storing data into database.
   
   <example><title>Write SQL expressions</title>
   <programlisting><![CDATA[
   $opts['fdd']['surname']['sqlw'] = 'UPPER($val_qas)';
   $opts['fdd']['title']['sqlw'] = 'TRIM("$val_as")';
   ]]></programlisting>
   </example>
   
   </para>
   <para>
   
   As a placeholder for the field's content, there are three variables available.
   
   <simplelist type="horiz" columns="2">
   <member> &nbsp; <varname>$val</varname></member>
   <member> -- value of the field</member>
   <member> &nbsp; <varname>$val_as</varname></member>
   <member> -- value with applied <function>addslashes()</function> function</member>
   <member> &nbsp; <varname>$val_qas</varname></member>
   <member> -- same as <varname>$val_as</varname> with quotes around</member>
   </simplelist>
   
   </para>
   <para>
   
   So if the <varname>$val</varname> is <constant>some"nice"thing</constant>,
   than <varname>$val_as</varname> becomes <constant>some\"nice\"thing</constant>
   and <varname>$val_qas</varname> becomes
   <constant>"some\"nice\"thing"</constant>. You have to use these variables
   correctly in your <varname>['sqlw']</varname> expressions, otherwise MySQL
   parsing error could be occured.
   
   </para>
   </sect1>
 <sect1 id="configuration.tabs-feature">  <sect1 id="configuration.tabs-feature">
 <title id="configuration.tabs-feature.title">TABs feature</title>  <title id="configuration.tabs-feature.title">TABs feature</title>
 <para>  <para>

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top