2003-12-27 21:45:50 +00:00
|
|
|
--TEST--
|
|
|
|
sqlite-oo: call method with $this
|
2004-01-18 19:55:50 +00:00
|
|
|
--SKIPIF--
|
|
|
|
<?php # vim:ft=php
|
|
|
|
if (!extension_loaded("sqlite")) print "skip";
|
|
|
|
?>
|
2003-12-27 21:45:50 +00:00
|
|
|
--FILE--
|
2004-01-08 16:55:37 +00:00
|
|
|
<?php
|
2003-12-27 21:45:50 +00:00
|
|
|
include "blankdb_oo.inc";
|
|
|
|
|
|
|
|
$db->query("CREATE TABLE strings(key VARCHAR(10), var VARCHAR(10))");
|
|
|
|
$db->query("INSERT INTO strings VALUES('foo', 'foo')");
|
|
|
|
|
|
|
|
class sqlite_help
|
|
|
|
{
|
2004-03-26 21:16:50 +00:00
|
|
|
function __construct($db){
|
2003-12-27 21:45:50 +00:00
|
|
|
$this->db = $db;
|
2004-03-26 21:16:50 +00:00
|
|
|
$this->db->createFunction('link_keywords', array(&$this, 'linkers'), 1);
|
2003-12-27 21:45:50 +00:00
|
|
|
}
|
|
|
|
|
2004-03-26 21:16:50 +00:00
|
|
|
function getSingle($key)
|
2003-12-27 21:45:50 +00:00
|
|
|
{
|
2004-03-26 21:16:50 +00:00
|
|
|
return $this->db->singleQuery('SELECT link_keywords(var) FROM strings WHERE key=\''.$key.'\'', 1);
|
2003-12-27 21:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function linkers($str)
|
|
|
|
{
|
|
|
|
$str = str_replace('foo', 'bar', $str);
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
function free()
|
|
|
|
{
|
|
|
|
unset($this->db);
|
|
|
|
}
|
2004-01-08 16:55:37 +00:00
|
|
|
|
2003-12-27 21:45:50 +00:00
|
|
|
function __destruct()
|
|
|
|
{
|
|
|
|
echo "DESTRUCTED\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$obj = new sqlite_help($db);
|
2004-03-26 21:16:50 +00:00
|
|
|
echo $obj->getSingle('foo')."\n";
|
2003-12-27 21:45:50 +00:00
|
|
|
$obj->free();
|
|
|
|
unset($obj);
|
|
|
|
|
|
|
|
?>
|
|
|
|
===DONE===
|
|
|
|
--EXPECT--
|
|
|
|
bar
|
|
|
|
===DONE===
|
2004-01-08 16:55:37 +00:00
|
|
|
DESTRUCTED
|