Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 14.02.2006, 05:58   #1
Firedaemon
Архивный участник
 
Join Date: Oct 2005
Posts: 267
Default [SHARE] Import itemname-e.txt into mySQL from PHP

Topic says all

[php:1:da72899f17]
<?php

$dblink = mysql_connect(, , );

($dblink) ? $dbselect = @mysql_select_db("") : DIE("Link to mySQL server could not be established.");

if (!$dbselect) DIE(mysql_error());

$row = 1;

$handle = fopen("itemname-e.txt", "r");

while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
{
$row++;

$query = "
INSERT INTO
`itemname-e`
SET
`id`=".$data[0].",
`name`='".addslashes($data[1])."',
`additionalname`='".addslashes($data[2])."',
`popup`='".$data[3]."',
`description`='".addslashes($data[4])."'
";

$result = mysql_query($query);

if ($result)
{
print $data[1]."\r\n";
}
else
{
print mysql_error();
sleep(30);
}
}

fclose($handle);
?>
[/php:1:da72899f17]

The SQL Schema
Code:
CREATE TABLE `itemname-e` (
  `id` int(12) NOT NULL,
  `name` varchar(255) NOT NULL,
  `additionalname` varchar(255) default NULL,
  `popup` int(2) NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=ascii;
Firedaemon is offline  
Old 14.02.2006, 06:00   #2
Firedaemon
Архивный участник
 
Join Date: Oct 2005
Posts: 267
Default

oh, and I should comment that this script assumes you have removed all the field information like "id=" and "name=[]" etc

If you want to store that info in the mysql table, the script can easily import it but you will need to change the data types in the mysql table so it can be stored properly.
Firedaemon is offline  
Old 14.02.2006, 06:39   #3
Alien003
Архивный участник
 
Join Date: Jun 2005
Posts: 143
Default

Isn't it much easy using the php from the php decryptor?
its not so easy to erase all the field information ...
Alien003 is offline  
Old 15.02.2006, 04:11   #4
Firedaemon
Архивный участник
 
Join Date: Oct 2005
Posts: 267
Default

Sure, if thats all you plan on doing. Personally, I have the entire client dats in mySQL. I am then able to create programs that perform a wide variety of tasks automatically for me. I also do the same thing with ALL of the server files as well. This allows me to easily sync changes when new versions of l2 come out and etc.
Firedaemon is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 19:52.