Skip to content

Commit

Permalink
Feature 1559 : remove custom function (std) for sqlite
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@5503 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
nikrou committed Mar 31, 2010
1 parent fc99828 commit c790511
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 58 deletions.
29 changes: 0 additions & 29 deletions include/dblayer/functions_pdo-sqlite.inc.php
Expand Up @@ -50,7 +50,6 @@ function pwg_db_connect($host, $user, $password, $database)
$link->sqliteCreateFunction('md5', 'md5', 1);
$link->sqliteCreateFunction('if', 'pwg_if', 3);

$link->sqliteCreateAggregate('std', 'pwg_std_step', 'pwg_std_finalize');
$link->sqliteCreateFunction('regexp', 'pwg_regexp', 2);

return $link;
Expand Down Expand Up @@ -566,32 +565,4 @@ function pwg_regexp($pattern, $string)
$pattern = sprintf('`%s`', $pattern);
return preg_match($pattern, $string);
}

function pwg_std_step(&$values, $rownumber, $value)
{
$values[] = $value;

return $values;
}

function pwg_std_finalize(&$values, $rownumber)
{
if (count($values)<=1)
{
return 0;
}

$total = 0;
$total_square = 0;
foreach ($values as $value)
{
$total += $value;
$total_square += pow($value, 2);
}

$mean = $total/count($values);
$var = $total_square/count($values) - pow($mean, 2);

return sqrt($var);
}
?>
29 changes: 0 additions & 29 deletions include/dblayer/functions_sqlite.inc.php
Expand Up @@ -59,7 +59,6 @@ function pwg_db_connect($host, $user, $password, $database)
$link->createFunction('md5', 'md5', 1);
$link->createFunction('if', 'pwg_if', 3);

$link->createAggregate('std', 'pwg_std_step', 'pwg_std_finalize');
$link->createFunction('regexp', 'pwg_regexp', 2);

return $link;
Expand Down Expand Up @@ -578,32 +577,4 @@ function pwg_regexp($pattern, $string)
$pattern = sprintf('`%s`', $pattern);
return preg_match($pattern, $string);
}

function pwg_std_step(&$values, $rownumber, $value)
{
$values[] = $value;

return $values;
}

function pwg_std_finalize(&$values, $rownumber)
{
if (count($values)<=1)
{
return 0;
}

$total = 0;
$total_square = 0;
foreach ($values as $value)
{
$total += $value;
$total_square += pow($value, 2);
}

$mean = $total/count($values);
$var = $total_square/count($values) - pow($mean, 2);

return sqrt($var);
}
?>

0 comments on commit c790511

Please sign in to comment.