Can someone please provide an example of how to store, and read xml data into MySQL? I'm using php, and I've read this documentation: http://dev.mysql.com/doc/refman/5.6/en/xml-functions.html
But I simply cannot get results that I want.
Thank you very much. (I'm using this because I have a lot of calls to the data stored in the xml, and I need faster functions.)
[EDIT] As per request:
I currently have 30k .xml files with anywhere from 25-50 elements in each file. I ask for values in various files hundreds of times a second. I'm finding there's a huge bottleneck from the I/O actions preformed here.
I think storing the data from the .xml files into a database would make accessing the values a much faster process.
I'm asking for help/advice on how to go about this.
Accessing the data stored in the database will be no faster than accessing them on the disk. The database speed is provided by being able to index the data, and the contents of the XML is (I assume) not indexed.
So unless you can take key fields out of the XML it is not going to help you.
However, in answer to your actual question (rather than whether it is a good idea), if you are using a mysqli connection and a prepared statement:
if ($stmt = $mysqli->prepare("INSERT INTO MY_DATA_TABLE (Id, Data) VALUES(?,?)"))
{
$stmt->bind_param('ib', $id, $data);
for($i = 0; $i < $numfiles; $i++)
{
$id= $row;
$data= readfile($id);
$stmt->execute();
}
}
Something like that? (Haven't tried it).
EDIT:
But from your answer, if you just want to read the elements from the XML files, you probably need to look at simple XML: http://php.net/manual/en/book.simplexml.php