Changeset 5503


Ignore:
Timestamp:
03/31/10 20:16:27 (10 years ago)
Author:
nikrou
Message:

Feature 1559 : remove custom function (std) for sqlite

Location:
trunk/include/dblayer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/dblayer/functions_pdo-sqlite.inc.php

    r5452 r5503  
    5151  $link->sqliteCreateFunction('if', 'pwg_if', 3); 
    5252 
    53   $link->sqliteCreateAggregate('std', 'pwg_std_step', 'pwg_std_finalize'); 
    5453  $link->sqliteCreateFunction('regexp', 'pwg_regexp', 2); 
    5554 
     
    567566  return preg_match($pattern, $string); 
    568567} 
    569  
    570 function pwg_std_step(&$values, $rownumber, $value)  
    571 { 
    572   $values[] = $value; 
    573  
    574   return $values; 
    575 } 
    576  
    577 function pwg_std_finalize(&$values, $rownumber)  
    578 { 
    579   if (count($values)<=1) 
    580   { 
    581     return 0; 
    582   } 
    583  
    584   $total = 0; 
    585   $total_square = 0; 
    586   foreach ($values as $value) 
    587   { 
    588     $total += $value; 
    589     $total_square += pow($value, 2); 
    590   } 
    591  
    592   $mean = $total/count($values); 
    593   $var = $total_square/count($values) - pow($mean, 2); 
    594    
    595   return sqrt($var); 
    596 } 
    597568?> 
  • trunk/include/dblayer/functions_sqlite.inc.php

    r5236 r5503  
    6060  $link->createFunction('if', 'pwg_if', 3); 
    6161 
    62   $link->createAggregate('std', 'pwg_std_step', 'pwg_std_finalize'); 
    6362  $link->createFunction('regexp', 'pwg_regexp', 2); 
    6463 
     
    579578  return preg_match($pattern, $string); 
    580579} 
    581  
    582 function pwg_std_step(&$values, $rownumber, $value)  
    583 { 
    584   $values[] = $value; 
    585  
    586   return $values; 
    587 } 
    588  
    589 function pwg_std_finalize(&$values, $rownumber)  
    590 { 
    591   if (count($values)<=1) 
    592   { 
    593     return 0; 
    594   } 
    595  
    596   $total = 0; 
    597   $total_square = 0; 
    598   foreach ($values as $value) 
    599   { 
    600     $total += $value; 
    601     $total_square += pow($value, 2); 
    602   } 
    603  
    604   $mean = $total/count($values); 
    605   $var = $total_square/count($values) - pow($mean, 2); 
    606    
    607   return sqrt($var); 
    608 } 
    609580?> 
Note: See TracChangeset for help on using the changeset viewer.