[RFC] Enable authorizer-feature in PDO_SQLITE

From: Date: Mon, 11 Dec 2006 10:29:23 +0000
Subject: [RFC] Enable authorizer-feature in PDO_SQLITE
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-26899@lists.php.net to get a copy of this message
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
      )
)

Attachment: [text/x-patch] pdo_sqlite.diff
« previous php.internals (#26899) next »