Re: [RFC] Enable authorizer-feature in PDO_SQLITE

From: Date: Thu, 14 Dec 2006 01:15:21 +0000
Subject: Re: [RFC] Enable authorizer-feature in PDO_SQLITE
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-26946@lists.php.net to get a copy of this message
Hi Mario, Sorry that I didn't get back to you--I often get too busy to follow up on PHP related mail so you need to poke. I'm currently doing some work on PDO and so I'll look at integrating your patch this week; if I don't spot any problems, I'll commit it, otherwise I'll get back to you to discuss it. Thanks for putting in the effort! --Wez. On 12/11/06, Mario Wolff <wolfshoehle@googlemail.com> wrote:
Any suggestions or meanings on it? Thanks, Mario Short test script: <?php $data = array( 'one', 'two', 'three', 'four', 'five', 'six'); $db = new PDO( 'sqlite::memory:'); echo "register authorizer\n"; $db->sqliteSetAuthorizer('auth'); $db->exec( "CREATE TABLE strings( a)"); $insert = $db->prepare( 'INSERT INTO strings VALUES ( ?)'); foreach ( $data as $str) {
      $insert->execute( array( $str));
} $insert = null; if( $delete = $db->prepare( 'DELETE FROM strings where a=?')){ if( $delete->execute(array( "six" ))){
       echo "delete done!\n";
} $delete = null; }else{ echo "delete not prepared\n"; } echo "unregister authorizer\n"; $db->sqliteSetAuthorizer(); if( $delete = $db->prepare( 'DELETE FROM strings where a=?')){ if( $delete->execute(array( "six" ))){
       echo "delete done!\n";
} $delete = null; }else{ echo "delete not prepared\n"; } function auth($type,$arga,$argb,$argc,$argd ){ echo "$type\t$arga\t$argb\t$argc\t$argd\n"; if( $type==SQLITE_DELETE ){
       return SQLITE_DENY;
} return SQLITE_OK; } print_r( $db->query( 'SELECT sqlite_version( *);')->fetchAll( )); print_r( $db->query( 'SELECT * from strings;')->fetchAll( )); ?> gives: register authorizer
18      sqlite_master           main
2       strings         main
23      sqlite_master   type    main
23      sqlite_master   name    main
23      sqlite_master   tbl_name        main
23      sqlite_master   rootpage        main
23      sqlite_master   sql     main
20      sqlite_master   ROWID   main
20      sqlite_master   name    main
20      sqlite_master   rootpage        main
20      sqlite_master   sql     main
20      sqlite_master   tbl_name        main
18      strings         main
9       strings         main
delete not prepared unregister authorizer delete done! Array ( [0] => Array
       (
           [sqlite_version( *)] => 3.3.7
           [0] => 3.3.7
       )
) Array ( [0] => Array
       (
           [a] => one
           [0] => one
       )
[1] => Array
       (
           [a] => two
           [0] => two
       )
[2] => Array
       (
           [a] => three
           [0] => three
       )
[3] => Array
       (
           [a] => four
           [0] => four
       )
[4] => Array
       (
           [a] => five
           [0] => five
       )
) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#26946) next »