2 balupton Jul 22, 2007 10:36

Yes and no.
function GetDbLayout() {
return array(
"CREATE TABLE IF NOT EXISTS ".$this->get_sql_table('Sites')." (
name varchar(50) NOT NULL default '',
latitude varchar(12) NOT NULL default '',
longitude varchar(12) NOT NULL default '',
PRIMARY KEY (name)
)",
);
}
That's a snip that basically shows where I'm at. So how do I tell it what Site #1 is upon installation?
Honestly, I have no fricking clue. I find b2evo's db interface extremely confusing. And the only plugin i've made that actually uses the db is the gallery plugin, and in that I tried to stay away from b2evo as much as possible. And in non b2evo projects, I have written my own OO db interface (about 5 months straight of dev) which I use in all my commercial projects. So I hardly touch SQL.
You want to look into [url=http://doc.b2evolution.net/v-1-10/plugins/Plugin.html#methodAfterInstall]AfterInstall()[/url] ;)
¥
¥åßßå wrote:
You want to look into AfterInstall() Wink
¥
No, there is a reference to DB install in [url=http://doc.b2evolution.net/v-1-10/plugins/Plugin.html#methodBeforeInstall]BeforeInstall()[/url].
I ran through the code of the Democracy Plugin. It found the function as cited by EdB, but I can't figure out when it is called.
I'll look at both those hooks and see if I can make sense of it. Thanks!
Afwas wrote:
No, there is a reference to DB install in [url=http://doc.b2evolution.net/v-1-10/plugins/Plugin.html#methodBeforeInstall]BeforeInstall()[/url].
Yeah, but that wasn't the question ;)
¥
EdB, did you ever get this sorted. I usually just do something like this:
function whateverHookYoureUsing()
{
global $DB;
$sql = "INSERT INTO " . $this->get_sql_table('Sites') . " (name, lattitude, longitude) VALUES ('$name', '$lattitude', '$longitude')"
$DB->query( $sql );
}
Daniel's dnsbl plugin is a good example of the things you can do with $DB.
been doing the work thing again so I haven't had the chance to play, but I also thought why not just do a dbinsert after I make the database? Either way, it shouldn't be a big problem to get some content in the database upon creation.
Thanks!
Hooray for AfterInstall()!
Are you talking about a db table, and settings?