function purgedbf($db = "ctw10005.dbf", $key = "EJE", $id = "2007") { $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); if ($num_rows > 100000) { $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[$key]) != $id) { 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 } } } dbase_pack($rs); dbase_close($rs); echo "<p>PURGA EFECTUADA DE {$db} SEGUN {$key} sobre {$id} A LAS " . date("H:i:s") . " HRS </p>"; }
public function organizar() { if (dbase_pack($this->conexao)) { return true; } else { return false; } }
function _saveRecords() { if (file_exists(str_replace('.*', '.dbf', $this->FileName))) { @unlink(str_replace('.*', '.dbf', $this->FileName)); } if (!($this->DBFFile = @dbase_create(str_replace('.*', '.dbf', $this->FileName), $this->DBFHeader))) { return $this->setError(sprintf("It wasn't possible to create the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); } $offset = 50; if (is_array($this->records) && count($this->records) > 0) { reset($this->records); while (list($index, $record) = each($this->records)) { //Save the record to the .shp file $record->saveToFile($this->SHPFile, $this->DBFFile, $index + 1); //Save the record to the .shx file fwrite($this->SHXFile, pack("N", $offset)); fwrite($this->SHXFile, pack("N", $record->getContentLength())); $offset += 4 + $record->getContentLength(); } } @dbase_pack($this->DBFFile); }
Ana update terakhir tgl. .............. -abrarhedar- ------------------------------------------------------ */ session_start(); include "../lib/sambung.php"; include "../lib/sipl.php"; CheckAuthentication(); $kdunit = $_SESSION[kdunit]; $sktunit = strtolower(sktunitkerja($kdunit, $ta)); $ta = $_SESSION[ta]; $filedata = '../DataDipa/' . $sktunit . '/d_item.dbf'; if (file_exists($filedata)) { echo 'file ' . $filedata . ' ada'; $data = dbase_open($filedata, 2); dbase_pack($data); $jml = dbase_numrecords($data); $vdataawal = dbase_get_record_with_names($data, 1); $tahun = $vdataawal["THANG"]; $kodesatker = $vdataawal["KDSATKER"]; //dbase_pack($data); $kdsatkerunit = kdsatker($kdunit); echo 'tahun anggaran ' . $tahun . ' satker data ' . $kodesatker; echo 'kode unit ' . $kdunit . ' satker unit ' . $kdsatkerunit; if ($_REQUEST['ok']) { mysql_query("delete from d_item where ThAng='{$ta}' and kdsatker='{$kdsatkerunit}' "); $i = 0; $no == 0; while ($i <= $jml) { $vdata = dbase_get_record_with_names($data, $i); $thang = $vdata["THANG"];
/** * Delete all of the entries marked for deletion */ public function pack() { return dbase_pack($this->db); }
global $hkdata; //sql building: BE CAREFUL NOT TO USE semicolon inside the sql!!!! $db->TruncateTable("hkmatrix"); //destroy table data $sql = "CREATE TABLE IF NOT EXISTS `hkmatrix` (\n `uid` int(11) NOT NULL AUTO_INCREMENT,\n `custgroup` varchar(4) NULL,\n `refnum` varchar(10) NULL,\n `prodgroup` varchar(254) NULL,\n `supplier` varchar(254) NULL,\n `prodcode` varchar(16) NULL,\n `matrix` varchar(1) NULL,\n `discount` decimal(10,2) NULL,\n `contract` decimal(10,2) NULL,\n `trade` decimal(10,2) NULL,\n `retail` decimal(10,2) NULL,\n `date_on` date DEFAULT NULL,\n `date_off` date DEFAULT NULL,\n\t`break1` decimal(5,2) NULL,\n\t\n\t`break2` decimal(5,2) NULL,\n\t\n\t`break3` decimal(5,2) NULL,\n\t\n\t`break4` decimal(5,2) NULL,\n\t\n\t`break5` decimal(5,2) NULL,\n\t\n\t`break6` decimal(5,2) NULL,\n\t\n\t`break7` decimal(5,2) NULL,\n\t`price1` decimal(10,2) NULL,`price2` decimal(10,2) NULL,`price3` decimal(10,2) NULL,`price4` decimal(10,2) NULL,`price5` decimal(10,2) NULL,`price6` decimal(10,2) NULL,`price7` decimal(10,2) NULL,\n\t `text` varchar(254) NULL,\n\t `type` varchar(4) NULL,\n PRIMARY KEY (`uid`)\n \n) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"; $results = $db->Query($sql); if (!$results) { die('Error contacting database!' . $sql); } // open in read-write mode if (function_exists('dbase_open')) { // only if php was compiled with dbase support $updatemsg .= "Packing database.<br/>"; $dbo = dbase_open('datastore/hkmatrix.dbf', 2); // expunge the database dbase_pack($dbo); } $dbr = new dbf_class('datastore/hkmatrix.dbf'); $num_rec = $dbr->dbf_num_rec; $field_num = $dbr->dbf_num_field; //print" Num_rec: $num_rec Num_field $field_num <br>"; for ($i = 0; $i < $num_rec; $i++) { //print"<br> Record : $i <br>================<br>"; $row = $dbr->getRow($i); if (is_array($row)) { $rowkeys = array_keys($row); $sql = "INSERT INTO hkmatrix (custgroup,refnum,prodgroup,supplier,prodcode,matrix,discount,contract,trade,retail,date_on,date_off,break1,break2,break3,break4,break5,break6,break7,price1,price2,price3,price4,price5,price6,price7,text,type) VALUES ("; $k = 0; //build SQL from db columns foreach ($rowkeys as $key) { if ($row[$key] == NULL) {
$fields = array(array("bool", DBFFIELD_TYPE_LOGICAL), array("memo", DBFFIELD_TYPE_MEMO), array("date", DBFFIELD_TYPE_DATE), array("number", DBFFIELD_TYPE_NUMERIC, 3, 0), array("string", DBFFIELD_TYPE_CHAR, 50)); $di = dbase_create("test/dbase.dbf", $fields); $xi = xbase_create("test/xbase.dbf", $fields); dbase_add_record($di, array("T", "abc", "20060120", 123, "string one")); dbase_add_record($di, array("F", "def", "20060121", 321, "string two")); dbase_add_record($di, array("F", "ghi", "20060121", 111, "string trio")); xbase_add_record($xi, array("T", "abc", "20060120", 123, "string one")); xbase_add_record($xi, array("F", "def", "20060121", 321, "string two")); xbase_add_record($xi, array("F", "ghi", "20060121", 111, "string trio")); dbase_close($di); xbase_close($xi); $di = dbase_open("test/dbase.dbf", 2); $xi = xbase_open("test/xbase.dbf", 2); dbase_delete_record($di, 2); xbase_delete_record($xi, 2); dbase_pack($di); xbase_pack($xi); dbase_close($di); xbase_close($xi); $di = dbase_open("test/dbase.dbf", 2); $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>";
/** * Deletes record from the DBF file * * @param integer $index * * @return void */ private function _deleteRecordFromDBF($index) { if (@dbase_delete_record($this->DBFFile, $index)) { dbase_pack($this->DBFFile); } }
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); } ?>
/** * @inheritdoc */ public function offsetUnset($offset) { if (isset($this[$offset])) { dbase_delete_record($this->_dbaseId, $offset + 1); dbase_pack($this->_dbaseId); } else { throw new OutOfRangeException(sprintf('Invalid index %s', $offset)); } }