本文整理汇总了PHP中dbase_numrecords函数的典型用法代码示例。如果您正苦于以下问题:PHP dbase_numrecords函数的具体用法?PHP dbase_numrecords怎么用?PHP dbase_numrecords使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbase_numrecords函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prueba
public function prueba()
{
$conex = dbase_open('C:\\mficha.DBF', 0);
//return dbase_get_header_info($conex);
$total_registros = dbase_numrecords($conex);
for ($i = 1; $i <= $total_registros; $i++) {
echo dbase_get_record($conex, $i)[0] . '<br>';
}
}
示例2: 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
}
示例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: ListRead
public function ListRead()
{
$count = dbase_numrecords($this->_dBase);
for ($i = 1; $i <= $count; $i++) {
$row = dbase_get_record_with_names($this->_dBase, $i);
}
}
示例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: getNumeroRegistros
public function getNumeroRegistros()
{
$num = dbase_numrecords($this->conexao);
if ($num != false) {
return $num;
} else {
return false;
}
}
示例7: 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;
}
示例8: 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;
}
示例9: 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>');
}
示例10: 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;
}
}
}
示例11: 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';
}
}
示例12: 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);
}
示例13: convert
public function convert()
{
$delayed_objects = array();
$num_records = dbase_numrecords($this->_link);
for ($i = 1; $i <= $num_records; $i++) {
$record = dbase_get_record($this->_link, $i);
if ('skip_record' === ($obj = $this->_parseRecord($record))) {
continue;
}
if ('delay_object' === $this->_insertObject($obj)) {
$delayed_objects[] = $obj;
}
}
foreach ($delayed_objects as $obj) {
$this->_insertObject($obj, true);
}
//var_export($this->_region_abbrs);
//var_export($this->_local_abbrs);
return $this;
}
示例14: fetch_all
public function fetch_all()
{
$rows = array();
$record_numbers = dbase_numrecords($this->db);
for ($i = 1; $i <= $record_numbers; $i++) {
// do something here, for each record
$row = dbase_get_record_with_names($this->db, $i);
$rows[] = $row;
}
return $rows;
}
示例15: 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";
//}
}
}
?>