Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove personalization (usage of you, we, etc.) #2714

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 44 additions & 41 deletions reference/pdo_sqlite/PDO/sqliteCreateAggregate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
</methodsynopsis>
&warn.experimental.func;
<para>
This method is similar to <xref linkend="pdo.sqlitecreatefunction"
/> except that it registers functions that can be used to calculate a
result aggregated across all the rows of a query.
This method is similar to
<xref linkend="pdo.sqlitecreatefunction" />,
except that it registers functions that can be used to calculate a result
aggregated across all the rows of a query.
</para>
<para>
The key difference between this method and <xref
linkend="pdo.sqlitecreatefunction" /> is that two functions are
required to manage the aggregate.
The key difference between this method and
<xref linkend="pdo.sqlitecreatefunction" />
is that two functions are required to manage the aggregate.
</para>
</refsect1>

Expand All @@ -46,9 +47,9 @@
<term><parameter>step_func</parameter></term>
<listitem>
<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.
Callback function called for each row of the result set.
The PHP function should accumulate the result and store it in the
aggregation context.
</para>
<para>
This function need to be defined as:
Expand All @@ -65,8 +66,8 @@
<listitem>
<para>
&null; 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.
that was previously returned from the step function; this should be
used to maintain the aggregate state.
</para>
</listitem>
</varlistentry>
Expand Down Expand Up @@ -105,12 +106,12 @@
<term><parameter>finalize_func</parameter></term>
<listitem>
<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. This callback function should return a type understood
by SQLite (i.e. <link
linkend="language.types.intro">scalar type</link>).
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.
This callback function should return a type understood by SQLite (i.e. a
<link linkend="language.types.intro">scalar type</link>).
</para>
<para>
This function need to be defined as:
Expand Down Expand Up @@ -190,15 +191,15 @@ foreach ($data as $str) {
}
$insert = null;

function max_len_step($context, $rownumber, $string)
function max_len_step($context, $rownumber, $string)
{
if (strlen($string) > $context) {
$context = strlen($string);
}
return $context;
}

function max_len_finalize($context, $rowcount)
function max_len_finalize($context, $rowcount)
{
return $context === null ? 0 : $context;
}
Expand All @@ -213,43 +214,45 @@ var_dump($db->query('SELECT max_len(a) from strings')->fetchAll());
</example>
</para>
<para>
In this example, we are creating an aggregating function that will
calculate the length of the longest string in one of the columns of the
table. For each row, the <literal>max_len_step</literal> function is
called and passed a <literal>$context</literal> parameter. The context
parameter is just like any other PHP variable and be set to hold an array
or even an object value. In this example, we are simply using it to hold
the maximum length we have seen so far; if the
<literal>$string</literal> has a length longer than the current
maximum, we update the context to hold this new maximum length.
In this example, an aggregating function is being created that will calculate
the length of the longest string in one of the columns of the table.
For each row, the <literal>max_len_step</literal> function is called and
passed a <parameter>$context</parameter> parameter.
The <parameter>$context</parameter> parameter is just like any other PHP
variable and be set to hold an array or even an object value.
In this example, it is simply being used to hold the maximum length seen so
far; if the <parameter>$string</parameter> has a length longer than the
current maximum, the <parameter>$context</parameter> will be updated to hold
this new maximum length.
</para>
<para>
After all of the rows have been processed, SQLite calls the
<literal>max_len_finalize</literal> function to determine the aggregate
result. Here, we could perform some kind of calculation based on the
data found in the <literal>$context</literal>. In our simple example
though, we have been calculating the result as the query progressed, so we
simply need to return the context value.
result.
Here, some kind of calculation could be performed based on the data found in
the <parameter>$context</parameter>.
In this simple example though, the result has been calculated as the query
progressed, so it's simply needed to return the context value.
</para>
<tip>
<para>
It is NOT recommended for you to store a copy of the values in the context
and then process them at the end, as you would cause SQLite to use a lot of
memory to process the query - just think of how much memory you would need
if a million rows were stored in memory, each containing a string 32 bytes
in length.
It is <emphasis>not</emphasis> recommended to store a copy of the values in
the context and then process them at the end, as it would cause SQLite to
use a lot of memory to process the query - just think of how much memory
would be needed if a million rows were stored in memory, each containing a
string 32 bytes in length.
</para>
</tip>
<tip>
<para>
You can use <xref linkend="pdo.sqlitecreatefunction" /> and
<xref linkend="pdo.sqlitecreateaggregate" /> to override SQLite
native SQL functions.
<xref linkend="pdo.sqlitecreatefunction" />
and
<xref linkend="pdo.sqlitecreateaggregate" />
can be used to override SQLite native SQL functions.
</para>
</tip>
</refsect1>


<refsect1 role="seealso">
&reftitle.seealso;
<para>
Expand Down
7 changes: 6 additions & 1 deletion reference/pdo_sqlite/PDO/sqliteCreateCollation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
<term><parameter>callback</parameter></term>
<listitem>
<para>
The name of a PHP function or user-defined function to apply as a callback, defining the behavior of the collation. It should accept two strings and return as strcmp() does, i.e. it should return -1, 1, or 0 if the first string sorts before, sorts after, or is equal to the second.
The name of a PHP function or user-defined function to apply as a
callback, defining the behavior of the collation.
It should accept two strings and return as <function>strcmp</function>
does, i.e. it should return <literal>-1</literal>, <literal>1</literal>,
or <literal>0</literal> if the first string sorts before, sorts after, or
is equal to the second.
</para>
<para>
This function need to be defined as:
Expand Down
65 changes: 21 additions & 44 deletions reference/pdo_sqlite/PDO/sqliteCreateFunction.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
&warn.experimental.func;

<para>
This method allows you to register a PHP function with SQLite as an
<acronym>UDF</acronym> (User Defined Function), so that it can be called
from within your SQL statements.
This method allows to register a PHP function with SQLite as an
<acronym>UDF</acronym> (User Defined Function), so that it can be called from
within the SQL statements.
</para>
<para>
The UDF can be used in any SQL statement that can call functions, such as
Expand Down Expand Up @@ -86,20 +86,20 @@
<term><parameter>num_args</parameter></term>
<listitem>
<para>
The number of arguments that the SQL function takes. If
this parameter is <literal>-1</literal>, then the SQL function may take
any number of arguments.
The number of arguments that the SQL function takes.
If this parameter is <literal>-1</literal>, then the SQL function may
take any number of arguments.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</parameter></term>
<listitem>
<para>
A bitwise conjunction of flags. Currently, only
<constant>PDO::SQLITE_DETERMINISTIC</constant> is supported, which specifies
that the function always returns the same result given the same inputs
within a single SQL statement.
A bitwise conjunction of flags.
Currently, only <constant>PDO::SQLITE_DETERMINISTIC</constant> is
supported, which specifies that the function always returns the same
result given the same inputs within a single SQL statement.
</para>
</listitem>
</varlistentry>
Expand Down Expand Up @@ -158,45 +158,22 @@ $rows = $db->query('SELECT md5rev(filename) FROM files')->fetchAll();
</example>
</para>
<para>
In this example, we have a function that calculates the md5 sum of a
string, and then reverses it. When the SQL statement executes, it
returns the value of the filename transformed by our function. The data
returned in <literal>$rows</literal> contains the processed result.
In this example, there is a function that calculates the md5 sum of a string,
and then reverses it.
When the SQL statement executes, it returns the value of the filename
transformed by the function.
The data returned in <varname>$rows</varname> contains the processed result.
</para>
<para>
The beauty of this technique is that you do not need to process the
result using a &foreach; loop after you have queried for the data.
The beauty of this technique is that it is not needed to process the result
using a &foreach; loop after the data has been queried for.
</para>
<!-- not for PDO it doesn't, at least not yet
<para>
PHP registers a special function named <literal>php</literal> when the
database is first opened. The php function can be used to call any PHP
function without having to register it first.
</para>
<para>
<example>
<title>Example of using the PHP function</title>
<programlisting role="php">
<![CDATA[
<?php
$rows = $db->query("SELECT php('md5', filename) from files")->fetchAll();
?>
]]>
</programlisting>
<para>
This example will call the <function>md5</function> on each
<literal>filename</literal> column in the database and return the result
into <parameter>$rows</parameter>
</para>
</example>
</para>

-->
<tip>
<para>
You can use <xref linkend="pdo.sqlitecreatefunction" /> and
<xref linkend="pdo.sqlitecreateaggregate" /> to override SQLite
native SQL functions.
<xref linkend="pdo.sqlitecreatefunction" />
and
<xref linkend="pdo.sqlitecreateaggregate" />
can be used to override SQLite native SQL functions.
</para>
</tip>
</refsect1>
Expand Down
14 changes: 8 additions & 6 deletions reference/pdo_sqlite/configure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
<section xml:id="ref.pdo-sqlite.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.install;
<para>
The PDO_SQLITE PDO driver is enabled by default. To disable,
<option role="configure">--without-pdo-sqlite[=DIR]</option> may be used,
where the optional <literal>[=DIR]</literal> is the sqlite base install directory.
As of PHP 7.4.0 <link xlink:href="&url.sqlite;">libsqlite</link> ≥ 3.5.0 is required.
Formerly, the bundled libsqlite could have been used instead, and was the
default, if <literal>[=DIR]</literal> has been omitted.
The PDO_SQLITE PDO driver is enabled by default.
To disable it, <option role="configure">--without-pdo-sqlite[=DIR]</option>
may be used, where the optional <literal>[=DIR]</literal> is the sqlite base
install directory.
As of PHP 7.4.0,
<link xlink:href="&url.sqlite;">libsqlite</link> ≥ 3.5.0 is required.
Formerly, the bundled libsqlite could have been used instead and was the
default if <literal>[=DIR]</literal> has been omitted.
</para>
<note>
<title>Additional setup on Windows as of PHP 7.4.0</title>
Expand Down
2 changes: 1 addition & 1 deletion reference/pdo_sqlite/reference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<reference xml:id="ref.pdo-sqlite" xmlns="http://docbook.org/ns/docbook">
<?phpdoc extension-membership="bundledexternal" ?>
<title>SQLite Functions (PDO_SQLITE)</title>
<title>SQLite &Functions; (PDO_SQLITE)</title>
<titleabbrev>SQLite (PDO)</titleabbrev>
<partintro>

Expand Down