简体   繁体   中英

How to make an pdo_sqlite connection from binary stream in PHP

Having a .sqlite file in a memory stream (php://memory), I want to pipe it to pdo_sqlite driver to create a connection. Is this possible?

Its for testing purposes, I want to recreate DBs quickly without recreate schema at each time nor using tmpfs.

In memory sqlite has some limitations. The memory space could be the request, the session, but no way seems documented to share a base in memory among users.

For a request, open your base with the code

$pdo = new PDO( 'sqlite::memory:'); 

and your base will disapear on next request.

For session persistency

<?php 
$pdo = new PDO( 
    'sqlite::memory:', 
    null, 
    null, 
    array(PDO::ATTR_PERSISTENT => true) 
); 
?>

Also read manual

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM