1
GlouGlou
Problem creating a bulk insert script.
  • 2004/7/5 13:46

  • GlouGlou

  • Just popping in

  • Posts: 1

  • Since: 2004/7/5 1


First of all i hope i posted in the right category.

I wanted to migrate my file database from my previous CMS to Xoops.

So, i made a small script to write directly in the xoops_mydownloads_mydownloads database and into the xoops_mydownloads_text database. My problem is: when i click on the link inserted, it doesnt work because XOOPS modify the url after i click on it

here is my insert query

$InsertQuery=
"insert into xoops_mydownloads_downloads "
. "(cid,title,url,size,logourl,submitter,status,date,homepage,version,platform) "
. "values (2,"
. "\"" . $title
. " \", \"" . $DownloadBaseUrl .$file . "\","
. filesize($file)
. ",\"". $ShotBaseUrl . $logourl
. "\",1,1,1088797669,\"\",\"\",\"\")";

and here is my insertcomment query ->

$GetMaxLidQuery=
"select MAX(lid) as truc from xoops_mydownloads_downloads";

$result = mysql_db_query($dbname, $GetMaxLidQuery) or die("Query failed with error message: \"" . mysql_error () . '"'. " ". $GetMaxLidQuery);

$MaxLid = mysql_result ($result,0,0);

$InsertDescriptionQuery= "insert into xoops_mydownloads_text (lid,description) values (". $MaxLid . ",\"". $FileDescription ."\")";


cid must be 2 because all files are in cat 2, i put a fake date (which is a real one) and status is "1" (i dont know what status is).

I have very low experience with Xoops/PHP and mySQL so maybe im missing something.

Thx in advance.

2
sottwell
Re: Problem creating a bulk insert script.
  • 2004/7/11 7:06

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


Did you check your database to see exactly what got inserted into the fields in question? I had a similar problem with avatars, viewing source showed truncated image filenames, and when I looked into the database (using phpmyadmin) I saw that the filenames were getting truncated on insertion because the field was limited to fewer characters than my filenames were using.

It would be easier for you if you cleaned up your queries; for example used a single-quote (') instead of double quote (") for your insert values so you wouldn't need to be escaping all those quotes. MySQL likes single-quotes just fine. You only need to escape them if they're used as part of an insert value (e.g. O'Reilley in a name field). Then, create simple variables to use in the query before writing the string; for example:

$url $DownloadBaseUrl $file;
$size filesize($file);
$thislogourl $ShotBaseUrl $logourl;


then you could have:

"insert into xoops_mydownloads_downloads 
 (cid,title,url,size,logourl,submitter,status,date,homepage,version,platform) 
 values (2,'
$title','$url','$size','$thislogourl',...etc";


Also usually in XOOPS it's a good idea to say:

"insert into " .XOOPS_DB_PREFIX"_mydownloads_downloads...


just in case somebody isn't using the default XOOPS table prefix.

Just a few thoughts I had that might help, since I'm also new at Xoops, although I've been working with PHP and MySQL for a few years.

Login

Who's Online

259 user(s) are online (140 user(s) are browsing Support Forums)


Members: 0


Guests: 259


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits