Difference between revisions of "Tricks and tips"

Jump to: navigation, search
 
(Permit php function call)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
=SQL=
 
=SQL=
 
==Permut two rows according to their id==
 
==Permut two rows according to their id==
  UPDATE some_table SET id = a + ABS(id - b) WHERE order_num in (a , b)
+
Goal: permut two rows with id=a and id=b using only one query
 +
  <sql>UPDATE some_table SET id = a + ABS(id - b) WHERE order_num in (a , b)</sql>
 +
=XSLT=
 +
==Permit php function call==
 +
<xml>
 +
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 +
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
 +
  version="1.0"
 +
  xmlns:php="http://php.net/xsl"
 +
  exclude-result-prefixes="xhtml php">
 +
</xml>
 +
Do not forget '''exclude-result-prefixes="php"''' otherwise you will have xmlns:php attribute in your root tag!
 +
then:
 +
<xml><xsl:value-of select="php:functionString('phpFunctionName', //something/forexample)"/></xml>

Latest revision as of 17:17, 4 April 2007

SQL

Permut two rows according to their id

Goal: permut two rows with id=a and id=b using only one query

UPDATE some_table SET id = a + ABS(id - b) WHERE order_num in (a , b)

XSLT

Permit php function call

 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  version="1.0" 
  xmlns:php="http://php.net/xsl"
  exclude-result-prefixes="xhtml php">
 
Do not forget exclude-result-prefixes="php" otherwise you will have xmlns:php attribute in your root tag!

then:

<xsl:value-of select="php:functionString('phpFunctionName', //something/forexample)"/>