Annotation of embedaddon/php/ext/sqlite/tests/sqlite_oo_029.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: sqlite-oo: call method with $this
                      3: --SKIPIF--
                      4: <?php # vim:ft=php
                      5: if (!extension_loaded("sqlite")) print "skip"; 
                      6: ?>
                      7: --FILE--
                      8: <?php
                      9: include "blankdb_oo.inc";
                     10: 
                     11: $db->query("CREATE TABLE strings(key VARCHAR(10), var VARCHAR(10))");
                     12: $db->query("INSERT INTO strings VALUES('foo', 'foo')");
                     13: 
                     14: class sqlite_help
                     15: {
                     16:        function __construct($db){
                     17:                $this->db = $db;
                     18:                $this->db->createFunction('link_keywords', array(&$this, 'linkers'), 1);
                     19:        }
                     20: 
                     21:        function getSingle($key)
                     22:        {
                     23:                return $this->db->singleQuery('SELECT link_keywords(var) FROM strings WHERE key=\''.$key.'\'', 1);
                     24:        }
                     25: 
                     26:        function linkers($str)
                     27:        {
                     28:                $str = str_replace('foo', 'bar', $str);
                     29:                return $str;
                     30:        }
                     31: 
                     32:        function free()
                     33:        {
                     34:                unset($this->db);
                     35:        }
                     36: 
                     37:        function __destruct()
                     38:        {
                     39:                echo "DESTRUCTED\n";
                     40:        }
                     41: }
                     42: 
                     43: $obj = new sqlite_help($db);
                     44: echo $obj->getSingle('foo')."\n";
                     45: $obj->free();
                     46: unset($obj);
                     47: 
                     48: ?>
                     49: ===DONE===
                     50: --EXPECT--
                     51: bar
                     52: ===DONE===
                     53: DESTRUCTED

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>