[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] =?utf-8?q?svn:_/phpdoc/en/trunk/reference/sqlite3/sqlite3/_openblob.xml?=
From:       Christoph_Michael_Becker <cmb () php ! net>
Date:       2017-06-19 13:26:22
Message-ID: svn-cmb-1497878782-342606-1624969611 () svn ! php ! net
[Download RAW message or body]

cmb                                      Mon, 19 Jun 2017 13:26:22 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=342606

Log:
Document writing of BLOBs (as of PHP 7.2.0)

Cf. <https://github.com/php/php-src/pull/2528>.

Changed paths:
    U   phpdoc/en/trunk/reference/sqlite3/sqlite3/openblob.xml

Modified: phpdoc/en/trunk/reference/sqlite3/sqlite3/openblob.xml
===================================================================
--- phpdoc/en/trunk/reference/sqlite3/sqlite3/openblob.xml	2017-06-19 11:45:50 UTC \
                (rev 342605)
+++ phpdoc/en/trunk/reference/sqlite3/sqlite3/openblob.xml	2017-06-19 13:26:22 UTC \
(rev 342606) @@ -15,13 +15,21 @@
    <methodparam><type>string</type><parameter>column</parameter></methodparam>
    <methodparam><type>int</type><parameter>rowid</parameter></methodparam>
    <methodparam choice="opt"><type>string</type><parameter>dbname</parameter><initializer>"main"</initializer></methodparam>
 +   <methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>SQLITE_OPEN_READONLY</initializer></methodparam>
  </methodsynopsis>
   <para>
-   Opens a stream resource to read a BLOB, which would be selected by:
+   Opens a stream resource to read or write a BLOB, which would be selected by:
   </para>
   <para>
    SELECT <parameter>column</parameter> FROM \
<parameter>dbname</parameter>.<parameter>table</parameter> WHERE rowid = \
<parameter>rowid</parameter>  </para>
+  <note>
+   <simpara>
+    It is not possible to change the size of a BLOB by writing to the stream.
+    Instead, an UPDATE statement has to be executed, possibly using SQLite's
+    zeroblob() function to set the desired BLOB size.
+   </simpara>
+  </note>
  </refsect1>

  <refsect1 role="parameters">
@@ -60,6 +68,15 @@
       </para>
      </listitem>
     </varlistentry>
+    <varlistentry>
+     <term><parameter>flags</parameter></term>
+     <listitem>
+      <para>
+       Either SQLITE_OPEN_READONLY or SQLITE_OPEN_READWRITE to open the stream
+       for reading only, or for reading and writing, respectively.
+      </para>
+     </listitem>
+    </varlistentry>
    </variablelist>
   </para>

@@ -72,6 +89,29 @@
   </para>
  </refsect1>

+ <refsect1 role="changelog">
+  &reftitle.changelog;
+  <informaltable>
+   <tgroup cols="2">
+    <thead>
+     <row>
+      <entry>&Version;</entry>
+      <entry>&Description;</entry>
+     </row>
+    </thead>
+    <tbody>
+     <row>
+      <entry>7.2.0</entry>
+      <entry>
+       The <parameter>flags</parameter> parameter has been added, allowing to
+       write BLOBs; formerly only reading was supported.
+      </entry>
+     </row>
+    </tbody>
+   </tgroup>
+  </informaltable>
+ </refsect1>
+
  <refsect1 role="examples">
   &reftitle.examples;
   <para>
@@ -98,6 +138,35 @@
     </screen>
    </example>
   </para>
+  <para>
+   <example>
+    <title>Incrementally writing a BLOB</title>
+    <programlisting role="php">
+<![CDATA[
+<?php
+$conn = new SQLite3(':memory:');
+$conn->exec('CREATE TABLE test (text text)');
+$conn->exec("INSERT INTO test VALUES (zeroblob(36))");
+$stream = $conn->openBlob('test', 'text', 1, 'main', SQLITE3_OPEN_READWRITE);
+for ($i = 0; $i < 3; $i++) {
+    fwrite($stream,  "Lorem ipsum\n");
+}
+fclose($stream);
+echo $conn->querySingle("SELECT text FROM test");
+$conn->close();
+?>
+]]>
+    </programlisting>
+    &example.outputs;
+    <screen>
+<![CDATA[
+Lorem ipsum
+Lorem ipsum
+Lorem ipsum
+]]>
+    </screen>
+   </example>
+  </para>
  </refsect1>

 </refentry>



-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic