phpday 2027 - Call for Papers

dbase_create

(PHP 5 < 5.3.0, dbase 5, dbase 7)

dbase_create — Crea un database

Descrizione

function dbase_create(string $path, array $fields, int $type = DBASE_TYPE_DBASE): resource

dbase_create() crea un database dBase con la definizione indicata. Se il file esiste già, non viene troncato. È possibile chiamare dbase_pack() per forzarne il troncamento.

Nota:

Questa funzione è influenzata da open_basedir.

Elenco dei parametri

path

Il percorso del database. Può essere un percorso relativo o assoluto del file in cui dBase memorizzerà i dati.

fields

Un array di array, ognuno dei quali descrive il formato di un campo del database. Ogni campo è composto da un nome, un carattere che indica il tipo del campo e, facoltativamente, una lunghezza, una precisione e un flag nullable. I tipi di campo supportati sono elencati nella sezione introduttiva.

Nota:

I nomi dei campi hanno una lunghezza limitata e non devono superare i 10 caratteri.

type

Il tipo di database da creare. Può essere DBASE_TYPE_DBASE o DBASE_TYPE_FOXPRO.

Valori restituiti

Restituisce una risorsa del database se il database viene creato correttamente, oppure false se si è verificato un errore.

Log delle modifiche

Versione Descrizione
PECL dbase 7.0.0 È stato aggiunto il parametro type.
PECL dbase 7.0.0 Il valore restituito ora è una resource invece di un int.

Esempi

Example #1 Creazione di un file di database dBase

<?php

// "definizione" del database
$def = array(
  array("date",     "D"),
  array("name",     "C",  50),
  array("age",      "N",   3, 0),
  array("email",    "C", 128),
  array("ismember", "L")
);

// creazione
if (!dbase_create('/tmp/test.dbf', $def)) {
  echo "Errore, impossibile creare il database\n";
}

?>

Vedere anche:

+add a note

User Contributed Notes 1 note

up
-5
denvolin
8 years ago
There is no third param in this function.
According to latest pecl package "dbase-pecl-php7", there are only 2 params.
To Top