📄 function.pdo-sqlitecreateaggregate.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Registers an aggregating User Defined Function for use in SQL statements</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-sqlite.connection.html">PDO_SQLITE DSN</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pdo-sqlitecreatefunction.html">PDO->sqliteCreateFunction</a></div> <div class="up"><a href="ref.pdo-sqlite.html">SQLite (PDO)</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.pdo-sqlitecreateaggregate" class="refentry"> <div class="refnamediv"> <h1 class="refname">PDO->sqliteCreateAggregate</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">PDO->sqliteCreateAggregate</span> — <span class="dc-title"> Registers an aggregating User Defined Function for use in SQL statements </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="classsynopsis"> <div class="ooclass"><a href="class.pdo.html" class="classname">PDO</a></div> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>sqliteCreateAggregate</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$function_name</tt></span> , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.callback" class="type callback">callback</a></span> <tt class="parameter">$step_func</tt></span> , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.callback" class="type callback">callback</a></span> <tt class="parameter">$finalize_func</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$num_args</tt></span> ] )</div> </div> <div class="warning"><b class="warning">Warning</b><p class="simpara">This function is<em class="emphasis">EXPERIMENTAL</em>. The behaviour of this function, its name, andsurrounding documentation may change without notice in a future release of PHP.This function should be used at your own risk.</p></div> <p class="para"> This method is similar to <a href="function.pdo-sqlitecreatefunction.html" class="xref">PDO->sqliteCreateFunction</a> except that it registers functions that can be used to calculate a result aggregated across all the rows of a query. </p> <p class="para"> The key difference between this method and <a href="function.pdo-sqlitecreatefunction.html" class="xref">PDO->sqliteCreateFunction</a> is that two functions are required to manage the aggregate. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">function_name</tt></i></span> <dd> <p class="para"> The name of the function used in SQL statements. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">step_func</tt></i></span> <dd> <p class="para"> Callback function called for each row of the result set. Your PHP function should accumulate the result and store it in the aggregation context. </p> <p class="para"> This function need to be defined as: <div class="methodsynopsis dc-description"> <span class="methodname"><b><span class="replaceable">step</span></b></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$context</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$rownumber</tt></span> , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$value1</tt></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$value2</tt></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$..</tt></span> ]] )</div> </p> <p class="para"> <var class="varname">context</var> will be <b><tt>NULL</tt></b> for the first row; on subsequent rows it will have the value that was previously returned from the step function; you should use this to maintain the aggregate state. </p> <p class="para"> <var class="varname">rownumber</var> will hold the current row number. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">finalize_func</tt></i></span> <dd> <p class="para"> Callback function to aggregate the "stepped" data from each row. Once all the rows have been processed, this function will be called and it should then take the data from the aggregation context and return the result. Callback functions should return a type understood by SQLite (i.e. <a href="language.types.html#language.types.intro" class="link">scalar type</a>). </p> <p class="para"> This function need to be defined as: <div class="methodsynopsis dc-description"> <span class="methodname"><b><span class="replaceable">fini</span></b></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$context</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$rownumber</tt></span> )</div> </p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -