-
-
Save chrif/1785543 to your computer and use it in GitHub Desktop.
Revisions
-
chrif revised this gist
Jun 7, 2012 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,8 +9,5 @@ function xpathEscape($query, $default_delim = '"') $delim = $apos[$i] ? '"' : "'"; $part = $delim . $part . $delim; } return 'concat("",' . implode(',', $parts) . ')'; } -
chrif revised this gist
Jun 6, 2012 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,5 +9,8 @@ function xpathEscape($query, $default_delim = '"') $delim = $apos[$i] ? '"' : "'"; $part = $delim . $part . $delim; } // concat() must have two or more parts if (count($parts) == 1) $parts[] = $delim . $delim; return 'concat(' . implode(',', $parts) . ')'; } -
chrif revised this gist
Feb 10, 2012 . 1 changed file with 12 additions and 39 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,40 +1,13 @@ <?php function xpathEscape($query, $default_delim = '"') { if (strpos($query, $default_delim) === false) return $default_delim . $query . $default_delim; preg_match_all("#(?:('+)|[^']+)#", $query, $matches); list($parts, $apos) = $matches; foreach ($parts as $i => &$part) { $delim = $apos[$i] ? '"' : "'"; $part = $delim . $part . $delim; } return 'concat(' . implode(',', $parts) . ')'; } -
iaindooley revised this gist
Aug 21, 2011 . No changes.There are no files selected for viewing
-
iaindooley renamed this gist
Aug 21, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
iaindooley revised this gist
Aug 19, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ function xpathEscape($query,$default_delim = '"') } if($current_part) $parts[] = '\''.$current_part.'\''; $ret = 'concat('.implode(',',$parts).')'; } -
iaindooley revised this gist
Aug 19, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ <?php function xpathEscape($query,$default_delim = '"') { if((strpos($query,'\'') !== FALSE) || -
iaindooley created this gist
Aug 19, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ <?php function genericXpathQuoteConcatenation($query,$default_delim = '"') { if((strpos($query,'\'') !== FALSE) || (strpos($query,'"') !== FALSE)) { $quotechars = array('\'','"'); $parts = array(); $current_part = ''; foreach(str_split($query) as $character) { if(in_array($character,$quotechars)) { $parts[] = '\''.$current_part.'\''; if($character == '\'') $parts[] = '"'.$character.'"'; else $parts[] = '\''.$character.'\''; $current_part = ''; } else $current_part .= $character; } if($current_part) $parts[] = $current_part; $ret = 'concat('.implode(',',$parts).')'; } else $ret = $default_delim.$query.$default_delim; return $ret; }