PHP pthreads和SQLite3 更新
我发现这不是SQLite问题。PHP pthreads和SQLite3 更新,php,pthreads,Php,Pthreads,我发现这不是SQLite问题。 看看这个 代码1 代码2 并且启用了php线程安全。(来自phpinfo) 这是php故障吗 起初的 我在php中使用SQLITE3时遇到了一些线程问题。 代码很简单 <?php class Test { protected $db; public function __construct() { $this->db = new SQLite3(__DIR__.'/test.db'); echo
看看这个 代码1 代码2 并且启用了php线程安全。(来自phpinfo)
这是php故障吗 起初的 我在php中使用SQLITE3时遇到了一些线程问题。
代码很简单
<?php
class Test
{
protected $db;
public function __construct()
{
$this->db = new SQLite3(__DIR__.'/test.db');
echo $this->db->lastErrorCode().PHP_EOL;
}
}
$test = new Test();
输出:
PHP警告:SQLite3::lastErrorCode():第8行的/home/ordinaryparksee/Projects/human/test.PHP中的SQLite3对象未正确初始化
警告:SQLite3::lastErrorCode():第8行的/home/ordinaryparksee/Projects/human/test.php中的SQLite3对象未正确初始化
有什么问题吗???来自:
在介绍页的手册中,说明了任何对象
意图被多个上下文操纵的应扩展
可堆叠,线程或工人,如
不是我的领域,但我想线程
需要更多的关注,就像你需要实现的方法一样?你的sqlite3是用enabled构建的吗?亲爱的@mario。是,我使用选项--启用线程安全重新构建sqlite3。当make脚本编译完成时,我检查了-DSQLITE\u THREADSAFE=1
。但它仍然不起作用。
changed text
<?php
class Test extends Thread // Difference
{
protected $member;
public function __construct($member = null)
{
$this->member = $member;
$this->member->text = 'changed text';
}
}
class Text
{
public $text = 'this is text';
}
$text = new Text();
$test = new Test($text);
echo $text->text.PHP_EOL;
this is text
<?php
class Test
{
protected $db;
public function __construct()
{
$this->db = new SQLite3(__DIR__.'/test.db');
echo $this->db->lastErrorCode().PHP_EOL;
}
}
$test = new Test();
<?php
class Test extends Thread
{
protected $db;
public function __construct()
{
$this->db = new SQLite3(__DIR__.'/test.db');
echo $this->db->lastErrorCode().PHP_EOL;
}
}
$test = new Test();
<?php
class Test extends Thread // Difference
{
protected $member;
public function __construct($member = null)
{
$this->member = $member;
$this->member->text = 'changed text';
}
}
class Text extends Threaded // Difference2
{
public $text = 'this is text';
}
$text = new Text();
$test = new Test($text);
echo $text->text.PHP_EOL;