Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
sting
Involved
Involved



Joined: Sep 23, 2003
Posts: 456
Location: Somewhere out there...

PostPosted: Thu Jun 29, 2006 6:25 pm Reply with quote

Anyone had any experience or know how to pull data from a dbase iv export (.dbf) into MySql via PHP?

The files 'appear' tab delimited, but upon further review (and opening through Excel) it is clear that they are not.

I can pull them into Excel and Access with no problem (and from there get them to MySql) but need a way to automate this through PHP if possible.

I know of the dbase_open and associated utilities, but have never used them against straight flat export files and definitely not through Nuke - any ideas as to how I would go about successfully calling this function from within a php-nuke module? Its not in the nuke includes, so am curious as to how that is done.

Thanks in advance...

-sting, who once again feels 'n00bish'.

_________________
You see - I told you I wasn't paranoid. They were really out to get me. 
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
gregexp
The Mouse Is Extension Of Arm



Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol

PostPosted: Thu Jun 29, 2006 6:33 pm Reply with quote

have you attempted fopen?

like this:
$fp = fopen ("yourfile.ext", "r");
$bytes = "10000000000";
$buffer = fread($fp, $bytes);
fclose ($fp);
$buffer1 = "$buffer";
$query = "";
if ($p_transaction_safe) {
$buffer2 = 'START TRANSACTION;' . $buffer1 . '; COMMIT;';
};
$query_split = preg_split ("/[;]+/", $buffer2);
foreach ($query_split as $command_line) {
$command_line = trim($command_line);
if ($command_line != '') {
$query_result = mysql_query($command_line);
if ($query_result == 0) {
echo "$buffer";
};
};

};

return $query_result;

_________________
For those who stand shall NEVER fall and those who fall shall RISE once more!! 
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
sting







PostPosted: Thu Jun 29, 2006 6:52 pm Reply with quote

Can't say that I have - I am familiar with direct file reads, but haven't tried it on this as the format was dbase iv - can you explain some of it?

For example:
Quote:

preg_split ("/[;]+/", $buffer2);


How is this representative of DbaseIV data vs any other type of data?

(Sorry, code newb on this one...)

-sting
 
sting







PostPosted: Thu Jun 29, 2006 8:52 pm Reply with quote

Just read this on the php.net pages -

Quote:
In order to enable the bundled dbase library and to use these functions, you must compile PHP with the --enable-dbase option.


Anyone know of a way to determine whether or not my ISP is using that option? (Without asking them of course). . .

-sting
 
gregexp







PostPosted: Thu Jun 29, 2006 9:18 pm Reply with quote

ok
this is what this does, if ur file works on phpmyadmin, as is, content wise, then this script, that line in particular breaks it all down into sql commands, since mysql_query can only run one command at a time

this buffers as many commands(seperated by the semi-colin) into a variable, then applys each line as a SINGLE sql command until it is finished running all the info it has buffered and since the buffer variable is feined as the contents on a file, it breaks the contents down to one command per ;

so now instead of it running mysql_query ("1;2;3;4;5;6;7;8;9;0;");
which will not run

This will run

mysql_query("1");
mysql_query("2");
mysql_query("3");
mysql_query("4");
etc

phpinfo() should allow u to find out.

but it wouldnt run nuke if it was disabled(i believe)
 
sting







PostPosted: Thu Jun 29, 2006 9:30 pm Reply with quote

You know I haven't tried reading it directly from phpMyAdmin - let me play with that and see what happens.

Thanks for the idea(s)

-sting
 
sting







PostPosted: Thu Jun 29, 2006 9:33 pm Reply with quote

Nope, its as I expected - doesn't read it in at all.. gets hung up on the tabs and the format from the dbf export.

I can open these things all day long in Excel and in Access, which I could then export to a MySql query, but I much prefer the idea of loading it directly from the php source.

Thanks so far for the brainstorming...

-sting
 
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri Jun 30, 2006 12:03 am Reply with quote

sting wrote:
Just read this on the php.net pages -

Quote:
In order to enable the bundled dbase library and to use these functions, you must compile PHP with the --enable-dbase option.


Anyone know of a way to determine whether or not my ISP is using that option? (Without asking them of course). . .

-sting

Run phpinfo();
 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Wed Jul 05, 2006 5:44 pm Reply with quote

sting, do mind posting a few lines of the .dbf file here?

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©