本文整理汇总了PHP中dbase_open函数的典型用法代码示例。如果您正苦于以下问题:PHP dbase_open函数的具体用法?PHP dbase_open怎么用?PHP dbase_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbase_open函数的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: ProcessDBF
function ProcessDBF($AName)
{
$vResult = 0;
$vHandle = dbase_open($AName, 0);
if ($vHandle === FALSE) {
throw new Exception('Невозможно открыть файл базы данных');
}
try {
$vFieldList = GetFieldList($vHandle);
$vSurgeryIDIdx = FindFieldIdx($vFieldList, 'MYSURGERYID', false);
$vCaseIDIdx = FindFieldIdx($vFieldList, 'MYCASEID');
$vDateIdx = FindFieldIdx($vFieldList, 'DATEIN');
$vSendIdx = FindFieldIdx($vFieldList, 'SEND');
$vErrorIdx = FindFieldIdx($vFieldList, 'ERROR');
$vCnt = dbase_numrecords($vHandle);
for ($i = 1; $i <= $vCnt; $i++) {
$vRecord = dbase_get_record($vHandle, $i);
ProcessDBFRecord(trim(@$vRecord[$vSurgeryIDIdx]), trim(@$vRecord[$vCaseIDIdx]), DBF2Date(trim(@$vRecord[$vDateIdx])), trim(@$vRecord[$vSendIdx]), iconv('CP866', 'UTF-8', trim(@$vRecord[$vErrorIdx])));
$vResult++;
}
} catch (Exception $e) {
dbase_close($vHandle);
throw $e;
}
dbase_close($vHandle);
return $vResult;
}
示例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: __construct
public function __construct($options)
{
$this->_dBase = dbase_open($options['file'], 0);
if ($this->_dBase === false) {
throw new Zend_Exception('Ошибка открытия файла импорта');
}
}
示例5: export
/**
* Export data
* @return boolean
*/
function export()
{
$def = array(array('o_id', 'N', 10, 0), array('o_uid', 'N', 10, 0), array('o_date', 'D'), array('o_state', 'N', 1, 0), array('o_ip', 'C', 32), array('o_lastname', 'C', 155), array('o_firstnam', 'C', 155), array('o_adress', 'C', 155), array('o_zip', 'C', 30), array('o_town', 'C', 155), array('o_country', 'C', 3), array('o_telephon', 'C', 30), array('o_email', 'C', 155), array('o_articles', 'N', 10, 0), array('o_total', 'N', 10, 2), array('o_shipping', 'N', 10, 2), array('o_bill', 'L'), array('o_password', 'C', 155), array('o_text', 'C', 155), array('o_cancel', 'C', 155), array('c_id', 'N', 10, 0), array('c_prod_id', 'N', 10, 0), array('c_qte', 'N', 10, 0), array('c_price', 'N', 10, 2), array('c_o_id', 'N', 10, 0), array('c_shipping', 'N', 10, 2), array('c_pass', 'C', 155));
/*
* Correspondances
* cmd_id o_id
* cmd_uid o_uid
* cmd_date o_date
* cmd_state o_state
* cmd_ip o_ip
* cmd_lastname o_lastname
* cmd_firstname o_firstnam
* cmd_adress o_adress
* cmd_zip o_zip
* cmd_town o_town
* cmd_country o_country
* cmd_telephone o_telephon
* cmd_email o_email
* cmd_articles_count o_articles
* cmd_total o_total
* cmd_shipping o_shipping
* cmd_bill o_bill
* cmd_password o_password
* cmd_text o_text
* cmd_cancel o_cancel
* caddy_id c_id
* caddy_product_id c_prod_id
* caddy_qte c_qte
* caddy_price c_price
* caddy_cmd_id c_o_id
* caddy_shipping c_shipping
* caddy_pass c_pass
*/
if (!dbase_create($this->folder . DIRECTORY_SEPARATOR . $this->filename, $def)) {
$this->success = false;
return false;
}
$dbf = dbase_open($this->folder . DIRECTORY_SEPARATOR . $this->filename, 2);
if ($dbf === false) {
$this->success = false;
return false;
}
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('cmd_id', 0, '<>'));
$criteria->add(new Criteria('cmd_state', $this->orderType, '='));
$criteria->setSort('cmd_date');
$criteria->setOrder('DESC');
$orders = $this->handlers->h_myshop_commands->getObjects($criteria);
foreach ($orders as $order) {
$carts = array();
$carts = $this->handlers->h_myshop_caddy->getObjects(new Criteria('caddy_cmd_id', $order->getVar('cmd_id'), '='));
foreach ($carts as $cart) {
dbase_add_record($dbf, array($order->getVar('cmd_id'), $order->getVar('cmd_uid'), date('Ymd', strtotime($order->getVar('cmd_date'))), $order->getVar('cmd_state'), $order->getVar('cmd_ip'), $order->getVar('cmd_lastname'), $order->getVar('cmd_firstname'), $order->getVar('cmd_adress'), $order->getVar('cmd_zip'), $order->getVar('cmd_town'), $order->getVar('cmd_country'), $order->getVar('cmd_telephone'), $order->getVar('cmd_email'), $order->getVar('cmd_articles_count'), $order->getVar('cmd_total'), $order->getVar('cmd_shipping'), $order->getVar('cmd_bill'), $order->getVar('cmd_password'), $order->getVar('cmd_text'), $order->getVar('cmd_cancel'), $cart->getVar('caddy_id'), $cart->getVar('caddy_product_id'), $cart->getVar('caddy_qte'), $cart->getVar('caddy_price'), $cart->getVar('caddy_cmd_id'), $cart->getVar('caddy_shipping'), $cart->getVar('caddy_pass')));
}
}
dbase_close($dbf);
$this->success = true;
return true;
}
示例6: conectar
public function conectar()
{
$this->conexao = dbase_open($this->caminho, $this->modo);
if ($this->conexao == false) {
return false;
}
return $this->conexao;
}
示例7: 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;
}
示例8: _load
protected function _load($file)
{
if ($this->_fp) {
return $this->_fp;
}
$this->_fp = dbase_open($file, 0);
$this->_setHeader();
$this->_setSize();
}
示例9: DBFOpen
function DBFOpen($flag = 2)
{
$this->DBFCon = dbase_open($this->DBFFile, $flag);
if (!$this->DBFCon) {
die("Gagal Membuka File DBF");
} else {
return $this->DBFCon;
}
}
示例10: __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();
}
示例11: 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;
}
示例12: open
public static function open($filename, $mode = self::MODE_READ)
{
if (!file_exists($filename)) {
throw new RuntimeException(sprintf('Filename %s not found', $filename));
}
if (!function_exists('dbase_open')) {
throw new RuntimeException(sprintf('Extension dBase not support with your PHP interpreter'));
}
$dbaseId = @dbase_open($filename, $mode);
if (false === $dbaseId) {
throw new RuntimeException(sprintf('Failed to open database file %s', $filename));
}
return new self($dbaseId);
}
示例13: 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;
}
示例14: 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>');
}
示例15: connect
function connect($dsninfo, $persistent = false)
{
if (!DB::assertExtension('dbase')) {
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
}
$this->dsn = $dsninfo;
ob_start();
$conn = dbase_open($dsninfo['database'], 0);
$error = ob_get_contents();
ob_end_clean();
if (!$conn) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, strip_tags($error));
}
$this->connection = $conn;
return DB_OK;
}