Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mini SQL Plugin
#11
This looks very good. Wish you had released it a month ago. It would have saved me some time coding it. Smile

Great job.
Reply
#12
This user has been denied support. This user has been denied support.
Looks good. Very nice of you to release this under the GPL license too. Smile

You could add a small readme explaining how to install it, even if uploading is all you have to do. I was a bit confused at first since there were two files called mini_sql.php.

Some minor nitpicks with your code (feel free to ignore all of them):

In mini_sql/mini_sql*.php there is a broken windows/mac? linebreak in the first if

if(!defined("IN_MYBB"))^M{

PHP probably ignores all \r\n outside of strings, but maybe you want to fix it anyway.

The IN_MYBB check is also completely missing in the plugin mini_sql.php file, you should probably add it back.

'disporder' => 1,
'gid' => 17 // Server

There is no guarantee that group id 17 will be the server group (or that it exists at all), so in worst case that entry will be invalid. Also why do you think that your setting belongs to this group and has to be right at the top of it (disporder 1)?

;
   // I know this is may not good :)
   define('MINI_SQL_CONFIG_FILE', '../../../inc/plugins/mini_sql/mini_sql_config.php');
[...]
   // I know this is may not good :)
   define('MINI_SQL_FILE', '../../../inc/plugins/mini_sql/mini_sql.php');

You can use MYBB_ROOT or MYBB_ROOT.$mybb->config['admin_dir'].'/' depending on where you want to look for a file.

Minor nitpicks with your style (this is where programmers tend to get touchy so please ignore it completely):

mini_sql/mini_sql.php is a bit hard to read, since you break out of php ?> only to get html / javascript intermixed with <?php ?> statements followed by <?php again. Isn't doing this more cumbersome than having to escape a " quote here and there?

Your indentation and codestyle is inconsistent, you mix spaces with tabs, sometimes you write if(x) sometimes if (x) and while even becomes while ( x ).

I also have a feature request:
For forums that do not have a dedicated database, but share one database with other applications, it would be nice if the List of Table(s) could be restricted to tables with the MyBB table prefix. Similar to how it is done in Backups -> New Backup -> Select Forum Tables except that in this case it should probably a filters as in [X] Show only forum tables.

I also have a bug to report:
Show forum columns does not work right for me, I get a warning instead.
Warning [2] mysql_num_fields(): supplied argument is not a valid MySQL result resource - Line: 97 - File: inc/plugins/mini_sql/mini_sql.php PHP 5.2.8 (Linux)
File 	Line 	Function
[PHP] 	  	errorHandler->error
/inc/plugins/mini_sql/mini_sql.php 	97 	mysql_num_fields
/inc/plugins/mini_sql/mini_sql.php 	66 	mini_sql_generate_fields
/admin/index.php 	378 	require

Using PHP 5 and MySQL 5... it does show the columns despite this though.
Reply
#13
Quote:There is no guarantee that group id 17 will be the server group (or that it exists at all), so in worst case that entry will be invalid. Also why do you think that your setting belongs to this group and has to be right at the top of it (disporder 1)?

Well, when I choose 17 since I think It always be there and I did not find a feature in admin panel that delete the server configuration group. But my main reason was I did not put the User Interface in settings table but in files, so it just dummy value. But then I was wrong. So, I will fix it in next realase.

Quote:You can use MYBB_ROOT or MYBB_ROOT.$mybb->config['admin_dir'].'/' depending on where you want to look for a file.

You're right, I just noticed that $mybb global variable contains this settings. I never check it Blush

Quote:mini_sql/mini_sql.php is a bit hard to read, since you break out of php ?> only to get html / javascript intermixed with <?php ?> statements followed by <?php again. Isn't doing this more cumbersome than having to escape a " quote here and there?

Sorry, I read too many wordpress plugin so I got influenced Big Grin

Quote:Your indentation and codestyle is inconsistent, you mix spaces with tabs, sometimes you write if(x) sometimes if (x) and while even becomes while ( x ).

yeah... Big Grin I will try to consistent in next release

Quote:For forums that do not have a dedicated database, but share one database with other applications, it would be nice if the List of Table(s) could be restricted to tables with the MyBB table prefix. Similar to how it is done in Backups -> New Backup -> Select Forum Tables except that in this case it should probably a filters as in [X] Show only forum tables.

OK,

Quote:I also have a bug to report:
Show forum columns does not work right for me, I get a warning instead.

My box using Linux with MySQL 5 and PHP 5. I don't know is there any different between SHOW COLUMNS and SHOW FIELDS? MySQL 4/5?.

Many thanks frostschutz Smile
Reply
#14
For the right GID I do a quick query based on the name.

$query = $db->simple_select("settinggroups", "gid", "name='posting'");
$gid = $db->fetch_field($query, "gid");

The you can use $gid in the array...foolproof really. You may have to look in mysql in order to know all the names for the setting groups though. He is right that there is an inconsistency that exists between install and users. What might be gid 17 on one forum will be 22 on another.
Reply
#15
(2009-02-09, 03:03 AM)labrocca Wrote: For the right GID I do a quick query based on the name.

$query = $db->simple_select("settinggroups", "gid", "name='posting'");
$gid = $db->fetch_field($query, "gid");

The you can use $gid in the array...foolproof really. You may have to look in mysql in order to know all the names for the setting groups though. He is right that there is an inconsistency that exists between install and users. What might be gid 17 on one forum will be 22 on another.

thanks for the tips labrocca Smile
Reply
#16
Can do SQLite 2 ?
Reply
#17
(2009-04-27, 01:01 AM)qlan Wrote: Can do SQLite 2 ?

Means ??

(2009-02-09, 03:03 AM)labrocca Wrote: For the right GID I do a quick query based on the name.

$query = $db->simple_select("settinggroups", "gid", "name='posting'");
$gid = $db->fetch_field($query, "gid");

The you can use $gid in the array...foolproof really. You may have to look in mysql in order to know all the names for the setting groups though. He is right that there is an inconsistency that exists between install and users. What might be gid 17 on one forum will be 22 on another.

Hey Jesse, Great tip, I am using this technique in my future planed plugins, but the problem is it doesnot support myBB installed on local computer, OR perhaps my MyBB copy have errors, NOT sure about it Undecided
Reply
#18
This user has been denied support. This user has been denied support.
You would need some excellent admin control panel protection, good work though.
Reply
#19
Thanks Mate. I might use this, it saves me time going into phpmyadmin.
Your friendly neighbourhood lurker.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)