Funktie werkt maar half met vullen db
Ik heb de volgende funktie:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function menu_install() {
global $bbdb;
$query = "CREATE TABLE `$bbdb->menu` (
`set` varchar(50) NOT NULL default '',
`item` varchar(50) NOT NULL default '',
`page` varchar(50) NOT NULL default '',
`is` varchar(150) NOT NULL default '',
`order` int(9) NOT NULL default '0',
PRIMARY KEY (`set`,`item`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$bbdb->query($query);
$sql = "INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Forums', 'index.php', 'is_front() || is_forum() || is_tag() || is_topic() || is_bb_feed() || is_bb_profile() || is_bb_favorites() || is_view()', 0);
INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Search', 'search.php', 'is_bb_search()', 0);
INSERT INTO `$bbdb->menu` VALUES ('left_col', 'Statistics', 'statistics.php', 'is_bb_stats()', 0);";
$bbdb->query($sql);
return $bbdb->query("SHOW TABLES LIKE '$bbdb->menu'");
}
global $bbdb;
$query = "CREATE TABLE `$bbdb->menu` (
`set` varchar(50) NOT NULL default '',
`item` varchar(50) NOT NULL default '',
`page` varchar(50) NOT NULL default '',
`is` varchar(150) NOT NULL default '',
`order` int(9) NOT NULL default '0',
PRIMARY KEY (`set`,`item`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$bbdb->query($query);
$sql = "INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Forums', 'index.php', 'is_front() || is_forum() || is_tag() || is_topic() || is_bb_feed() || is_bb_profile() || is_bb_favorites() || is_view()', 0);
INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Search', 'search.php', 'is_bb_search()', 0);
INSERT INTO `$bbdb->menu` VALUES ('left_col', 'Statistics', 'statistics.php', 'is_bb_stats()', 0);";
$bbdb->query($sql);
return $bbdb->query("SHOW TABLES LIKE '$bbdb->menu'");
}
Het aanmaken van de tabel werkt perfect, alleen vult hij hem niet. Wat doe ik verkeerd?
Thx
Gewijzigd op 01/01/1970 01:00:00 door Maurice prive
ik zou als ik jou was de backticks vermijden (`)
Welke? Er zijn er zoveel :)
Maurice schreef op 18.01.2007 22:45:
Welke? Er zijn er zoveel :)
allemaal.
In dit geval zal blijken dat je slechts 1 query tegelijk naar de database kunt sturen. 3 (insert-)queries tegelijk gaat dus fout.
En hoe los ik dat dan op zodat die inserts wel goed gaan?
Code (php)
1
2
3
4
5
2
3
4
5
<?php
$sql = "INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Forums', 'index.php', 'is_front() || is_forum() || is_tag() || is_topic() || is_bb_feed() || is_bb_profile() || is_bb_favorites() || is_view()', 0)";
$sql2= " INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Search', 'search.php', 'is_bb_search()', 0)";
$sql3="INSERT INTO `$bbdb->menu` VALUES ('left_col', 'Statistics', 'statistics.php', 'is_bb_stats()', 0);";
?>
$sql = "INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Forums', 'index.php', 'is_front() || is_forum() || is_tag() || is_topic() || is_bb_feed() || is_bb_profile() || is_bb_favorites() || is_view()', 0)";
$sql2= " INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Search', 'search.php', 'is_bb_search()', 0)";
$sql3="INSERT INTO `$bbdb->menu` VALUES ('left_col', 'Statistics', 'statistics.php', 'is_bb_stats()', 0);";
?>
Gewijzigd op 01/01/1970 01:00:00 door patrick G
Code (php)
1
2
3
4
2
3
4
mysql_query ("INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Forums', 'index.php', 'is_front() || is_forum() || is_tag() || is_topic() || is_bb_feed() || is_bb_profile() || is_bb_favorites() || is_view()', 0)");
mysql_query ("INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Search', 'search.php', 'is_bb_search()', 0)");
mysql_query ("INSERT INTO `$bbdb->menu` VALUES ('left_col', 'Statistics', 'statistics.php', 'is_bb_stats()', 0)");
Dit is correct gebeurd?
Het geheel is nu:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function menu_install() {
global $bbdb;
$query = "CREATE TABLE `$bbdb->menu` (
`set` varchar(50) NOT NULL default '',
`item` varchar(50) NOT NULL default '',
`page` varchar(50) NOT NULL default '',
`is` varchar(150) NOT NULL default '',
`order` int(9) NOT NULL default '0',
PRIMARY KEY (`set`,`item`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$bbdb->query($query);
mysql_query ("INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Forums', 'index.php', 'is_front() || is_forum() || is_tag() || is_topic() || is_bb_feed() || is_bb_profile() || is_bb_favorites() || is_view()', 0)");
mysql_query ("INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Search', 'search.php', 'is_bb_search()', 0)");
mysql_query ("INSERT INTO `$bbdb->menu` VALUES ('left_col', 'Statistics', 'statistics.php', 'is_bb_stats()', 0)");
}
global $bbdb;
$query = "CREATE TABLE `$bbdb->menu` (
`set` varchar(50) NOT NULL default '',
`item` varchar(50) NOT NULL default '',
`page` varchar(50) NOT NULL default '',
`is` varchar(150) NOT NULL default '',
`order` int(9) NOT NULL default '0',
PRIMARY KEY (`set`,`item`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$bbdb->query($query);
mysql_query ("INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Forums', 'index.php', 'is_front() || is_forum() || is_tag() || is_topic() || is_bb_feed() || is_bb_profile() || is_bb_favorites() || is_view()', 0)");
mysql_query ("INSERT INTO `$bbdb->menu` VALUES ('right_col', 'Search', 'search.php', 'is_bb_search()', 0)");
mysql_query ("INSERT INTO `$bbdb->menu` VALUES ('left_col', 'Statistics', 'statistics.php', 'is_bb_stats()', 0)");
}
Gewijzigd op 01/01/1970 01:00:00 door Maurice prive