Recent Topics

1 Jul 22, 2007 09:33    

I can make tables with a plugin, and do stuff like add or edit stuff, and that's cool, but I don't know how to tell it to have default stuff in the first place. Any takers?

2 Jul 22, 2007 10:36

Are you talking about a db table, and settings?

3 Jul 22, 2007 11:13

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?

4 Jul 22, 2007 13:58

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.

7 Jul 22, 2007 22:40

I'll look at both those hooks and see if I can make sense of it. Thanks!

9 Jul 23, 2007 14:50

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.

10 Jul 23, 2007 15:42

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!


Form is loading...