本文整理汇总了PHP中dbase_get_header_info函数的典型用法代码示例。如果您正苦于以下问题:PHP dbase_get_header_info函数的具体用法?PHP dbase_get_header_info怎么用?PHP dbase_get_header_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbase_get_header_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postDailySales
public function postDailySales()
{
$dbf_file = $this->extracted_path . DS . 'CSH_AUDT.DBF';
if (file_exists($dbf_file)) {
$db = dbase_open($dbf_file, 0);
$header = dbase_get_header_info($db);
$record_numbers = dbase_numrecords($db);
$last_ds = $this->ds->lastRecord();
$update = 0;
for ($i = 1; $i <= $record_numbers; $i++) {
$row = dbase_get_record_with_names($db, $i);
$vfpdate = vfpdate_to_carbon(trim($row['TRANDATE']));
if (is_null($last_ds)) {
$attrs = ['date' => $vfpdate->format('Y-m-d'), 'branchid' => session('user.branchid'), 'managerid' => session('user.id'), 'sales' => $row['CSH_SALE'] + $row['CHG_SALE'], 'tips' => $row['TIP'], 'custcount' => $row['CUST_CNT'], 'empcount' => $row['CREW_KIT'] + $row['CREW_DIN']];
if ($this->ds->firstOrNew($attrs, ['date', 'branchid'])) {
}
$update++;
} else {
if ($last_ds->date->lte($vfpdate)) {
$attrs = ['date' => $vfpdate->format('Y-m-d'), 'branchid' => session('user.branchid'), 'managerid' => session('user.id'), 'sales' => $row['CSH_SALE'] + $row['CHG_SALE'], 'tips' => $row['TIP'], 'custcount' => $row['CUST_CNT'], 'empcount' => $row['CREW_KIT'] + $row['CREW_DIN']];
if ($this->ds->firstOrNew($attrs, ['date', 'branchid'])) {
}
$update++;
}
}
}
dbase_close($db);
return count($update > 0) ? true : false;
}
return false;
}
示例2: __construct
function __construct($url_dbf)
{
$this->url = $url_dbf;
// Abrir un el archivo dbase
$this->dbf = dbase_open($this->url, 0) or die("¡Error! No se pudo abrir el archivo de base de datos dbase '{$this->url}'.");
// Inicializo valores
$this->info_columna = dbase_get_header_info($this->dbf);
$this->set_campos();
$this->set_nombre_tabla();
$this->set_campos_array();
}
示例3: GetFieldList
function GetFieldList($AHandle)
{
$vHeader = dbase_get_header_info($AHandle);
$vResult = array();
if (is_array($vHeader)) {
foreach ($vHeader as $vFD) {
$vResult[] = strtoupper($vFD['name']);
}
}
return $vResult;
}
示例4: volcarDBF
function volcarDBF($db = "ctw10005")
{
$results = array();
$mFile = $db . date("Ymd") . ".txt";
//Abrir el Archivo para Escribir
$TFile = fopen(PATH_TMP . $mFile, "a");
$pathdbase = CTW_PATH . vLITERAL_SEPARATOR . $db . ".dbf";
//$db = dbase_open($ipdbase . $dirdbase . $nombredb . $db, 0);
$rs = dbase_open($pathdbase, 0);
//echo $pathdbase;
$results[SYS_MSG] .= "Abrir {$pathdbase} <br />";
$num_rows = dbase_numrecords($rs);
//$o_num_rows = dbase_numrecords ($rs);
if ($num_rows > 100000) {
//$num_rows = 100000; //Eliminar la Consulta a 50000
}
$results[SYS_MSG] .= "Numero de Filas {$num_rows} <br />";
if (isset($rs)) {
$results[SYS_MSG] .= "Cerrando " . dbase_get_header_info($rs) . " <br />";
for ($i = 1; $i <= $num_rows; $i++) {
//$field = dbase_get_record_with_names($rs, $i);
$field = dbase_get_record($rs, $i);
$lim = sizeof($field);
$strW = "";
for ($a = 0; $a < $lim; $a++) {
if ($a == 0) {
$strW .= trim($field[$a]);
} else {
$strW .= STD_LITERAL_DIVISOR . trim($field[$a]);
}
}
$strW .= "\n";
@fwrite($TFile, $strW);
//if (dbase_delete_record ($rs, $i)) {
// print "Registro $i Marcado para Eliminar de un total de $o_num_rows; se Busco $field[$key]. <br >";
//break; # Exit the loop
//}
}
} else {
//dbase_get_header_info($rs);
}
//dbase_pack($rs);
//$results[SYS_MSG] .= " <br />";
dbase_close($rs);
$results[SYS_MSG] .= "Cerrando {$pathdbase} <br />";
fclose($TFile);
$results[SYS_MSG] .= "Cerrando {$mFile} <br />";
return $results;
}
示例5: 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);
}
示例6: tableInfo
/**
* Returns information about the current database
*
* @param mixed $result THIS IS UNUSED IN DBASE. The current database
* is examined regardless of what is provided here.
* @param int $mode a valid tableInfo mode
*
* @return array an associative array with the information requested.
* A DB_Error object on failure.
*
* @see DB_common::tableInfo()
* @since Method available since Release 1.7.0
*/
function tableInfo($result = null, $mode = null)
{
if (function_exists('dbase_get_header_info')) {
$id = @dbase_get_header_info($this->connection);
if (!$id && $php_errormsg) {
return $this->raiseError(DB_ERROR, null, null, null, $php_errormsg);
}
} else {
/*
* This segment for PHP 4 is loosely based on code by
* Hadi Rusiah <deegos@yahoo.com> in the comments on
* the dBase reference page in the PHP manual.
*/
$db = @fopen($this->dsn['database'], 'r');
if (!$db) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, $php_errormsg);
}
$id = array();
$i = 0;
$line = fread($db, 32);
while (!feof($db)) {
$line = fread($db, 32);
if (substr($line, 0, 1) == chr(13)) {
break;
} else {
$pos = strpos(substr($line, 0, 10), chr(0));
$pos = $pos == 0 ? 10 : $pos;
$id[$i] = array('name' => substr($line, 0, $pos), 'type' => $this->types[substr($line, 11, 1)], 'length' => ord(substr($line, 16, 1)), 'precision' => ord(substr($line, 17, 1)));
}
$i++;
}
fclose($db);
}
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
$case_func = 'strtolower';
} else {
$case_func = 'strval';
}
$res = array();
$count = count($id);
if ($mode) {
$res['num_fields'] = $count;
}
for ($i = 0; $i < $count; $i++) {
$res[$i] = array('table' => $this->dsn['database'], 'name' => $case_func($id[$i]['name']), 'type' => $id[$i]['type'], 'len' => $id[$i]['length'], 'flags' => '');
if ($mode & DB_TABLEINFO_ORDER) {
$res['order'][$res[$i]['name']] = $i;
}
if ($mode & DB_TABLEINFO_ORDERTABLE) {
$res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
}
}
return $res;
}
示例7: mysql_pconnect
<?php
$tbl = "inc";
$db_uname = 'root';
$db_passwd = 'enachi59';
$db = 'car';
$conn = mysql_pconnect('localhost', $db_uname, $db_passwd);
// Path to dbase file
$db_path = "inc.dbf";
// Open dbase file
$dbh = dbase_open($db_path, 0) or die("Error! Could not open dbase database file '{$db_path}'.");
// Get column information
$column_info = dbase_get_header_info($dbh);
// Display information
//print_r($column_info);
$line = array();
foreach ($column_info as $col) {
switch ($col['type']) {
case 'character':
$line[] = "`{$col['name']}` VARCHAR( {$col['length']} )";
break;
case 'number':
$line[] = "`{$col['name']}` FLOAT";
break;
case 'boolean':
$line[] = "`{$col['name']}` BOOL";
break;
case 'date':
$line[] = "`{$col['name']}` DATE";
break;
case 'memo':
示例8: getColunasInfo
public function getColunasInfo()
{
return dbase_get_header_info($this->conexao);
}
示例9: header_info
public function header_info()
{
$this->header_info = dbase_get_header_info($this->db);
return $this->header_info;
}
示例10: _setHeader
private function _setHeader()
{
$this->_header = dbase_get_header_info($this->_fp);
}
示例11: 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);
}
示例12: upload_shp
/**
* Controller action to build the page that allows the user to choose which field is to be
* used for the location name, and optionally for the name of the parent location.
* A lot of this is stolen from the csv upload code.
*/
public function upload_shp()
{
$sizelimit = kohana::config('indicia.maxUploadSize');
$_FILES = Validation::factory($_FILES)->add_rules('zip_upload', 'upload::valid', 'upload::required', 'upload::type[zip]', "upload::size[{$sizelimit}]");
if ($_FILES->validate()) {
// move the file to the standard upload directory
$zipTempFile = upload::save('zip_upload');
$_SESSION['uploaded_zip'] = $zipTempFile;
// Following helps for files from Macs
ini_set('auto_detect_line_endings', 1);
$view = new View('location/upload_shp');
$zip = new ZipArchive();
$res = $zip->open($zipTempFile);
if ($res != TRUE) {
$this->setError('Upload file problem', 'Could not open Zip archive file - possible invalid format.');
return;
}
$directory = $this->create_zip_extract_dir();
if ($directory == false) {
return;
}
if (!$zip->extractTo($directory)) {
$this->setError('Upload file problem', 'Could not extract Zip archive file contents.');
return;
}
$entry = '';
$dbf = 0;
$shp = 0;
for ($i = 0; $i < $zip->numFiles; $i++) {
if (basename($zip->getNameIndex($i)) != basename($zip->getNameIndex($i), '.dbf')) {
$entry = $zip->getNameIndex($i);
$dbf++;
}
if (basename($zip->getNameIndex($i)) != basename($zip->getNameIndex($i), '.shp')) {
$shpentry = $zip->getNameIndex($i);
$shp++;
}
}
if ($shp == 0) {
$this->setError('Upload file problem', 'Zip archive file does not contain a file with a .shp extension.');
return;
}
if ($shp > 1) {
$this->setError('Upload file problem', 'Zip archive file contains more than one file with a .shp extension.');
return;
}
if ($dbf == 0) {
$this->setError('Upload file problem', 'Zip archive file does not contain a file with a .dbf extension.');
return;
}
if ($dbf > 1) {
$this->setError('Upload file problem', 'Zip archive file contains more than one file with a .dbf extension.');
return;
}
if (basename($entry, '.dbf') != basename($shpentry, '.shp')) {
$this->setError('Upload file problem', '.dbf and .shp files in Zip archive have different names.');
return;
}
$_SESSION['extracted_basefile'] = $directory . '/' . basename($entry, '.dbf');
$zip->close();
$this->template->title = "Choose details in " . $entry . " for " . $this->pagetitle;
$dbasedb = dbase_open($directory . '/' . $entry, 0);
if ($dbasedb) {
// read some data ..
$view->columns = dbase_get_header_info($dbasedb);
dbase_close($dbasedb);
} else {
$this->setError('Upload file problem', 'Could not open ' . $entry . ' from Zip archive.');
return;
}
$view->model = $this->model;
$view->controllerpath = $this->controllerpath;
$this->template->content = $view;
// Setup a breadcrumb
$this->page_breadcrumbs[] = html::anchor($this->model->object_name, $this->pagetitle);
$this->page_breadcrumbs[] = 'Setup SHP File upload';
} else {
$errors = $_FILES->errors();
$error = '';
foreach ($errors as $key => $val) {
switch ($val) {
case 'required':
$error .= 'You must specify a Zip Archive file to upload, containing the .shp and .dbf files.<br/>';
break;
case 'valid':
$error .= 'The uploaded file is not valid.<br/>';
break;
case 'type':
$error .= 'The uploaded file is not a zip file. The Shapefile should be uploaded in a Zip Archive file, which should also contain the .dbf file containing the data for each record.<br/>';
break;
case 'size':
$error .= 'The upload file is greater than the limit of ' . $sizelimit . 'b.<br/>';
break;
default:
$error .= 'An unknown error occurred when checking the upload file.<br/>';
//.........这里部分代码省略.........
示例13: dbase_close
for ($i = 0; $i < $nf; $i++) {
echo $rec[$i], "\n";
}
dbase_close($db);
}
echo 'end. Trying to create db...';
$def = array(array("date", "D"), array("name", "C", 50), array("age", "N", 3, 0), array("email", "C", 128), array("ismember", "L"));
// creation
$db = dbase_create('/home/a writeable directory/test.dbf', $def);
if (!$db) {
echo "Error, can't create the database\n";
} else {
echo 'hi numrecords is: ';
echo dbase_numrecords($db);
echo '\\r\\n Heres the header info:';
print_r(dbase_get_header_info($db));
echo 'number of records: ';
echo dbase_numrecords($db);
echo 'inserting row...';
dbase_add_record($db, array(date('Ymd'), 'Maxim Topolov', '23', 'max@example.com', 'T'));
echo 'finished inserting. number of records: ';
echo dbase_numrecords($db);
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";
}
dbase_add_record($db, array(date('Ymd'), 'Maxi2222m Topolov', '23', 'max@example.com', 'T'));
echo 'updating a row...';
// gets the old row
示例14: baca_dbf
function baca_dbf()
{
$filez = './uploads/urut.DBF';
$dbf = dbase_open($filez, 0);
$column_info = dbase_get_header_info($dbf);
$loop = dbase_numrecords($dbf);
for ($i = 1; $i <= $loop; $i++) {
$row = dbase_get_record_with_names($dbf, $i);
$data = array("nik" => $row['ID'], "mchID" => $row['IDABS']);
$this->db->insert("mchID", $data);
//echo $row['ID']."/".$row['IDABS']."<br>";
}
die;
}
示例15: importDBFs
public function importDBFs($br)
{
//(Request $request){
$logfile = base_path() . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . 'db-import.txt';
//return Employee::with('childrens')->get();
$import = true;
if ($import) {
$db = dbase_open('D:\\GI\\' . $br . '\\GC113015\\PAY_MAST.DBF', 0);
} else {
$db = dbase_open('D:\\GI\\MAR\\GC113015\\PAY_MAST.DBF', 0);
}
if ($db) {
$header = dbase_get_header_info($db);
if (!$import) {
echo '<table cellpadding="2" cellspacing="0" border="1"><thead>';
}
// render table header
if (!$import) {
echo '<tr>';
foreach ($header as $key => $value) {
echo '<th>' . $value['name'] . '</th>';
}
echo '</tr>';
}
// render table body
$children_ctr = 0;
$ecperson_ctr = 0;
$education_ctr = 0;
$work_ctr = 0;
$spouse_ctr = 0;
$record_numbers = dbase_numrecords($db);
for ($i = 1; $i <= $record_numbers; $i++) {
$row = dbase_get_record_with_names($db, $i);
if ($i == 1) {
$brcode = trim($row['BRANCH']);
}
if ($import) {
$e = Employee::where('code', trim($row['MAN_NO']))->first();
if (!is_null($e)) {
continue;
}
}
$employee = new Employee();
$employee->code = trim($row['MAN_NO']);
$employee->lastname = trim($row['LAST_NAM']);
$employee->firstname = trim($row['FIRS_NAM']);
$employee->middlename = trim($row['MIDL_NAM']);
$employee->companyid = trim($this->getCompanyId($row['CO_NAME']));
$employee->id = $employee->get_uid();
$branch = Branch::where('code', trim($row['BRANCH']))->first();
$employee->branchid = is_null($branch) ? '' : $branch->id;
$employee->deptid = $this->getDeptId($row['DEPT']);
$employee->positionid = $this->getPositionId(trim($row['POSITION']));
$employee->paytype = 2;
$employee->ratetype = 2;
$employee->rate = trim($row['RATE_HR']);
$employee->ecola = trim($row['RATE_HR']);
$employee->allowance1 = trim($row['ALW1_RATE']);
$employee->allowance2 = trim($row['ALW2_RATE']);
$employee->phicno = trim($row['PHEALTH_NO']);
$employee->hdmfno = trim($row['PBIG_NO']);
$employee->tin = trim($row['WTAX_NO']);
$employee->sssno = trim($row['SSS_NO']);
$employee->empstatus = $this->getEmpstatus(trim($row['EMP_STUS']));
$employee->datestart = Carbon::parse(trim($row['STARTED']));
//$employee->datehired = trim($row['ALW2_RATE']);
//$employee->datestop = trim($row['ALW2_RATE']);
$employee->punching = 1;
$employee->processing = 1;
$employee->address = trim($row['ADDRESS1']) . ', ' . trim($row['ADDRESS2']) . ', ' . trim($row['ADDRESS3']);
$employee->phone = trim($row['TEL']);
//$employee->fax = trim($row['TEL']);
$employee->mobile = trim($row['CEL']);
$employee->email = trim($row['EMAIL']);
$employee->gender = trim($row['SEX']) == 'M' ? 1 : 2;
$employee->civstatus = trim($row['CIV_STUS']) == 'SINGLE' ? 1 : 2;
$employee->height = str_replace("'", '.', trim($row['HEIGHT']));
$employee->weight = trim($row['WEIGHT']);
$employee->birthdate = Carbon::parse(trim($row['BIRTHDATE']));
$employee->birthplace = trim($row['BIRTHPLC']);
$employee->religionid = trim($this->getReligionId($row['RELIGION']));
$employee->hobby = trim($row['HOBBIES']);
$employee->notes = 'UNIFORM:' . trim($row['UNIFORM']) . '; ' . 'SP_NOTES1:' . trim($row['SP_NOTES1']) . '; ' . 'SP_NOTES2:' . trim($row['SP_NOTES2']) . '; ';
$childrens = [];
if (!empty(trim($row['CHILDREN1'])) && trim($row['CHILDREN1']) != 'N/A') {
$c1 = new Children();
$c1->firstname = trim($row['CHILDREN1']);
$c1->lastname = $employee->lastname;
$c1->id = $c1->get_uid();
array_push($childrens, $c1);
$children_ctr++;
}
if (!empty(trim($row['CHILDREN2'])) && trim($row['CHILDREN2']) != 'N/A') {
$c2 = new Children();
$c2->firstname = trim($row['CHILDREN2']);
$c2->lastname = $employee->lastname;
$c2->id = $c2->get_uid();
array_push($childrens, $c2);
$children_ctr++;
}
//.........这里部分代码省略.........