<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.sqlite3.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'sqlite3.createfunction.php',
    1 => 'SQLite3::createFunction',
    2 => 'Registers a PHP function for use as an SQL scalar function',
  ),
  'up' => 
  array (
    0 => 'class.sqlite3.php',
    1 => 'SQLite3',
  ),
  'prev' => 
  array (
    0 => 'sqlite3.createcollation.php',
    1 => 'SQLite3::createCollation',
  ),
  'next' => 
  array (
    0 => 'sqlite3.enableexceptions.php',
    1 => 'SQLite3::enableExceptions',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/sqlite3/sqlite3/createfunction.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="sqlite3.createfunction" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SQLite3::createFunction</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SQLite3::createFunction</span> &mdash; <span class="dc-title">Registers a PHP function for use as an SQL scalar function</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-sqlite3.createfunction-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SQLite3::createFunction</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$name</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$argCount</code><span class="initializer"> = -1</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Registers a PHP function or user-defined function for use as an SQL scalar
   function for use within SQL statements.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-sqlite3.createfunction-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">name</code></dt>
     <dd>
      <p class="para">
       Name of the SQL function to be created or redefined.
      </p>
     </dd>
    
    
     <dt><code class="parameter">callback</code></dt>
     <dd>
      <p class="para">
       The name of a PHP function or user-defined function to apply as a
       callback, defining the behavior of the SQL function.
      </p>
      <p class="para">
       This function need to be defined as:
       <div class="methodsynopsis dc-description">
        <span class="methodname"><span class="replaceable">callback</span></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">...$values</code></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

       <dl>
        
         <dt><code class="parameter">value</code></dt>
         <dd>
          <p class="para">
           The first argument passed to the SQL function.
          </p>
         </dd>
        
        
         <dt><code class="parameter">values</code></dt>
         <dd>
          <p class="para">
           Further arguments passed to the SQL function.
          </p>
         </dd>
        
       </dl>
      </p> 
     </dd>
    
    
     <dt><code class="parameter">argCount</code></dt>
     <dd>
      <p class="para">
       The number of arguments that the SQL function takes. If
       this parameter is <code class="literal">-1</code>, then the SQL function may take
       any number of arguments.
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       A bitwise conjunction of flags. Currently, only
       <strong><code><a href="sqlite3.constants.php#constant.sqlite3-deterministic">SQLITE3_DETERMINISTIC</a></code></strong> is supported, which specifies
       that the function always returns the same result given the same inputs
       within a single SQL statement.
      </p>
     </dd>
    
   </dl>
  </p>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-sqlite3.createfunction-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> upon successful creation of the function, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-sqlite3.createfunction-changelog">
  <h3 class="title">Log delle modifiche</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versione</th>
      <th>Descrizione</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>7.1.4</td>
      <td>
       The <code class="parameter">flags</code> parameter has been added.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-sqlite3.createfunction-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>SQLite3::createFunction()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">my_udf_md5</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">) {<br />    return </span><span style="color: #0000BB">hash</span><span style="color: #007700">(</span><span style="color: #DD0000">'md5'</span><span style="color: #007700">, </span><span style="color: #0000BB">$string</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$db </span><span style="color: #007700">= new </span><span style="color: #0000BB">SQLite3</span><span style="color: #007700">(</span><span style="color: #DD0000">'mysqlitedb.db'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">'my_udf_md5'</span><span style="color: #007700">, </span><span style="color: #DD0000">'my_udf_md5'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">querySingle</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT my_udf_md5("test")'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Il precedente esempio visualizzerà
qualcosa simile a:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">string(32) &quot;098f6bcd4621d373cade4e832627b4f6&quot;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


</div><?php manual_footer($setup); ?>