cortesi Thu Apr 11 13:14:56 2002 EDT
Added files:
/phpdoc/it/functions fbsql.xml
Log:
committing half done translation
#everybody is fearing Hartmut these days
Index: phpdoc/it/functions/fbsql.xml
+++ phpdoc/it/functions/fbsql.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- EN-Revision: 1.38 Maintainer: calandra Status: working -->
<reference id="ref.fbsql">
<title>FrontBase Functions</title>
<titleabbrev>FrontBase</titleabbrev>
<partintro>
<simpara>
Queste funzioni permettono di accedere ai servers del database FrontBase.
Affinch� queste funzioni siano disponibili � necessario compilare php con
il supporto fbsql usando l' opzione <option
role="configure">--with-fbsql</option>.Se si usa questa opzione senza specificare
il percorso a fbsql, php cercher� le librerie client di fbsql nella cartella di
default
specificata nell'istallazione di FrontBase, a seconda del sistema operativo. Se si
installa
FrontBase in una cartella non standard � necessario specificare sempre
il percorso a fbsql: <option
role="configure">--with-fbsql=/path/to/fbsql</option>. In questo modo
si forzer� php ad usare le librerie client installate da FrontBase,
evitando ogni conflitto.
</simpara>
<simpara>
Maggiori informazioni su FrontBase: <ulink
url="&url.fbsql;">&url.fbsql;</ulink>.
</simpara>
<simpara>
Documentazione su FrontBase : <ulink
url="&url.fbsql.docs;">&url.fbsql.docs;</ulink>.
</simpara>
<simpara>
Il supporto Frontbase � stato aggiunto dal PHP 4.0.6.
</simpara>
</partintro>
<refentry id="function.fbsql-affected-rows">
<refnamediv>
<refname>fbsql_affected_rows</refname>
<refpurpose>
Ritorna il numero di righe (tuple) interessate nella precedente operazione di
FrontBase.
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>int</type><methodname>fbsql_affected_rows</methodname>
<methodparam choice="opt"><type>int</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_affected_rows</function> restituisce il numero di
righe interessate dall'ultima query INSERT, UPDATE or DELETE associata
al parametro <parameter>link_identifier</parameter>. Se tale parametro non �
stato specificato,
sar� usata l'ultima connessione aperta da
<function>fbsql_connect</function>.
</para>
<note>
<para>
Se si stanno usando le transazioni, � necessario chiamare la funzione
<function>fbsql_affected_rows</function> dopo una query INSERT, UPDATE, or
DELETE,
non dopo la chiusura della transazione (commit).
</para>
</note>
<para>
Se l'ultima query � un istruzione DELETE senza clausola WHERE,
tutte le righe verranno cancellate dalla tabella e la funzione
restituir� il valore 0 (zero).
</para>
<note>
<para>
Se si utilizza l'istruzione UPDATE, FrontBase non aggiorner� le
colonne in cui il valore nuovo � uguale a quello vecchio. Quindi esiste la
possibilit�
che <function>fbsql_affected_rows</function> sia diverso dal
numero di righe realmente interessate
dalla query.
</para>
</note>
<para>
Se l'ultima query fallisce la funzione restituisce -1.
</para>
<para>
Vedere anche: <function>fbsql_num_rows</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-autocommit">
<refnamediv>
<refname>fbsql_autocommit</refname>
<refpurpose>Abilita o disabilita autocommit.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_autocommit</methodname>
<methodparam><type>resource</type><parameter>link_identifier</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>
OnOff
</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_autocommit</function> restituisce lo stato
corrente di autocommit .Se � stato specificato il parametro opzionale
OnOff , lo stato di autocommit verr� cambiato. Impostando il parametro
OnOff su &true; ogni istruzione verr� eseguita automaticamente,
in caso di assenza di errori. Impostandolo
su &false; l'utente dovr� eseguire la transazione richiamando
le funzioni <function>fbsql_commit</function> o
<function>fbsql_rollback</function>.
</para>
<para> Vedere anche:
<function>fbsql_commit</function> and
<function>fbsql_rollback</function>
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-change-user">
<refnamediv>
<refname>fbsql_change_user</refname>
<refpurpose>
Cambia l'identit� dell'utente connesso con una connessione attiva.
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>resource</type><methodname>fbsql_change_user</methodname>
<methodparam><type>string</type><parameter>user</parameter></methodparam>
<methodparam><type>string</type><parameter>password</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>
database
</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_change_user</function> Cambia l'identit� dell'utente connesso
con una connessione attiva, o con la connessione specificata
dal parametro opzionale link_identifier. Se � stato specificato un
database, dopo che l'identit� dell'utente sar� stata cambiata,
questo diventer� il database attivo . Se l'autorizzazione del
nuovo utente fallisce, rimarr� attiva l'identit� dell'utente corrente.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-close">
<refnamediv>
<refname>fbsql_close</refname>
<refpurpose>Chiude la connessione a FrontBase.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>boolean</type><methodname>fbsql_close</methodname>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Ritorna: &true; in caso di successo, &false; in caso di fallimento.
</para>
<para>
<function>fbsql_close</function> chiude la connessione al sever
FrontBase associata ad uno specificato link identifier.
Se il <parameter>link_identifier</parameter> non fosse specificato, verrebbe
chiusa
l'ultima connessione aperta.
</para>
<para>
Non � sempre necessario usare <function>fbsql_close</function> nel caso di
connessioni non permanenti,
esse verranno chiuse automaticamente alla fine dell'esecuzione
dello script.
</para>
<example>
<title>Uso di <function>fbsql_close</function></title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_connect ("localhost", "_SYSTEM", "secret")
or die ("Could not connect");
print ("Connected successfully");
fbsql_close ($link);
?>
]]>
</programlisting>
</example>
<para>
Vedere anche: <function>fbsql_connect</function> e
<function>fbsql_pconnect</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-commit">
<refnamediv>
<refname>fbsql_commit</refname>
<refpurpose>Compie una transazione.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_commit</methodname>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Ritorna: &true; in caso di successo, &false; in caso di fallimento.
</para>
<para>
<function>fbsql_commit</function> esegue la transazione
corrente scrivendo tutti gli aggiornamenti pendenti, cancella
il disco e sblocca tutte le righe della tabella bloccata dalla transazione.
Questo comando � necessario solo nel caso in cui autocommit fosse impostato su
false.
</para>
<para> Vedere anche:
<function>fbsql_autocommit</function> e
<function>fbsql_rollback</function>
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-connect">
<refnamediv>
<refname>fbsql_connect</refname>
<refpurpose>Apre una connessione al Server FrontBase.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>resource</type><methodname>fbsql_connect</methodname>
<methodparam choice="opt"><type>string</type><parameter>
hostname
</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>
username
</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>
password
</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce un valore di link_identifier positivo in
caso di successo, o un messaggio di errore in caso di fallimento.
</para>
<para>
<function>fbsql_connect</function> Apre una connessione
al Server FrontBase.Se i parametri opzionali non sono specificati verranno usati
i valori seguenti come default: <parameter>hostname</parameter> = '&null;',
<parameter>username</parameter> = '_SYSTEM' e
<parameter>password</parameter> = empty password.
</para>
<para>
Se si richiamasse, una seconda volta, la funzione
<function>fbsql_connect</function>
con gli stessi argomenti, non si creerebbe una nuova
connessione,ma verrebbe restituito il valore di link_identifier
della connessione gi� aperta.
</para>
<para>
La connessione al server si chiuder� alla fine dello script, a meno che
non venga chiusa in anticipo richiamando esplicitamente la funzione
<function>fbsql_close</function>.
</para>
<example>
<title><function>fbsql_connect</function></title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_connect ("localhost", "_SYSTEM", "secret")
or die ("Could not connect");
print ("Connected successfully");
fbsql_close ($link);
?>
]]>
</programlisting>
</example>
<para>
Vedere anche
<function>fbsql_pconnect</function> e
<function>fbsql_close</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-create-db">
<refnamediv>
<refname>fbsql_create_db</refname>
<refpurpose>Crea un database.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_create_db</methodname>
<methodparam><type>string</type><parameter>database
name</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_create_db</function> crea un nuovo database
FrontBase sul server, identificato dal parametro
link_identifier.
</para>
<example>
<title><function>fbsql_create_db</function></title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
or die ("Could not connect");
if (fbsql_create_db ("my_db")) {
print("Database created successfully\n");
} else {
printf("Error creating database: %s\n", fbsql_error ());
}
?>
]]>
</programlisting>
</example>
<para>
Vedere anche <function>fbsql_drop_db</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-create-blob">
<refnamediv>
<refname>fbsql_create_blob</refname>
<refpurpose>Create a BLOB</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_create_blob</methodname>
<methodparam><type>string</type><parameter>blob_data</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Returns: A resource handle to the newly created blob.
</para>
<para>
<function>fbsql_create_blob</function> creates a blob from
blob_data. The returned resource handle can be used with insert
and update commands to store the blob in the database.
</para>
<example>
<title><function>fbsql_create_blob</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
or die ("Could not connect");
$filename = "blobfile.bin";
$fp = fopen($filename, "rb");
$blobdata = fread($fp, filesize($filename));
fclose($fp);
$blobHandle = fbsql_create_blob($blobdata, $link);
$sql = "INSERT INTO BLOB_TABLE (BLOB_COLUMN) VALUES ($blobHandle);";
$rs = fbsql_query($sql, $link);
?>
]]>
</programlisting>
</example>
<para>
See also: <function>fbsql_create_clob</function>,
<function>fbsql_read_blob</function>,
<function>fbsql_read_clob</function>, and
<function>fbsql_set_lob_mode</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-create-clob">
<refnamediv>
<refname>fbsql_create_clob</refname>
<refpurpose>Create a CLOB</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_create_clob</methodname>
<methodparam><type>string</type><parameter>clob_data</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Returns: A resource handle to the newly created CLOB.
</para>
<para>
<function>fbsql_create_clob</function> creates a clob from
clob_data. The returned resource handle can be used with insert
and update commands to store the clob in the database.
</para>
<example>
<title><function>fbsql_create_clob</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
or die ("Could not connect");
$filename = "clob_file.txt";
$fp = fopen($filename, "rb");
$clobdata = fread($fp, filesize($filename));
fclose($fp);
$clobHandle = fbsql_create_clob($clobdata, $link);
$sql = "INSERT INTO CLOB_TABLE (CLOB_COLUMN) VALUES ($clobHandle);";
$rs = fbsql_query($sql, $link);
?>
]]>
</programlisting>
</example>
<para>
See also: <function>fbsql_create_blob</function>,
<function>fbsql_read_blob</function>,
<function>fbsql_read_clob</function>, and
<function>fbsql_set_lob_mode</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-database-password">
<refnamediv>
<refname>fbsql_database_password</refname>
<refpurpose>
Imposta o ricerca la password di un database FrontBase.
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_database_password</methodname>
<methodparam><type>resource</type><parameter>link_identifier</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>
database_password
</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce: La password del database identificato dal parametro link_identifier.
</para>
<para>
<function>fbsql_database_password</function> imposta e
ricerca la password del database corrente. Se
il secondo parametro, opzionale
(database_password),� stato specificato la funzione
imposta, sul server, il valore del parametro come password del
database identificato dal parametro link_identifier. Se il link_identifier
non � specificato, verr� utilizzata l'ultima connessione aperta. Se nessuna
connessione � aperta, la funzione tenter� di aprirne una come se la funzione
<function>fbsql_connect</function> fosse chiamata, e user� quella.
</para>
<para>
This function does not change the database password in the database
nor can it be used to retrive the database password for a database.
</para>
<example>
<title>Esempio di <function>fbsql_create_clob</function></title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
or die ("Could not connect");
fbsql_database_password($link, "secret db password");
fbsql_select_db($database, $link);
?>
]]>
</programlisting>
</example>
<para>
Vedere anche: <function>fbsql_connect</function>,
<function>fbsql_pconnect</function> e
<function>fbsql_select_db</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-data-seek">
<refnamediv>
<refname>fbsql_data_seek</refname>
<refpurpose>Sposta il puntatore del risultato interno.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_data_seek</methodname>
<methodparam><type>resource</type><parameter>result_identifier</parameter></methodparam>
<methodparam><type>int</type><parameter>row_number</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce: &true; in caso di successo, &false; in caso di fallimento.
</para>
<para>
<function>fbsql_data_seek</function> sposta il
puntatore interno al risultato FrontBase associato con
uno specificato indice in modo che punti ad un numero di riga
specificata . La chiamata successiva alla
funzione<function>fbsql_fetch_row</function> restituir� la
riga richiesta.
</para>
<para>
<parameter>Row_number</parameter> comincia a contare da 0.
</para>
<example>
<title><function>fbsql_data_seek</function></title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
or die ("Could not connect");
fbsql_select_db ("samp_db")
or die ("Could not select database");
$query = "SELECT last_name, first_name FROM friends;";
$result = fbsql_query ($query)
or die ("Query failed");
# fetch rows in reverse order
for ($i = fbsql_num_rows ($result) - 1; $i >=0; $i--) {
if (!fbsql_data_seek ($result, $i)) {
printf ("Cannot seek to row %d\n", $i);
continue;
}
if(!($row = fbsql_fetch_object ($result)))
continue;
printf("%s %s<BR>\n", $row->last_name, $row->first_name);
}
fbsql_free_result ($result);
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<refentry id="function.fbsql-db-query">
<refnamediv>
<refname>fbsql_db_query</refname>
<refpurpose>Manda una query FrontBase.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>resource</type><methodname>fbsql_db_query</methodname>
<methodparam><type>string</type><parameter>database</parameter></methodparam>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce: un indice FrontBase positivo come risultato della
query, o &false; in caso di errore.
</para>
<para>
<function>fbsql_db_query</function> seleziona un database
ed esegue la query su di esso.Se il parametro
opzionale link_identifier non � stato specificato,
la funzione ne cercher� una gi� aperta nel FrontBase server, in caso non
ne trovasse alcuna aprir� una nuova connessione come se la funzione
<function>fbsql_connect</function>
fosse chiamta senza argomenti.
</para>
<para>
Vedere anche: <function>fbsql_connect</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-db-status">
<refnamediv>
<refname>fbsql_db_status</refname>
<refpurpose>Ritorna lo stato di un dato database.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>int</type><methodname>fbsql_db_status</methodname>
<methodparam><type>string</type><parameter>database_name</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Ritorna: Un valore intero con lo stato corrente.
</para>
<para>
<function>fbsql_db_status</function> richiede lo stato corrente del
database specificato da
<parameter>database_name</parameter>. Se il
<parameter>link_identifier</parameter> viene omesso verr� usato quello
in uso.
</para>
<para>
Il valore restituito potr� essere uno delle seguenti costanti:
<itemizedlist>
<listitem>
<simpara>
&false; - L' exec handler del host era invalido. Questo errore si
presenta quando la connessione avviene direttamente al database,
tramite il link_identifier, usando un numero di porta. FBExec pu�
essere disponibile sul server ma nessuna connessione � stata creata.
</simpara>
</listitem>
<listitem>
<simpara>
FBSQL_UNKNOWN - Lo stato � sconosciuto.
</simpara>
</listitem>
<listitem>
<simpara>
FBSQL_STOPPED - Il database non � attivo. Usare
<function>fbsql_start_db</function> per attivare il database.
</simpara>
</listitem>
<listitem>
<simpara>
FBSQL_STARTING - Il database � in fase di attivazione.
</simpara>
</listitem>
<listitem>
<simpara>
FBSQL_RUNNING - Il database � attivo e pu� essere usato
per eseguire operazioni SQL.
</simpara>
</listitem>
<listitem>
<simpara>
FBSQL_STOPPING - Il database � in fase di disattivazione.
</simpara>
</listitem>
<listitem>
<simpara>
FBSQL_NOEXEC - FBExec non � attivo sul server quindi non �
possibile conoscere lo stato del database.
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
Vedere anche: <function>fbsql_start_db</function> e
<function>fbsql_stop_db</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-drop-db">
<refnamediv>
<refname>fbsql_drop_db</refname>
<refpurpose>Cancella un database FrontBase.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_drop_db</methodname>
<methodparam><type>string</type><parameter>database_name</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce &true; in caso di successo, &false; in caso di fallimento.
</para>
<para>
<function>fbsql_drop_db</function> procede con l'eliminazione
di un intero database dal server associato
all'identificatore di link.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-errno">
<refnamediv>
<refname>fbsql_errno</refname>
<refpurpose>
Ritorna il valore numerico del messaggio
di errore emesso dalla precedente operazione FrontBase.
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>int</type><methodname>fbsql_errno</methodname>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce il numero di errore dell'ultima funzione fbsql,
<literal>0</literal> (zero) se non ci sono stati errori.
</para>
<para>
Gli errori vengono restituiti dal database fbsql senza visualizzare i warnings.
Usare <function>fbsql_errno</function> per ricevere codice dell'errore.
Da notare che questa funzione restituisce solamente il codice di
errore proveniente dalla pi� recente esecuzione di una funzione fbsql
(escludendo <function>fbsql_error</function> e
<function>fbsql_errno</function>),cos� se si vuole usarla, assicurarsi
di controllare il valore prima di richiamare un'altra funzione fbsql.
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
fbsql_connect("marliesle");
echo fbsql_errno().": ".fbsql_error()."<BR>";
fbsql_select_db("nonexistentdb");
echo fbsql_errno().": ".fbsql_error()."<BR>";
$conn = fbsql_query("SELECT * FROM nonexistenttable;");
echo fbsql_errno().": ".fbsql_error()."<BR>";
?>
]]>
</programlisting>
</informalexample>
</para>
<para>
Vedere anche: <function>fbsql_error</function> e
<function>fbsql_warnings</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-error">
<refnamediv>
<refname>fbsql_error</refname>
<refpurpose>
Ritorna il testo del messaggio di errore emesso dalla precedente operazione
FrontBase.
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_error</methodname>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce il testo del messaggio di errore dell'ultima funzione fbsql, o
<literal>''</literal> (una stringa vuota) se non ci sono stati errori.
</para>
<para>
Gli errori vengono restituiti dal database fbsql senza visualizzare i warnings.
Usare <function>fbsql_errno</function> per ricevere codice dell'errore.
Da notare che questa funzione restituisce solamente il codice di
errore proveniente dalla pi� recente esecuzione di una funzione fbsql
(escludendo <function>fbsql_error</function> e
<function>fbsql_errno</function>),cos� se si vuole usarla, assicurarsi
di controllare il valore prima di richiamare un'altra funzione fbsql.
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
fbsql_connect("marliesle");
echo fbsql_errno().": ".fbsql_error()."<BR>";
fbsql_select_db("nonexistentdb");
echo fbsql_errno().": ".fbsql_error()."<BR>";
$conn = fbsql_query("SELECT * FROM nonexistenttable;");
echo fbsql_errno().": ".fbsql_error()."<BR>";
?>
]]>
</programlisting>
</informalexample>
</para>
<para>
Vedere anche: <function>fbsql_errno</function> e
<function>fbsql_warnings</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-fetch-array">
<refnamediv>
<refname>fbsql_fetch_array</refname>
<refpurpose>
Restituisce una riga (tupla) di risultato in forma di Array associativo, Array
enumerato o
entrambi.
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>array</type><methodname>fbsql_fetch_array</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>
result_type
</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce un array che corrisponde alla riga di risultato, o &false;
se non ci sono righe successive.
</para>
<para>
<function>fbsql_fetch_array</function> � una versione estesa di
<function>fbsql_fetch_row</function>. In aggiunta all'inserimento dei
dati negli elementi dell'array con indice numerico, li inserisce anche in
indici associativi, usando il nome dei campi come chiavi.
</para>
<para>
Se due o pi� colonne di risultato hanno lo stesso nome di campo ,
l'ultima colonna sovrascriver� la precedente con lo stesso nome. Per
accedere alle altre colonne con lo stesso nome si deve usare l'indice
numerico oppure fare un alias della colonna .
<informalexample>
<programlisting>
<![CDATA[
select t1.f1 as foo t2.f1 as bar from t1, t2
]]>
</programlisting>
</informalexample>
</para>
<para>
Una cosa importante da notare � che
<function>fbsql_fetch_array</function> NON � singnificativamente
pi� lenta di <function>fbsql_fetch_row</function>, mentre fornisce un
significativo
valore aggiunto.
</para>
<para>
Il secondo parametro opzionale, <parameter>result_type</parameter>
in <function>fbsql_fetch_array</function> � una costante che pu�
assumere i seguenti valori: FBSQL_ASSOC, FBSQL_NUM,
and FBSQL_BOTH.
</para>
<para>
Per ulteriori dettagli vedere anche
<function>fbsql_fetch_row</function> e
<function>fbsql_fetch_assoc</function>.
</para>
<example>
<title><function>fbsql_fetch_array</function></title>
<programlisting role="php">
<![CDATA[
<?php
fbsql_connect ($host, $user, $password);
$result = fbsql_db_query ("database","select user_id, fullname from table");
while ($row = fbsql_fetch_array ($result)) {
echo "user_id: ".$row["user_id"]."<br>\n";
echo "user_id: ".$row[0]."<br>\n";
echo "fullname: ".$row["fullname"]."<br>\n";
echo "fullname: ".$row[1]."<br>\n";
}
fbsql_free_result ($result);
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<refentry id="function.fbsql-fetch-assoc">
<refnamediv>
<refname>fbsql_fetch_assoc</refname>
<refpurpose>
Restituisce una riga (tupla) di risultato in forma di Array associativo.
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>array</type><methodname>fbsql_fetch_assoc</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce un array associativo corrispondente alla riga di risultato,
o &false; se non ci sono righe successive.</para>
<para>
<function>fbsql_fetch_assoc</function> � equivalente ad una chiamata a
<function>fbsql_fetch_array</function> con FBSQL_ASSOC come parametro opzionale.
Restituir� solo un array associativo.
<function>fbsql_fetch_array</function> originariamente lavora in questo modo.
Se si vuole un indice numerico come pure
quello associativo, usare <function>fbsql_fetch_array</function>.
</para>
<para>
Se due o pi� colonne di risultato hanno lo stesso nome di campo ,
l'ultima colonna sovrascriver� la precedente con lo stesso nome. Per accedere
alle
altre colonne con lo stesso nome si deve usare
<function>fbsql_fetch_array</function> che
ritorna un indice numerico.
</para>
<para>
Una cosa importante da notare � che
<function>fbsql_fetch_assoc</function> NON � singnificativamente pi� lenta di
<function>fbsql_fetch_row</function>, mentre fornisce un significativo
valore aggiunto.
</para>
<para>
Per maggiori dettagli, vedi anche
<function>fbsql_fetch_row</function> e
<function>fbsql_fetch_array</function>.
</para>
<example>
<title><function>fbsql_fetch_assoc</function></title>
<programlisting role="php">
<![CDATA[
<?php
fbsql_connect ($host, $user, $password);
$result = fbsql_db_query ("database","select * from table");
while ($row = fbsql_fetch_assoc ($result)) {
echo $row["user_id"];
echo $row["fullname"];
}
fbsql_free_result ($result);
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<refentry id="function.fbsql-fetch-field">
<refnamediv>
<refname>fbsql_fetch_field</refname>
<refpurpose>
Get column information from a result and return as an object
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>object</type><methodname>fbsql_fetch_field</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>
field_offset
</parameter></methodparam>
</methodsynopsis>
<para>
Returns an object containing field information.
</para>
<para>
<function>fbsql_fetch_field</function> can be used in order to
obtain information about fields in a certain query result. If
the field offset isn't specified, the next field that wasn't yet
retrieved by <function>fbsql_fetch_field</function> is retrieved.
</para>
<para>
The properties of the object are:
<itemizedlist>
<listitem>
<simpara>
name - column name
</simpara>
</listitem>
<listitem>
<simpara>
table - name of the table the column belongs to
</simpara>
</listitem>
<listitem>
<simpara>
max_length - maximum length of the column
</simpara>
</listitem>
<listitem>
<simpara>
not_null - 1 if the column cannot be &null;
</simpara>
</listitem>
<listitem>
<simpara>
type - the type of the column
</simpara>
</listitem>
</itemizedlist>
</para>
<example>
<title><function>fbsql_fetch_field</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
fbsql_connect ($host, $user, $password)
or die ("Could not connect");
$result = fbsql_db_query ("database", "select * from table")
or die ("Query failed");
# get column metadata
$i = 0;
while ($i < fbsql_num_fields ($result)) {
echo "Information for column $i:<BR>\n";
$meta = fbsql_fetch_field ($result);
if (!$meta) {
echo "No information available<BR>\n";
}
echo "<PRE>
max_length: $meta->max_length
name: $meta->name
not_null: $meta->not_null
table: $meta->table
type: $meta->type
</PRE>";
$i++;
}
fbsql_free_result ($result);
?>
]]>
</programlisting>
</example>
<para>
See also <function>fbsql_field_seek</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-fetch-lengths">
<refnamediv>
<refname>fbsql_fetch_lengths</refname>
<refpurpose>
Get the length of each output in a result
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>array</type><methodname>fbsql_fetch_lengths</methodname>
<methodparam
choice="opt"><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
Returns: An array that corresponds to the lengths of each field
in the last row fetched by <function>fbsql_fetch_row</function>,
or &false; on error.
</para>
<para>
<function>fbsql_fetch_lengths</function> stores the lengths of
each result column in the last row returned by
<function>fbsql_fetch_row</function>,
<function>fbsql_fetch_array</function> and
<function>fbsql_fetch_object</function> in an array, starting at
offset 0.
</para>
<para>
See also: <function>fbsql_fetch_row</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-fetch-object">
<refnamediv>
<refname>fbsql_fetch_object</refname>
<refpurpose>Fetch a result row as an object</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>object</type><methodname>fbsql_fetch_object</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>
result_type
</parameter></methodparam>
</methodsynopsis>
<para>
Returns an object with properties that correspond to the fetched
row, or &false; if there are no more rows.
</para>
<para>
<function>fbsql_fetch_object</function> is similar to
<function>fbsql_fetch_array</function>, with one difference - an
object is returned, instead of an array. Indirectly, that means
that you can only access the data by the field names, and not by
their offsets (numbers are illegal property names).
</para>
<para>
The optional argument <parameter>result_type</parameter> is a
constant and can take the following values: FBSQL_ASSOC,
FBSQL_NUM, and FBSQL_BOTH.
</para>
<para>
Speed-wise, the function is identical to
<function>fbsql_fetch_array</function>, and almost as quick as
<function>fbsql_fetch_row</function> (the difference is
insignificant).
<example>
<title><function>fbsql_fetch_object</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
fbsql_connect ($host, $user, $password);
$result = fbsql_db_query ("database", "select * from table");
while ($row = fbsql_fetch_object ($result)) {
echo $row->user_id;
echo $row->fullname;
}
fbsql_free_result ($result);
?>
]]>
</programlisting>
</example>
</para>
<para>
See also: <function>fbsql_fetch_array</function> and
<function>fbsql_fetch_row</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-fetch-row">
<refnamediv>
<refname>fbsql_fetch_row</refname>
<refpurpose>Get a result row as an enumerated array</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>array</type><methodname>fbsql_fetch_row</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
Returns: An array that corresponds to the fetched row, or &false;
if there are no more rows.
</para>
<para>
<function>fbsql_fetch_row</function> fetches one row of data from
the result associated with the specified result identifier. The
row is returned as an array. Each result column is stored in an
array offset, starting at offset 0.
</para>
<para>
Subsequent call to <function>fbsql_fetch_row</function> would
return the next row in the result set, or &false; if there are no
more rows.
</para>
<para>
See also: <function>fbsql_fetch_array</function>,
<function>fbsql_fetch_object</function>,
<function>fbsql_data_seek</function>,
<function>fbsql_fetch_lengths</function>, and
<function>fbsql_result</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-field-flags">
<refnamediv>
<refname>fbsql_field_flags</refname>
<refpurpose>
Get the flags associated with the specified field in a result
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_field_flags</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>int</type><parameter>field_offset</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_field_flags</function> returns the field flags of
the specified field. The flags are reported as a single word
per flag separated by a single space, so that you can split the
returned value using <function>explode</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-field-name">
<refnamediv>
<refname>fbsql_field_name</refname>
<refpurpose>
Get the name of the specified field in a result
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_field_name</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>int</type><parameter>field_index</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_field_name</function> returns the name of the
specified field index. <parameter>result</parameter> must be a
valid result identifier and <parameter>field_index</parameter> is
the numerical offset of the field.
</para>
<note>
<para>
<parameter>field_index</parameter> starts at 0.
</para>
<para>
e.g. The index of the third field would actually be 2, the index
of the fourth field would be 3 and so on.
</para>
</note>
<para>
<example>
<title><function>fbsql_field_name</function> example</title>
<programlisting role="php">
<![CDATA[
// The users table consists of three fields:
// user_id
// username
// password.
$res = fbsql_db_query("users", "select * from users", $link);
echo fbsql_field_name($res, 0) . "\n";
echo fbsql_field_name($res, 2);
]]>
</programlisting>
</example>
</para>
<para>
The above example would produce the following output:
<informalexample>
<programlisting>
<![CDATA[
user_id
password
]]>
</programlisting>
</informalexample>
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-field-len">
<refnamediv>
<refname>fbsql_field_len</refname>
<refpurpose>
Returns the length of the specified field
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>int</type><methodname>fbsql_field_len</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>int</type><parameter>field_offset</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_field_len</function> returns the length of the
specified field.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-field-seek">
<refnamediv>
<refname>fbsql_field_seek</refname>
<refpurpose>
Set result pointer to a specified field offset
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_field_seek</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>int</type><parameter>field_offset</parameter></methodparam>
</methodsynopsis>
<para>
Seeks to the specified field offset. If the next call to
<function>fbsql_fetch_field</function> doesn't include a field
offset, the field offset specified in
<function>fbsql_field_seek</function> will be returned.
</para>
<para>
See also: <function>fbsql_fetch_field</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-field-table">
<refnamediv>
<refname>fbsql_field_table</refname>
<refpurpose>
Get name of the table the specified field is in
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_field_table</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>int</type><parameter>field_offset</parameter></methodparam>
</methodsynopsis>
<para>
Returns the name of the table that the specified field is
in.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-field-type">
<refnamediv>
<refname>fbsql_field_type</refname>
<refpurpose>
Get the type of the specified field in a result
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_field_type</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>int</type><parameter>field_offset</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_field_type</function> is similar to the
<function>fbsql_field_name</function> function. The arguments are
identical, but the field type is returned instead. The field type
will be one of "int", "real", "string", "blob", and others as
detailed in the <ulink url="&url.fbsql.docs;">FrontBase
documentation</ulink>.
<example>
<title><function>fbsql_field_type</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
fbsql_connect ("localhost", "_SYSTEM", "");
fbsql_select_db ("wisconsin");
$result = fbsql_query ("SELECT * FROM onek;");
$fields = fbsql_num_fields ($result);
$rows = fbsql_num_rows ($result);
$i = 0;
$table = fbsql_field_table ($result, $i);
echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>";
echo "The table has the following fields <BR>";
while ($i < $fields) {
$type = fbsql_field_type ($result, $i);
$name = fbsql_field_name ($result, $i);
$len = fbsql_field_len ($result, $i);
$flags = fbsql_field_flags ($result, $i);
echo $type." ".$name." ".$len." ".$flags."<BR>";
$i++;
}
fbsql_close();
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-free-result">
<refnamediv>
<refname>fbsql_free_result</refname>
<refpurpose>Free result memory</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_free_result</methodname>
<methodparam><type>int</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_free_result</function> will free all memory
associated with the result identifier <parameter>result</parameter>.
</para>
<para>
<function>fbsql_free_result</function> only needs to be called if
you are concerned about how much memory is being used for queries
that return large result sets. All associated result memory is
automatically freed at the end of the script's execution.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-insert-id">
<refnamediv>
<refname>fbsql_insert_id</refname>
<refpurpose>
Get the id generated from the previous INSERT operation
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>int</type><methodname>fbsql_insert_id</methodname>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_insert_id</function> returns the ID generated for
an column defined as DEFAULT UNIQUE by the previous INSERT query
using the given <parameter>link_identifier</parameter>. If
<parameter>link_identifier</parameter> isn't specified, the last
opened link is assumed.
</para>
<para>
<function>fbsql_insert_id</function> returns 0 if the previous
query does not generate an DEFAULT UNIQUE value. If you need to
save the value for later, be sure to call fbsql_insert_id()
immediately after the query that generates the value.
</para>
<note>
<para>
The value of the FrontBase SQL function
<literal>LAST_INSERT_ID()</literal> always contains the most
recently generated DEFAULT UNIQUE value, and is not reset
between queries.
</para>
</note>
</refsect1>
</refentry>
<refentry id="function.fbsql-list-dbs">
<refnamediv>
<refname>fbsql_list_dbs</refname>
<refpurpose>
List databases available on a FrontBase server
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>resource</type><methodname>fbsql_list_dbs</methodname>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_list_dbs</function> will return a result pointer
containing the databases available from the current fbsql
daemon. Use the <function>fbsql_tablename</function> function to
traverse this result pointer.
</para>
<para>
<example>
<title><function>fbsql_list_dbs</function> example</title>
<programlisting role="php">
<![CDATA[
$link = fbsql_connect('localhost', 'myname', 'secret');
$db_list = fbsql_list_dbs($link);
while ($row = fbsql_fetch_object($db_list)) {
echo $row->Database . "\n";
}
]]>
</programlisting>
</example>
</para>
<para>
The above example would produce the following output:
<informalexample>
<programlisting>
<![CDATA[
database1
database2
database3
..
]]>
</programlisting>
</informalexample>
</para>
<note>
<para>
The above code would just as easily work with
<function>fbsql_fetch_row</function> or other similar functions.
</para>
</note>
</refsect1>
</refentry>
<refentry id="function.fbsql-list-fields">
<refnamediv>
<refname>fbsql_list_fields</refname>
<refpurpose>List FrontBase result fields</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>resource</type><methodname>fbsql_list_fields</methodname>
<methodparam><type>string</type><parameter>database_name</parameter></methodparam>
<methodparam><type>string</type><parameter>table_name</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_list_fields</function> retrieves information
about the given tablename. Arguments are the database name and
the table name. A result pointer is returned which can be used
with <function>fbsql_field_flags</function>,
<function>fbsql_field_len</function>,
<function>fbsql_field_name</function>, and
<function>fbsql_field_type</function>.
</para>
<para>
A result identifier is a positive integer. The function returns
-1 if a error occurs. A string describing the error will be
placed in <literal>$phperrmsg</literal>, and unless the function
was called as <literal>@fbsql()</literal> then this error string
will also be printed out.
</para>
<para>
<example>
<title><function>fbsql_list_fields</function> example</title>
<programlisting role="php">
<![CDATA[
$link = fbsql_connect('localhost', 'myname', 'secret');
$fields = fbsql_list_fields("database1", "table1", $link);
$columns = fbsql_num_fields($fields);
for ($i = 0; $i < $columns; $i++) {
echo fbsql_field_name($fields, $i) . "\n";;
}
]]>
</programlisting>
</example>
</para>
<para>
The above example would produce the following output:
<informalexample>
<programlisting>
<![CDATA[
field1
field2
field3
..
]]>
</programlisting>
</informalexample>
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-list-tables">
<refnamediv>
<refname>fbsql_list_tables</refname>
<refpurpose>List tables in a FrontBase database</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>resource</type><methodname>fbsql_list_tables</methodname>
<methodparam><type>string</type><parameter>database</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_list_tables</function> takes a database name and
returns a result pointer much like the
<function>fbsql_db_query</function> function. The
<function>fbsql_tablename</function> function should be used to
extract the actual table names from the result pointer.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-next-result">
<refnamediv>
<refname>fbsql_next_result</refname>
<refpurpose>
Move the internal result pointer to the next result
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_next_result</methodname>
<methodparam><type>int</type><parameter>result_id</parameter></methodparam>
</methodsynopsis>
<para>
When sending more than one SQL statement to the server or
executing a stored procedure with multiple results will cause the
server to return multiple result sets. This function will test
for additional results available form the server. If an
additional result set exists it will free the existing result set
and prepare to fetch the words from the new result set. The
function will return &true; if an additional result set was
available or &false; otherwise.
</para>
<example>
<title><function>fbsql_next_result</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_connect ("localhost", "_SYSTEM", "secret");
fbsql_select_db("MyDB", $link);
$SQL = "Select * from table1; select * from table2;";
$rs = fbsql_query($SQL, $link);
do {
while ($row = fbsql_fetch_row($rs)) {
}
} while (fbsql_next_result($rs));
fbsql_free_result($rs);
fbsql_close ($link);
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<refentry id="function.fbsql-num-fields">
<refnamediv>
<refname>fbsql_num_fields</refname>
<refpurpose>Get number of fields in result</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>int</type><methodname>fbsql_num_fields</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_num_fields</function> returns the number of
fields in a result set.
</para>
<para>
See also:
<function>fbsql_db_query</function>,
<function>fbsql_query</function>,
<function>fbsql_fetch_field</function>, and
<function>fbsql_num_rows</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-num-rows">
<refnamediv>
<refname>fbsql_num_rows</refname>
<refpurpose>Get number of rows in result</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>int</type><methodname>fbsql_num_rows</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_num_rows</function> returns the number of rows in
a result set. This command is only valid for SELECT statements.
To retrieve the number of rows returned from a INSERT, UPDATE or
DELETE query, use <function>fbsql_affected_rows</function>.
<example>
<title><function>fbsql_num_rows</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_connect("localhost", "username", "password");
fbsql_select_db("database", $link);
$result = fbsql_query("SELECT * FROM table1;", $link);
$num_rows = fbsql_num_rows($result);
echo "$num_rows Rows\n";
?>
]]>
</programlisting>
</example>
</para>
<para>
See also: <function>fbsql_affected_rows</function>,
<function>fbsql_connect</function>,
<function>fbsql_select_db</function>, and
<function>fbsql_query</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-pconnect">
<refnamediv>
<refname>fbsql_pconnect</refname>
<refpurpose>
Open a persistent connection to a FrontBase Server
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>resource</type><methodname>fbsql_pconnect</methodname>
<methodparam
choice="opt"><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam
choice="opt"><type>string</type><parameter>username</parameter></methodparam>
<methodparam
choice="opt"><type>string</type><parameter>password</parameter></methodparam>
</methodsynopsis>
<para>
Returns: A positive FrontBase persistent link identifier on
success, or &false; on error.
</para>
<para>
<function>fbsql_pconnect</function> establishes a connection
to a FrontBase server. The following defaults are assumed for
missing optional parameters: <parameter>host</parameter> =
'localhost', <parameter>username</parameter> = "_SYSTEM"
and <parameter>password</parameter> = empty password.
</para>
<para>
<function>fbsql_pconnect</function> acts very much like
<function>fbsql_connect</function> with two major differences.
</para>
<para>
To set Frontbase server port number, use
<function>fbsql_select_db</function>.
</para>
<para>
First, when connecting, the function would first try to find a
(persistent) link that's already open with the same host,
username and password. If one is found, an identifier for it
will be returned instead of opening a new connection.
</para>
<para>
Second, the connection to the SQL server will not be closed when
the execution of the script ends. Instead, the link will remain
open for future use.
</para>
<para>
This type of links is therefore called 'persistent'.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-query">
<refnamediv>
<refname>fbsql_query</refname>
<refpurpose>Send a FrontBase query</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>resource</type><methodname>fbsql_query</methodname>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam
choice="opt"><type>resource</type><parameter>link_identifier</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_query</function> sends a query to the currently
active database on the server that's associated with the
specified link identifier. If
<parameter>link_identifier</parameter> isn't specified, the last
opened link is assumed. If no link is open, the function tries
to establish a link as if <function>fbsql_connect</function> was
called with no arguments, and use it.
</para>
<note>
<para>
The query string shall always end with a semicolon.
</para>
</note>
<para>
<function>fbsql_query</function> returns &true; (non-zero) or &false;
to indicate whether or not the query succeeded. A return value
of &true; means that the query was legal and could be executed by
the server. It does not indicate anything about the number of
rows affected or returned. It is perfectly possible for a query
to succeed but affect no rows or return no rows.
</para>
<para>
The following query is syntactically invalid, so
<function>fbsql_query</function> fails and returns &false;:
<example>
<title><function>fbsql_query</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$result = fbsql_query ("SELECT * WHERE 1=1")
or die ("Invalid query");
?>
]]>
</programlisting>
</example>
</para>
<para>
The following query is semantically invalid if
<literal>my_col</literal> is not a column in the table
<literal>my_tbl</literal>, so <function>fbsql_query</function>
fails and returns &false;:
<example>
<title><function>fbsql_query</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$result = fbsql_query ("SELECT my_col FROM my_tbl")
or die ("Invalid query");
?>
]]>
</programlisting>
</example>
</para>
<para>
<function>fbsql_query</function> will also fail and return
&false; if you don't have permission to access the table(s)
referenced by the query.
</para>
<para>
Assuming the query succeeds, you can call
<function>fbsql_num_rows</function> to find out how many rows
were returned for a SELECT statement or
<function>fbsql_affected_rows</function> to find out how many
rows were affected by a DELETE, INSERT, REPLACE, or UPDATE
statement.
</para>
<para>
For SELECT statements, <function>fbsql_query</function> returns a
new result identifier that you can pass to
<function>fbsql_result</function>. When you are done with the
result set, you can free the resources associated with it by
calling <function>fbsql_free_result</function>. Although, the
memory will automatically be freed at the end of the script's
execution.
</para>
<para>
See also: <function>fbsql_affected_rows</function>,
<function>fbsql_db_query</function>,
<function>fbsql_free_result</function>,
<function>fbsql_result</function>,
<function>fbsql_select_db</function>, and
<function>fbsql_connect</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-read-blob">
<refnamediv>
<refname>fbsql_read_blob</refname>
<refpurpose>Read a BLOB from the database</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_read_blob</methodname>
<methodparam><type>string</type><parameter>blob_handle</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Returns: A string containing the BLOB specified by blob_handle.
</para>
<para>
<function>fbsql_read_blob</function> reads BLOB data from the
database. If a select statement contains BLOB and/or BLOB
columns FrontBase will return the data directly when data is
fetched. This default behavior can be changed with
<function>fbsql_set_lob_mode</function> so the fetch functions
will return handles to BLOB and CLOB data. If a handle is
fetched a user must call <function>fbsql_read_blob</function> to
get the actual BLOB data from the database.
</para>
<example>
<title><function>fbsql_read_blob</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
or die ("Could not connect");
$sql = "SELECT BLOB_COLUMN FROM BLOB_TABLE;";
$rs = fbsql_query($sql, $link);
$row_data = fbsql_fetch_row($rs);
// $row_data[0] will now contain the blob data for teh first row
fbsql_free_result($rs);
$rs = fbsql_query($sql, $link);
fbsql_set_lob_mode($rs, FBSQL_LOB_HANDLE);
$row_data = fbsql_fetch_row($rs);
// $row_data[0] will now contain a handle to the BLOB data in the first row
$blob_data = fbsql_read_blob($row_data[0]);
fbsql_free_result($rs);
?>
]]>
</programlisting>
</example>
<para>
See also: <function>fbsql_create_blob</function>,
<function>fbsql_read_blob</function>,
<function>fbsql_read_clob</function>, and
<function>fbsql_set_lob_mode</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-read-clob">
<refnamediv>
<refname>fbsql_read_clob</refname>
<refpurpose>Read a CLOB from the database</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_read_clob</methodname>
<methodparam><type>string</type><parameter>clob_handle</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Returns: A string containing the CLOB specified by clob_handle.
</para>
<para>
<function>fbsql_read_clob</function> reads CLOB data from the
database. If a select statement contains BLOB and/or CLOB
columns FrontBase will return the data directly when data is
fetched. This default behavior can be changed with
<function>fbsql_set_lob_mode</function> so the fetch functions
will return handles to BLOB and CLOB data. If a handle is
fetched a user must call <function>fbsql_read_clob</function> to
get the actual CLOB data from the database.
</para>
<example>
<title><function>fbsql_read_clob</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
or die ("Could not connect");
$sql = "SELECT CLOB_COLUMN FROM CLOB_TABLE;";
$rs = fbsql_query($sql, $link);
$row_data = fbsql_fetch_row($rs);
// $row_data[0] will now contain the clob data for teh first row
fbsql_free_result($rs);
$rs = fbsql_query($sql, $link);
fbsql_set_lob_mode($rs, FBSQL_LOB_HANDLE);
$row_data = fbsql_fetch_row($rs);
// $row_data[0] will now contain a handle to the CLOB data in the first row
$clob_data = fbsql_read_clob($row_data[0]);
fbsql_free_result($rs);
?>
]]>
</programlisting>
</example>
<para>
See also: <function>fbsql_create_blob</function>,
<function>fbsql_read_blob</function>,
<function>fbsql_read_clob</function>, and
<function>fbsql_set_lob_mode</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-result">
<refnamediv>
<refname>fbsql_result</refname>
<refpurpose>Get result data</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>mixed</type><methodname>fbsql_result</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>int</type><parameter>row</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>
field
</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_result</function> returns the contents of one
cell from a FrontBase result set. The field argument can be the
field's offset, or the field's name, or the field's table dot
field's name (tabledname.fieldname). If the column name has been
aliased ('select foo as bar from...'), use the alias instead of
the column name.
</para>
<para>
When working on large result sets, you should consider using one
of the functions that fetch an entire row (specified below). As
these functions return the contents of multiple cells in one
function call, they're MUCH quicker than
<function>fbsql_result</function>. Also, note that specifying a
numeric offset for the field argument is much quicker than
specifying a fieldname or tablename.fieldname argument.
</para>
<para>
Calls to <function>fbsql_result</function> should not be mixed
with calls to other functions that deal with the result set.
</para>
<para>
Recommended high-performance alternatives:
<function>fbsql_fetch_row</function>,
<function>fbsql_fetch_array</function>, and
<function>fbsql_fetch_object</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-rollback">
<refnamediv>
<refname>fbsql_rollback</refname>
<refpurpose>Rollback a transaction to the database</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_rollback</methodname>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Returns: &true; on success, &false; on failure.
</para>
<para>
<function>fbsql_rollback</function> ends the current transaction by
rolling back all statements issued since last commit.
This command is only needed if autocommit is set to false.
</para>
<para> See also:
<function>fbsql_autocommit</function> and
<function>fbsql_commit</function>
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-set-lob-mode">
<refnamediv>
<refname>fbsql_set_lob_mode</refname>
<refpurpose>
Set the LOB retrieve mode for a FrontBase result set
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_set_lob_mode</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>string</type><parameter>database_name</parameter></methodparam>
</methodsynopsis>
<para>
Returns: &true; on success, &false; on error.
</para>
<para>
<function>fbsql_set_lob_mode</function> sets the mode for
retrieving LOB data from the database. When BLOB and CLOB data is
stored in FrontBase it can be stored direct or indirect. Direct
stored LOB data will always be fetched no matter the setting of
the lob mode. If the LOB data is less than 512 bytes it will
always be stored directly.
<itemizedlist>
<listitem>
<simpara>
FBSQL_LOB_DIRECT - LOB data is retrieved directly. When data
is fetched from the database with
<function>fbsql_fetch_row</function>, and other fetch
functions, all CLOB and BLOB columns will be returned as
ordinary columns. This is the default value on a new
FrontBase result.
</simpara>
</listitem>
<listitem>
<simpara>
FBSQL_LOB_HANDLE - LOB data is retrieved as handles to the
data. When data is fetched from the database with
<function>fbsql_fetch_row </function>, and other fetch
functions, LOB data will be returned as a handle to the data
if the data is stored indirect or the data if it is stored
direct. If a handle is returned it will be a 27 byte string
formatted as "@'000000000000000000000000'".
</simpara>
</listitem>
</itemizedlist>
</para>
<para> See also:
<function>fbsql_create_blob</function>,
<function>fbsql_create_clob</function>,
<function>fbsql_read_blob</function>, and
<function>fbsql_read_clob</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-select-db">
<refnamediv>
<refname>fbsql_select_db</refname>
<refpurpose>Select a FrontBase database</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_select_db</methodname>
<methodparam><type>string</type><parameter>database_name</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Returns: &true; on success, &false; on error.
</para>
<para>
<function>fbsql_select_db</function> sets the current active
database on the server that's associated with the specified link
identifier. If no link identifier is specified, the last opened
link is assumed. If no link is open, the function will try to
establish a link as if <function>fbsql_connect</function> was
called, and use it.
</para>
<para>
The client contacts FBExec to obtain the port number to use for
the connection to the database. If the database name is a number
the system will use that as a port number and it will not ask
FBExec for the port number. The FrontBase server can be stared
as FRontBase -FBExec=No -port=<port number> <database
name>.
</para>
<para>
Every subsequent call to <function>fbsql_query</function> will be
made on the active database.
</para>
<para>
if the database is protected with a database password, the user must
call <function>fbsql_database_password</function> before selecting
the database.
</para>
<para> See also:
<function>fbsql_connect</function>,
<function>fbsql_pconnect</function>,
<function>fbsql_database_password</function> and
<function>fbsql_query</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-start-db">
<refnamediv>
<refname>fbsql_start_db</refname>
<refpurpose>Start a database on local or remote server</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_start_db</methodname>
<methodparam><type>string</type><parameter>database_name</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Returns: &true; on success, &false; on failure.
</para>
<para>
<function>fbsql_start_db</function>
</para>
<para>
See also: <function>fbsql_db_status</function> and
<function>fbsql_stop_db</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-stop-db">
<refnamediv>
<refname>fbsql_stop_db</refname>
<refpurpose>Stop a database on local or remote server</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_stop_db</methodname>
<methodparam><type>string</type><parameter>database_name</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>
link_identifier
</parameter></methodparam>
</methodsynopsis>
<para>
Returns: &true; on success, &false; on failure.
</para>
<para>
<function>fbsql_stop_db</function>
</para>
<para>
See also: <function>fbsql_db_status</function> and
<function>fbsql_start_db</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-tablename">
<refnamediv>
<refname>fbsql_tablename</refname>
<refpurpose>Get table name of field</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_tablename</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>int</type><parameter>i</parameter></methodparam>
</methodsynopsis>
<para>
<function>fbsql_tablename</function> takes a result pointer
returned by the <function>fbsql_list_tables</function> function
as well as an integer index and returns the name of a table. The
<function>fbsql_num_rows</function> function may be used to
determine the number of tables in the result pointer.
<example>
<title><function>fbsql_tablename</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
fbsql_connect ("localhost", "_SYSTEM", "");
$result = fbsql_list_tables ("wisconsin");
$i = 0;
while ($i < fbsql_num_rows ($result)) {
$tb_names[$i] = fbsql_tablename ($result, $i);
echo $tb_names[$i] . "<BR>";
$i++;
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.fbsql-warnings">
<refnamediv>
<refname>fbsql_warnings</refname>
<refpurpose>Enable or disable FrontBase warnings</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>bool</type><methodname>fbsql_warnings</methodname>
<methodparam choice="opt"><type>bool</type><parameter>
OnOff
</parameter></methodparam>
</methodsynopsis>
<para>
Returns &true; if warnings is turned on otherwise &false;.
</para>
<para>
<function>fbsql_warnings</function> enables or disables FrontBase
warnings.
</para>
</refsect1>
</refentry>
<refentry id='function.fbsql-database'>
<refnamediv>
<refname>fbsql_database</refname>
<refpurpose>Get or set the database name used with a connection</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_database</methodname>
<methodparam><type>resource</type><parameter>link_identifier</parameter></methodparam>
<methodparam
choice="opt"><type>string</type><parameter>database</parameter></methodparam>
</methodsynopsis>
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id='function.fbsql-get-autostart-info'>
<refnamediv>
<refname>fbsql_get_autostart_info</refname>
<refpurpose>No Descrizione given yet</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>array</type><methodname>fbsql_get_autostart_info</methodname>
<methodparam
choice="opt"><type>resource</type><parameter>link_identifier</parameter></methodparam>
</methodsynopsis>
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id='function.fbsql-hostname'>
<refnamediv>
<refname>fbsql_hostname</refname>
<refpurpose>Get or set the host name used with a connection</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_hostname</methodname>
<methodparam><type>resource</type><parameter>link_identifier</parameter></methodparam>
<methodparam
choice="opt"><type>string</type><parameter>host_name</parameter></methodparam>
</methodsynopsis>
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id='function.fbsql-password'>
<refnamediv>
<refname>fbsql_password</refname>
<refpurpose>Get or set the user password used with a connection</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_password</methodname>
<methodparam><type>resource</type><parameter>link_identifier</parameter></methodparam>
<methodparam
choice="opt"><type>string</type><parameter>password</parameter></methodparam>
</methodsynopsis>
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id='function.fbsql-set-transaction'>
<refnamediv>
<refname>fbsql_set_transaction</refname>
<refpurpose>
Set the transaction locking and isolation
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>void</type><methodname>fbsql_set_transaction</methodname>
<methodparam><type>resource</type><parameter>link_identifier</parameter></methodparam>
<methodparam><type>int</type><parameter>Locking</parameter></methodparam>
<methodparam><type>int</type><parameter>Isolation</parameter></methodparam>
</methodsynopsis>
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id='function.fbsql-username'>
<refnamediv>
<refname>fbsql_username</refname>
<refpurpose>Get or set the host user used with a connection</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fbsql_username</methodname>
<methodparam><type>resource</type><parameter>link_identifier</parameter></methodparam>
<methodparam
choice="opt"><type>string</type><parameter>username</parameter></methodparam>
</methodsynopsis>
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->