本文整理汇总了PHP中dbase_get_record_with_names函数的典型用法代码示例。如果您正苦于以下问题:PHP dbase_get_record_with_names函数的具体用法?PHP dbase_get_record_with_names怎么用?PHP dbase_get_record_with_names使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbase_get_record_with_names函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importar_ctw
function importar_ctw($db = "ctw10005.dbf", $id = "2007")
{
//elimina la anterior
mysql_unbuffered_query("TRUNCATE compacw_importados");
$pathdbase = CTW_PATH . "/" . $db;
//$db = dbase_open($ipdbase . $dirdbase . $nombredb . $db, 0);
$rs = dbase_open($pathdbase, 2);
//echo $pathdbase;
$num_rows = dbase_numrecords($rs);
//$o_num_rows = dbase_numrecords ($rs);
//$num_rows = 100000; //Eliminar la Consulta a 50000
for ($i = 1; $i <= $num_rows; $i++) {
$field = dbase_get_record_with_names($rs, $i);
if (trim($field["EJE"]) == $id and trim($field["TIPO"]) == 1) {
//
$values_sql = " ('" . $field["CUENTA"] . "', " . $field["IMP1"] . ") ";
$sql_ex = "INSERT INTO compacw_importados(cuenta, saldo) VALUES " . $values_sql;
mysql_unbuffered_query($sql_ex);
//
}
}
//
//dbase_pack($rs);
dbase_close($rs);
echo "<p>DATOS IMPORTADOS: " . date("H:i:s") . " HRS </p>";
}
示例2: ListRead
public function ListRead()
{
$count = dbase_numrecords($this->_dBase);
for ($i = 1; $i <= $count; $i++) {
$row = dbase_get_record_with_names($this->_dBase, $i);
}
}
示例3: 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;
}
示例4: get_encabezado_llenado
function get_encabezado_llenado()
{
if ($this->dbf) {
$numero_registros = dbase_numrecords($this->dbf);
$this->tabla_sql_data = "INSERT INTO `" . $this->nombre_tabla . "` (\n" . $this->get_campos_str();
for ($i = 1; $i <= $numero_registros; $i++) {
$fila = dbase_get_record_with_names($this->dbf, $i);
$control = 0;
$this->tabla_sql_data .= "(";
foreach ($fila as $key => $value) {
if ($control < count($fila) - 1) {
if ($this->campos[$control]['type'] === 'number') {
$this->tabla_sql_data .= $fila[$key];
} else {
$this->tabla_sql_data .= "'" . $fila[$key] . "'";
}
if ($control != count($fila) - 2) {
$this->tabla_sql_data .= ",";
} else {
$this->tabla_sql_data .= "),";
}
}
$control++;
}
}
$cad = $this->tabla_sql_data;
$this->tabla_sql_data = substr($cad, 0, -1);
$this->tabla_sql_data .= ";";
}
//Fin IF Principal
}
示例5: actionIndex
/**
* Обновляет справочник банков, используя указанный файл или файл из папки data.
*
* Необходимо расширение dbase. Установить расширение dbase можно так: sudo pecl install dbase
*
* @param null $file
* @return int
*/
public function actionIndex($file = null)
{
if (!extension_loaded('dbase')) {
$this->stdout("Для работы скрипта обновления необходимо установить расширение dbase\n", Console::FG_RED);
return 1;
}
if ($file === null) {
$file = Yii::getAlias(dirname(__FILE__) . '/../data/bnkseek.dbf');
} else {
$file = Yii::getAlias($file);
}
if (!file_exists($file)) {
$this->stdout("Файл {$file} не найден!\n", Console::FG_RED);
return 1;
}
if ($this->confirm("Обновить справочник банков России, используя файл {$file}?")) {
$this->stdout('Выполняю обновление...' . "\n");
$db = dbase_open($file, 0);
if (!$db) {
$this->stdout("Не удалось открыть файл как базу данный dbase!\n", Console::FG_RED);
return 1;
}
$current_db_records_count = Bank::find()->count();
$data_records_count = dbase_numrecords($db);
$data_updated = false;
$this->stdout("Количество банков в текущем справочнике - {$current_db_records_count}.\n");
$this->stdout("Количество банков в файле - {$data_records_count}.\n");
for ($i = 1; $i <= $data_records_count; $i++) {
$rec = dbase_get_record_with_names($db, $i);
/** @var Bank $model */
$model = Yii::createObject(['class' => Bank::className(), 'bik' => $rec["NEWNUM"], 'okpo' => $rec["OKPO"], 'full_name' => iconv('CP866', 'utf-8', $rec["NAMEP"]), 'short_name' => iconv('CP866', 'utf-8', $rec["NAMEN"]), 'ks' => $rec["KSNP"], 'city' => iconv('CP866', 'utf-8', $rec["NNP"]), 'zip' => (int) $rec["IND"], 'address' => iconv('CP866', 'utf-8', $rec["ADR"]), 'tel' => iconv('CP866', 'utf-8', $rec["TELEF"])]);
foreach ($model->getAttributes() as $key => $value) {
$model->{$key} = trim($value);
}
/** @var Bank $exist */
$exist = Bank::findOne($model->bik);
if (!$exist) {
$this->stdout("Добавлен новый банк: {$model->bik} {$model->short_name}\n");
$data_updated = true;
$model->save(false);
} else {
if ($exist->getAttributes() != $model->getAttributes()) {
$exist->setAttributes($model->getAttributes());
$this->stdout("Обновлены данные банка: {$exist->bik} {$exist->short_name}\n");
$data_updated = true;
$exist->save(false);
}
}
}
dbase_close($db);
if ($data_updated) {
$this->stdout('Справочник банков успешно обновлен!' . "\n", Console::FG_GREEN);
} else {
$this->stdout('В справочник банков не было внесено изменений.' . "\n", Console::FG_GREEN);
}
}
return 0;
}
示例6: actionImportDbf
public function actionImportDbf($filename, $region = false)
{
$db = @dbase_open($filename, 0);
if (!$db) {
$this->stderr("Не удалось открыть DBF файл: '{$filename}'\n");
return 1;
}
$classMap = ['/^.*DADDROBJ\\.DBF$/' => FiasDaddrobj::className(), '/^.*ADDROBJ\\.DBF$/' => FiasAddrobj::className(), '/^.*LANDMARK\\.DBF$/' => FiasLandmark::className(), '/^.*DHOUSE\\.DBF$/' => FiasDhouse::className(), '/^.*HOUSE\\d\\d\\.DBF$/' => FiasHouse::className(), '/^.*DHOUSINT\\.DBF$/' => FiasDhousint::className(), '/^.*HOUSEINT\\.DBF$/' => FiasHouseint::className(), '/^.*DLANDMRK\\.DBF$/' => FiasDlandmrk::className(), '/^.*DNORDOC\\.DBF$/' => FiasDnordoc::className(), '/^.*NORDOC\\d\\d\\.DBF$/' => FiasNordoc::className(), '/^.*ESTSTAT\\.DBF$/' => FiasDhousint::className(), '/^.*ACTSTAT\\.DBF$/' => FiasActstat::className(), '/^.*CENTERST\\.DBF$/' => FiasCenterst::className(), '/^.*ESTSTAT\\.DBF$/' => FiasEststat::className(), '/^.*HSTSTAT\\.DBF$/' => FiasHststat::className(), '/^.*OPERSTAT\\.DBF$/' => FiasOperstat::className(), '/^.*INTVSTAT\\.DBF$/' => FiasIntvstat::className(), '/^.*STRSTAT\\.DBF$/' => FiasStrstat::className(), '/^.*CURENTST\\.DBF$/' => FiasCurentst::className(), '/^.*SOCRBASE\\.DBF$/' => FiasSocrbase::className()];
$modelClass = false;
foreach ($classMap as $pattern => $className) {
if (preg_match($pattern, $filename)) {
$modelClass = $className;
break;
}
}
if ($modelClass === false) {
$this->stderr("Не поддерживаемый DBF файл: '{$filename}'\n");
return 1;
}
$rowsCount = dbase_numrecords($db);
$this->stdout("Записей в DBF файле '{$filename}' : {$rowsCount}\n");
$j = 0;
for ($i = 1; $i <= $rowsCount; $i++) {
$row = dbase_get_record_with_names($db, $i);
if ($modelClass == FiasAddrobj::className() && $this->region && intval($row['REGIONCODE']) != intval($this->region)) {
continue;
}
if ($j == 0) {
$transaction = Yii::$app->db->beginTransaction();
}
$model = new $modelClass();
foreach ($row as $key => $value) {
if ($key == 'deleted') {
continue;
}
$key = strtolower($key);
$model->{$key} = trim(mb_convert_encoding($value, 'UTF-8', 'CP866'));
}
$model->save();
$j++;
if ($j == 1000) {
$transaction->commit();
$j = 0;
$this->stdout("Обработано {$i} из {$rowsCount} записей\n");
}
}
if ($j != 0) {
$transaction->commit();
}
return 0;
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('<info>Started at ' . date('H:i:s') . '</info>');
$em = $this->em = $this->getEntityManager('default');
$this->truncate();
$db_path = __DIR__ . '/../Resources/KLADR/STREET.DBF';
$db = dbase_open($db_path, 0) or die("Error! Could not open dbase database file '$db_path'.");
$record_numbers = dbase_numrecords($db);
$batchSize = $input->getOption('batch');
for ($i = 1; $i <= $record_numbers; $i++) {
$row = dbase_get_record_with_names($db, $i);
$street = new KladrStreet();
$street->setTitle(trim(iconv('cp866', 'utf8', $row['NAME'])));
$code = trim($row['CODE']);
if(substr($code, -2) != '00')
continue;
$code = substr($code, 0, -2);
$street->setId($code);
$street->setParentCode(intval(str_pad(substr($code, 0, -4), 11, '0', STR_PAD_RIGHT)));
$street->setZip(trim($row['INDEX']));
$street->setOcatd(trim($row['OCATD']));
$street->setSocr(trim(iconv('cp866', 'utf8', $row['SOCR'])));
$em->persist($street);
if (($i % $batchSize) == 0) {
$em->flush();
$em->clear();
$output->writeln('<info>Inserted '. $i. ' records</info>');
}
}
$em->flush();
$output->writeln('<info>Inserted '. $i. ' records</info>');
$output->writeln('<info>Success</info>');
$output->writeln('<info>Deleting dead links</info>');
$this->deleteNotLinkedElements();
$output->writeln('<info>Assigning parents</info>');
$this->updateParents();
$output->writeln('<info>Success</info>');
}
示例8: 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';
}
}
示例9: 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;
}
}
}
示例10: error_reporting
<?php
error_reporting('-1');
$db = dbase_open('chart.dbf', 0);
if ($db) {
$record_numbers = dbase_numrecords($db);
for ($i = 1; $i <= $record_numbers; $i++) {
$row = dbase_get_record_with_names($db, $i);
foreach ($row as $key => $value) {
echo $key . ': ' . $value . '<br/>';
}
// echo print_r($row,true);
//if ($row['ismember'] == 1) {
// echo "Member #$i: " . trim($row['name']) . "\n";
//}
}
}
?>
示例11: getRecord
public function getRecord($geometry_format = self::GEOMETRY_ARRAY)
{
if (ftell($this->shp) >= $this->file_size) {
return false;
}
$record_number = $this->ReadData('N');
$content_length = $this->ReadData('N');
$shape_type = $this->ReadData('V');
if ($shape_type != 0 && $shape_type != $this->shape_type) {
$this->Error('WRONG_RECORD_TYPE', $shape_type);
}
switch ($shape_type) {
case 0:
$shp = null;
break;
case 1:
$shp = $this->ReadPoint();
break;
case 8:
$shp = $this->ReadMultiPoint();
break;
case 3:
$shp = $this->ReadPolyLine();
break;
case 5:
$shp = $this->ReadPolygon();
break;
}
if ($geometry_format == self::GEOMETRY_WKT) {
$shp = $this->WKT($shp);
}
return array('shp' => $shp, 'dbf' => dbase_get_record_with_names($this->dbf, $record_number));
}
示例12: _fetchDBFInformation
private function _fetchDBFInformation()
{
$this->_openDBFFile();
if ($this->dbf) {
//En este punto salta un error si el registro 0 está vacio.
//Ignoramos los errores, ja que aún así todo funciona perfecto.
$this->dbf_data = dbase_get_record_with_names($this->dbf, $this->record_number);
} else {
$this->setError(sprintf(self::INCORRECT_DBF_FILE, $this->file_name));
}
$this->_closeDBFFile();
}
示例13: getRecord
public function getRecord($record_num)
{
$record = dbase_get_record_with_names($this->_fp, $record_num);
return $record;
}
示例14: GetDBFRecByName
function GetDBFRecByName($i)
{
$ret = dbase_get_record_with_names($this->DBFCon, $i) or die("Gagal Mengambil Data");
return $ret;
}
示例15: 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;
}