• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • dba_insert()

    (PHP 4, PHP 5, PHP 7)

    Insert entry

    说明

    dba_insert(string $key,string $value,resource $handle): bool

    dba_insert() inserts the entry described with$keyand$valueinto the database.

    参数

    $key

    The key of the entry to be inserted. If this key already exist in the database, this function will fail. Use dba_replace() if you need to replace an existent key.

    $value

    The value to be inserted.

    $handle

    The database handler, returned by dba_open() or dba_popen().

    返回值

    成功时返回TRUE,或者在失败时返回FALSE

    参见

    berkeleydb example.
    <?php
      # DB4 CREATE & INSERT
      $_FILE  = "/DATA_DIR/TEST_DATA.DB";
      $DIV   = "\xFE";
      $inValue = "name".$DIV."0".$DIV."test value";
      $dbh  = dba_open($_FILE,"c","db4");
      dba_close($dbh);
      $dbh  = dba_open($_FILE,"w","db4");
      dba_insert(1,$inValue,$dbh);
      dba_close($dbh);
    ?>
    
    here is a good example for this;
     $dbh = dba_open( "./data/products", "c", "gdbm" ) 
        or die( "Couldn't open database" );
     
     dba_insert( "Sonic Screwdriver", "23.20", $dbh);
     dba_insert( "Tricorder", "55.50", $dbh);
     dba_insert( "ORAC AI", "2200.50", $dbh);
     dba_insert( "HAL 2000", "4500.50", $dbh);
     
     dba_close( $dbh );
     you may find more about the topic in this URL:
    http://www.samspublishing.com /articles/article.asp?p=29742&seqNum=3&rl=1

    上篇:dba_handlers()

    下篇:dba_key_split()