Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not read record #61

Closed
ghopretz opened this issue Nov 20, 2018 · 4 comments
Closed

can not read record #61

ghopretz opened this issue Nov 20, 2018 · 4 comments

Comments

@ghopretz
Copy link

Why cannot php xbase read record of this file?
tes2.zip

@nebojsac
Copy link

What error do you get? Do you know at which point it fails exactly? Sample code would help people help you.

@ghopretz
Copy link
Author

ghopretz commented Nov 20, 2018

it can read column count and column name, but it can not read while($record = $table->nextRecord()){}
i don't get error, but can not read record.
this is my code:

<?php
require 'DBFReader/XBase/Table.php';
require 'DBFReader/XBase/Column.php';
require 'DBFReader/XBase/Record.php';
require 'DBFReader/XBase/Memo.php';
require 'DBFReader/XBase/Exception/InvalidColumnException.php';
require 'DBFReader/XBase/Exception/TableException.php';

use XBase\Table;

$file = addslashes($_GET['file']);
/* buka koneksi database kita */
$user_name = "root";
$password = "";
$database = "db_sbh";
$host_name = "localhost";
	 
$koneksi=mysqli_connect($host_name, $user_name, $password, $database);
//$disable_full_group = mysqli_query($koneksi, "SET sql_mode = ''");

$table = new Table("file/$file.dbf");
//$table = new Table("tes2.dbf");
$columns = $table->getColumns();

$jmlkolom = count($columns);
/*
echo "<table border=1>";
echo "<thead><tr>";
foreach ($columns as $column) {
    echo "<td>".$column->name."</td>";//ambil nama semua kolom
}
echo "</tr></thead><tbody></table>";
*/

$row = 0;
while($record = $table->nextRecord()){
    //$idprop = $record->prop;//ambil isi kolom id prop
    
    $val = "";
    
    for($i=0; $i<$jmlkolom; $i++){
        if($i == $jmlkolom - 1){
            $val .= "'$record[$i]'";
        }else {
            $val .= "'$record[$i]', ";
        }
    }
    
    $sql = "INSERT INTO $file VALUES ($val)";
    mysqli_query($koneksi, $sql);
    echo "sql= ".$sql;
    
    $row++;
}
echo $row;

?>

@ghopretz
Copy link
Author

@luads

@mygoodboy
Copy link

echo $records->getString(ColumnName)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants