本文整理汇总了PHP中dbase_numfields函数的典型用法代码示例。如果您正苦于以下问题:PHP dbase_numfields函数的具体用法?PHP dbase_numfields怎么用?PHP dbase_numfields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbase_numfields函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNumeroCampos
public function getNumeroCampos()
{
$num = dbase_numfields($this->conexao);
if ($num != false) {
return $num;
} else {
return false;
}
}
示例2: import_dbf
function import_dbf($db, $table, $dbf_file)
{
global $conn;
if (!($dbf = dbase_open($dbf_file, 0))) {
die("Could not open {$dbf_file} for import.");
}
$num_rec = dbase_numrecords($dbf);
$num_fields = dbase_numfields($dbf);
$fields = array();
for ($i = 1; $i <= $num_rec; $i++) {
$row = @dbase_get_record_with_names($dbf, $i);
$q = "insert into {$db}.{$table} values (";
foreach ($row as $key => $val) {
if ($key == 'deleted') {
continue;
}
$q .= "'" . addslashes(trim($val)) . "',";
// Code modified to trim out whitespaces
}
if (isset($extra_col_val)) {
$q .= "'{$extra_col_val}',";
}
$q = substr($q, 0, -1);
$q .= ')';
//if the query failed - go ahead and print a bunch of debug info
if (!($result = mysql_query($q, $conn))) {
print mysql_error() . " SQL: {$q}\n\n";
print substr_count($q, ',') + 1 . " Fields total.\n\n";
$problem_q = explode(',', $q);
$q1 = "desc {$db}.{$table}";
$result1 = mysql_query($q1, $conn);
$columns = array();
$i = 1;
while ($row1 = mysql_fetch_assoc($result1)) {
$columns[$i] = $row1['Field'];
$i++;
}
$i = 1;
foreach ($problem_q as $pq) {
print "{$i} column: {$columns[$i]} data: {$pq}\n\n";
$i++;
}
die;
}
}
}
示例3: subedbff
function subedbff($file = 'TRABAJAD.DBF')
{
//nota:hay que modificar el upload_max_file_size=100M del php.ini
//nota:cambiar el tamanano de pres.nacinal a 15 caracteres
//nota:cambiar tamano de carg.descrip a tamano de 100
set_time_limit(3600);
$this->load->dbforge();
$this->load->dbutil();
$filea = explode('.', $file);
$name = $filea[0];
$ext = $filea[1];
$uploadsdir = getcwd() . '/uploads/';
$filedir = $uploadsdir . $file;
$tabla = strtoupper($ext . $name);
if (extension_loaded('dbase')) {
$db = dbase_open($filedir, 0);
$this->dbforge->drop_table($tabla);
if ($db) {
$cols = dbase_numfields($db);
$rows = dbase_numrecords($db);
$row = dbase_get_record_with_names($db, 10);
foreach ($row as $key => $value) {
$fields[trim($key)] = array('type' => 'TEXT');
}
//print_r($fields);
//exit();
$this->dbforge->add_field($fields);
$this->dbforge->create_table($tabla);
$insert = array();
for ($i = 0; $i <= $rows; $i++) {
$r = dbase_get_record_with_names($db, $i);
foreach ($row as $key => $value) {
$a = utf8_encode(trim($r[trim($key)]));
$insert[trim($key)] = $a;
}
$this->db->insert($tabla, $insert);
}
echo $i;
dbase_close($db);
} else {
echo "No pudo abrir el archivo";
}
} else {
echo 'Debe cargar las librerias dbase para poder usar este modulo';
}
}
示例4: load_dbf
public function load_dbf($filename, $mode = 0)
{
if (!file_exists($filename)) {
return cy_dt(CYE_ERROR, 'Not a valid DBF file!');
}
$tail = substr($filename, -4);
if (strcasecmp($tail, '.dbf') != 0) {
return cy_dt(CYE_ERROR, 'Not a valid DBF file!');
}
try {
$this->_handler = dbase_open($filename, $mode);
} catch (Exception $e) {
echo $e->getMessage();
return cy_dt(CYE_ERROR, 'open DBF file failed!');
}
$this->field_num = dbase_numfields($this->_handler);
$this->rec_num = dbase_numrecords($this->_handler);
$this->field_names = dbase_get_header_info($this->_handler);
return cy_dt(0);
}
示例5: numCols
/**
* Gets the number of columns in a result set
*
* This method is not meant to be called directly. Use
* DB_result::numCols() instead. It can't be declared "protected"
* because DB_result is a separate object.
*
* @param resource $result PHP's query result resource
*
* @return int the number of columns. A DB_Error object on failure.
*
* @see DB_result::numCols()
*/
function numCols($foo)
{
return @dbase_numfields($this->connection);
}
示例6: end
<?php
$db = false;
if (!empty($argc)) {
$file = end($argv);
$db = dbase_open($file, 0);
}
if ($db) {
$iconvFrom = '866';
$iconvTo = 'UTF-8';
$delimetr = ',';
$info = dbase_get_header_info($db);
$fields = dbase_numfields($db);
$fieldsCount = sizeof($fields);
$records = dbase_numrecords($db);
//for ($i = 1; $i <= 10; $i++) { # test
for ($i = 1; $i <= $records; $i++) {
$row = dbase_get_record($db, $i);
$line = array();
for ($j = 0; $j < $fields; $j++) {
$line[] = addslashes(iconv($iconvFrom, $iconvTo, trim($row[$j])));
}
echo implode($delimetr, $line);
echo PHP_EOL;
}
dbase_close($db);
}
示例7: array
$tab_date = array();
// on constitue le tableau des champs à extraire
$tabchamps = array("ABSTYPE", "ELENOET", "ABSDATD", "ABSDATF", "ABSSEQD", "ABSSEQF", "ABSHEUR", "ABSJUST", "ABSMOTI", "ABSACTI");
//ABSTYPE : Absence ou Retard ou Infirmerie
//ELENOET : numéro de l'élève
//ABSDATD : date de début de l'absence
//ABSDATF : date de fin de l'absence
//ABSSEQD : numéro de la séquence de début de l'absence
//ABSSEQF : numéro de la séquence de fin de l'absence
//ABSHEUR : heure de rentrée dans la cas d'un retard
//ABSJUST : justification (Oui ou Non)
//ABSMOTI : Motif
//ABSACTI : ???? prend les valeurs suivantes AT, LE, CO, ... ?
$nblignes = dbase_numrecords($fp);
//number of rows
$nbchamps = dbase_numfields($fp);
//number of fields
if (@dbase_get_record_with_names($fp, 1)) {
$temp = @dbase_get_record_with_names($fp, 1);
} else {
echo "<p>Le fichier sélectionné n'est pas valide !<br />\n";
echo "<a href='import_absences_gep.php?id_classe={$id_classe}&periode_num={$periode_num}&step=3'>Cliquer ici </a> pour recommencer !</center></p>\n";
die;
}
$nb = 0;
foreach ($temp as $key => $val) {
$en_tete[$nb] = $key;
$nb++;
}
// On range dans tabindice les indices des champs retenus
for ($k = 0; $k < count($tabchamps); $k++) {
示例8: xbase_open
$xi = xbase_open("test/xbase.dbf", 2);
echo "dbase<br>";
echo "index = {$di} <br>";
echo "<br>";
echo "xbase<br>";
echo "index = {$xi} <br>";
echo "header info: ";
print_r(xbase_get_header_info($xi));
dbase_close($di);
xbase_close($xi);
echo "<br><br>";
$di = dbase_open("test/xbase.dbf", 0);
$xi = xbase_open("test/dbase.dbf", 0);
echo "dbase<br>";
echo "index = {$di} <br>";
echo "column count = " . dbase_numfields($di) . " <br>";
echo "record count = " . dbase_numrecords($di) . " <br>";
echo "<table>";
for ($i = 0; $i < dbase_numrecords($di); $i++) {
echo "<tr>";
$r = dbase_get_record_with_names($di, $i + 1);
foreach ($r as $c => $v) {
echo "<td> {$c}={$v} </td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br>";
echo "xbase<br>";
echo "index = {$xi} <br>";
echo "column count = " . xbase_numfields($xi) . " <br>";
示例9: subedbf
function subedbf($file = 'DATONO02.DBF', $insertar = true)
{
set_time_limit(3600);
$this->load->dbforge();
$this->load->dbutil();
$filea = explode('.', $file);
$name = $filea[0];
$ext = $filea[1];
$uploadsdir = getcwd() . '/uploads/';
$filedir = $uploadsdir . $file;
$tabla = strtoupper($ext . $name);
if (extension_loaded('dbase')) {
$db = @dbase_open($filedir, 0);
$this->dbforge->drop_table($tabla);
if ($db) {
$cols = @dbase_numfields($db);
$rows = @dbase_numrecords($db);
$row = @dbase_get_record_with_names($db, 10);
print_r($row);
count($row);
if (is_array($row) > 0) {
foreach ($row as $key => $value) {
$fields[trim($key)] = array('type' => 'TEXT');
}
//print_r($fields);
//exit();
@$this->dbforge->add_field($fields);
@$this->dbforge->create_table($tabla);
if ($insertar) {
$insert = array();
for ($i = 0; $i <= $rows; $i++) {
$r = @dbase_get_record_with_names($db, $i);
foreach ($row as $key => $value) {
$a = @utf8_encode(trim($r[trim($key)]));
$insert[trim($key)] = $a;
}
@$this->db->insert($tabla, $insert);
echo 1;
}
}
@dbase_close($db);
}
} else {
echo "No pudo abrir el archivo";
}
} else {
echo 'Debe cargar las librerias dbase para poder usar este modulo';
}
}
示例10: num_fields
function num_fields($query)
{
if ($this->debug) {
echo "<pre style=\"color : green\">Getting number of fields {$this->dbpath} <p style=\"color:purple;\"> {$query} </p></pre>";
}
$nooffields = 0;
//Validate the sql statement and make adjustments
switch ($this->dbtype) {
/* Firebird Functionality */
case "firebird":
//write some things here
$nooffields = ibase_num_fields($query);
break;
/* SQLite Functionality */
/* SQLite Functionality */
case "sqlite":
putenv("TMP=" . $this->tmppath);
$nooffields = sqlite_num_fields($query);
break;
/*DBASE functionality */
/*DBASE functionality */
case "dbase":
$nooffields = dbase_numfields($this->dbh);
break;
/* MYSQL Functionality */
/* MYSQL Functionality */
case "mysql":
$nooffields = mysql_num_fields($query);
break;
/* Oracle Functionality */
/* Oracle Functionality */
case "oracle":
$nooffields = oci_num_fields($query);
break;
/* PGSQL Functionality */
/* PGSQL Functionality */
case "pgsql":
$nooffields = pg_num_fields($query);
break;
}
if ($this->debug) {
echo "<pre style=\"color : blue\">Number of fields {$nooffields} \n </pre>";
}
return $nooffields;
}
示例11: print_r
echo 'row before inserting is: ';
print_r($row);
// Replace the record
dbase_replace_record($db, $row, 1);
echo 'trying record num 1: ';
$rec = dbase_get_record($db, 1);
$nf = dbase_numfields($db);
for ($i = 0; $i < $nf; $i++) {
echo $rec[$i], "\n";
}
echo 'deleting row 2. before deletion: ';
$rec = dbase_get_record($db, 2);
$nf = dbase_numfields($db);
for ($i = 0; $i < $nf; $i++) {
echo $rec[$i], "\n";
}
echo dbase_delete_record($db, 2);
echo 'before db pack';
echo dbase_pack($db);
echo 'after pack, trying to fetch record 2';
$rec = dbase_get_record($db, 2);
$nf = dbase_numfields($db);
for ($i = 0; $i < $nf; $i++) {
echo $rec[$i], "\n";
}
dbase_close($db);
}
?>