Hello, So I'm Creating a complex plugin which, in order to work needs to save and pull information from the elgg database... how would I use my plugin to create the tables within the database? This is the code i need to put into the database:
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for records
-- ----------------------------
CREATE TABLE `records` (
`recordID` int(11) NOT NULL auto_increment,
`recordText` varchar(255) default NULL,
`recordListingID` int(11) default NULL,
PRIMARY KEY (`recordID`)
);
-- ----------------------------
-- Records
-- ----------------------------
INSERT INTO `records` VALUES ('1', 'Once dropped, an Ajax query is activated', '3');
INSERT INTO `records` VALUES ('2', 'Dragging changes the opacity of the item', '2');
INSERT INTO `records` VALUES ('3', 'Returned array can be found at the right', '1');
INSERT INTO `records` VALUES ('4', 'It is very very easy', '4');
Then I need to know how I can link back to the elgg database, for example: I have a file called DB.php and inside that file consists of:
<?php
$dbhost = "localhost";
$dbuser = "";
$dbpass = "";
$dbname = "";
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ("Error connecting to mysql");
mysql_select_db($dbname);
?>
So what do I need to insert into this to allow it to connect to your elgg database? Thank you for all you help!
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Kevin Jardine@kevin
Kevin Jardine - 0 likes
- wer2chosen@wer2chosen
wer2chosen - 0 likes
You must log in to post replies.This has already been said many times, but I think that it is worth saying again:
Adding new tables to Elgg is a Bad Idea. It subverts the whole API and means that you can't use the many standard functions for updating, searching and listing entities that Elgg supplies out of the box.
In every case that I have seen so far, the person wanting to do this does not understand the Elgg API and is trying to do something that the standard API can do better and more easily.
MarkieDude, you may be the exception to this rule, but I really urge you to look at Elgg carefully before adding new tables.
I would agree. If you have allot of data and you determine that you need to store it outside of elgg. I would create a seperate database, expose it via a webservice or just interact directly. This will allow you to create facebook versions of your app or pure webbased versions. Since you didn't change the elgg database, upgrading shouldnt cause any issues.