Ejemplo n.º 1
0
function xbase_open($filename, $flags = 0)
{
    // - Opens a dBase database - flags : Typically 0 means read-only, 1 means write-only, and 2 means read and write
    if ($flags == 0) {
        $xbase = new XBaseTable($filename);
        if (!$xbase->open()) {
            return false;
        }
    } else {
        $xbase = new XBaseWritableTable($filename);
        if (!$xbase->openWrite()) {
            return false;
        }
    }
    return xbase_addInstance($xbase);
}
Ejemplo n.º 2
0
 	$JML11		= $Item->Fields(19);
 	$JML12		= $Item->Fields(20);
 	
 	$sql = "INSERT INTO d_trktrm(THANG, KDSATKER, KDDEPT, KDUNIT, KDPROGRAM, KDGIAT, RPHPAGU, KDTRKTRM, JNSBELANJA, JML01, JML02, JML03, 
 	JML04, JML05, JML06, JML07, JML08, JML09, JML10, JML11, JML12) VALUES ('".$THANG."', '".$KDSATKER."', '".$KDDEPT."', '".$KDUNIT."', 
 	'".$KDPROGRAM."', '".$KDGIAT."', '".$RPHPAGU."', '".$KDTRKTRM."', '".$JNSBELANJA."', '".$JML01."', '".$JML02."', '".$JML03."', 
 	'".$JML04."', '".$JML05."', '".$JML06."', '".$JML07."', '".$JML08."', '".$JML09."', '".$JML10."', '".$JML11."', '".$JML12."')";
 	
 	mysql_query($sql);
     				$Item->MoveNext();
 }
 
 $Item->Close();
 */
 $table_7 = new XBaseTable($tabel_7);
 $table_7->open();
 while ($record = $table_7->nextRecord()) {
     foreach ($table_7->getColumns() as $i => $c) {
         if ($c->getName() == "THANG") {
             $THANG = $record->getString($c);
         } else {
             if ($c->getName() == "KDSATKER") {
                 $KDSATKER = $record->getString($c);
             } else {
                 if ($c->getName() == "KDDEPT") {
                     $KDDEPT = $record->getString($c);
                 } else {
                     if ($c->getName() == "KDUNIT") {
                         $KDUNIT = $record->getString($c);
                     } else {
                         if ($c->getName() == "KDPROGRAM") {
Ejemplo n.º 3
0
*
* Demonstration how to clone table meta-data to another and copy records
*
**/
/* load the required classes */
require_once "Column.class.php";
require_once "Record.class.php";
require_once "Table.class.php";
require_once "WritableTable.class.php";
/* open a template table object and read it */
$tableParent = new XBaseTable("test/bond.DBF");
$tableParent->open();
/* create a new table */
$tableNew = XBaseWritableTable::cloneFrom($tableParent);
$tableNew->openWrite("test/created.dbf", true);
while ($record = $tableParent->nextRecord()) {
    $tableNew->appendRecord();
    $tableNew->record->copyFrom($record);
    $tableNew->writeRecord();
}
$tableNew->close();
$tableParent->close();
/* open created file*/
$table = new XBaseTable("test/created.dbf");
$table->open();
/* xml output */
echo "<pre>\n";
echo htmlspecialchars($table->toXML());
echo "</pre>\n";
/* close the table */
$table->close();
Ejemplo n.º 4
0
 function execute($id)
 {
     $row = $this->db->from('tb_upload')->where('id', $id)->get()->row();
     $path = getcwd() . '/tmp/';
     $filename = $row->filename;
     if (!file_exists($path . DIRECTORY_SEPARATOR . $row->code)) {
         echo mkdir($path . DIRECTORY_SEPARATOR . $row->code);
     }
     $this->_extract($path . $filename, $path . $row->code);
     $dir = scandir($path . $row->code);
     //echo 'path : '.$path.'<br>';
     //echo 'filename : '.$filename.'<br>';
     //echo 'row code : '.$row->code.'<br>';
     //print_r($dir);
     require_once './prodigy-dbf.php';
     /* load the required classes */
     require_once "phpxbase/Column.class.php";
     require_once "phpxbase/Record.class.php";
     require_once "phpxbase/Table.class.php";
     $sql = $sql2 = '';
     $this->db->query('USE staging_monev');
     $nullflags = 0;
     //foreach ($dir as $v) {
     //echo count($dir);
     for ($i = 2; $i < count($dir); $i++) {
         $exploded = explode($row->code, $dir[$i]);
         //echo ' <br> dudi : '.$exploded[0];
         /* buat object table dan buka */
         if (substr($exploded[0], -3) != "FPT" && $exploded[0] != "t_versi.DBF") {
             $table = new XBaseTable('tmp/' . $row->code . '/' . $exploded[0] . $row->code);
             $table->open();
             /*Create table */
             $create_table = "create table if not exists " . $exploded[0] . " ( ";
             $fields = $table->getColumns();
             for ($t = 0; $t < count($fields); $t++) {
                 $j = count($fields) - 1;
                 switch ($fields[$i]->type) {
                     case "C":
                         $type = "char";
                         break;
                     case "N":
                         $type = "varchar";
                         break;
                 }
                 if ($t == $j) {
                     $create_table .= $fields[$t]->name . " " . $type . "(" . $fields[$t]->length . ") null ";
                 } else {
                     $create_table .= $fields[$t]->name . " " . $type . "(" . $fields[$t]->length . ") null, ";
                 }
             }
             $create_table .= ");";
             //echo $create_table;
             $this->db->query($create_table);
             //insert data of table X
             while ($record = $table->nextRecord()) {
                 //$field = $table->getColumns();
                 $data = $record->choppedData;
                 $value_of_field = "'" . $data[0] . "'";
                 for ($val = 1; $val < count($data); $val++) {
                     $value_of_field .= ",'" . $data[$val] . "'";
                 }
                 $sql = "INSERT INTO " . $exploded[0] . " VALUES ({$value_of_field});";
                 $this->db->query($sql);
                 //echo $sql;
             }
             //end while
             $table->close();
         }
     }
     $this->db->update('db_monev.tb_upload', array('is_done' => true), array('id' => $id));
     redirect(site_url() . 'backend/queue');
 }