Ok, you we're right!!

The trigger fires a PHP function that connects back to de database and, in
that connection I didn't register the php functions. Just in case someone
runs in the same problem, this is a strange situation, because the function
exists for PHP, but no for SQLite. So, the first time you have check if the
php function exist with a code like this

    if (!function_exists(test))
    {

        include_once("/var/www/arduino/sqlite_functions.php");
    }

and, after that, always register to SQLite.
       $dbh->sqliteCreateFunction('Test','Test');


But, now, I'run into another problem (don't know if it's better to open
another thread)

As I said, the trigger fires a PHP script that connects back to the
database, and tries to update another row in the same table, and, when it
executes the update statement, it gets frozen. In some cases, I get the
"Database lock"  error,

I don't really think this is a deadlock, as far as I'm not writing to the
same row and the trigger is configured as "after update", so the row shoul
be released by the time trigger is fired, but I rather think that SQLite
considers this new connection as completely new and it's blocking the whole
database.

Do you think that this can be avoided somehow?

Thx in advance
Chano

2009/8/29 Kees Nuyt <k.n...@zonnet.nl>

> On Fri, 28 Aug 2009 19:50:56 +0200, Alejandro Ruiz-Oriol
> <aruiz...@itelsys.com> wrote:
>
> >Thank's Swithun
> >
> >but I still have trouble.
> >
> >Ok, I find out how to register functions with
> >PDO_Sqlite extensions. Just in case someone
> >is in the same situation, the way to do it is this:
> >
> >$dbh = new PDO('sqlite:/whatever.sqlite');
> >$dbh->sqliteCreateFunction('Test','Test');
> >
> >But I still have a problem:
> >
> >If I use direct the test funcion in a quuery like
> >
> >$res=$dbh->query("select test() from table");
> >
> >it works, but if function test is invoked from a triiger it will say, my
> >sentence will be somethin like
> >
> >$modulo=$dbh->query("UPDATE test SET x = 1");
> >
> >I get this:
> >
> >    [0] => HY000
> >    [1] => 1
> >    [2] => no such function: Test
> >
> >seems like the trigger is not using the same "$dbh"
> >
> >¿any clue?
>
> Are you sure the function is registered on the $dbh with
> $dbh->sqliteCreateFunction(...);
> on the $dbh in which the trigger fires?
>
> You have to do that in every script that instantiates the
> object.
>
> >Thx
> --
>  (  Kees Nuyt
>  )
> c[_]
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to