MyBB Community Forums

Full Version: How to check if row exists
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm having trouble with the _is_installed() function because my plugin doesn't create any new tables or columns that can be checked for. It only creates a row so I basically want to check if a row with the name '*** ***' exists. I haven't been able to find a good method to do that yet. Any ideas?
$query = $db->simple_select('TABLE', 'field name', 'name=\'value you want\'', array('limit => 1));
if (!$db->fetch_field($query, 'field name'))
	// error

Does this do what you want? I don't get exactly what you want to be honest Toungue
(2010-04-18, 05:24 PM)Pirata Nervo Wrote: [ -> ]
$query = $db->simple_select('TABLE', 'field name', 'name=\'value you want\'', array('limit => 1));
if (!$db->fetch_field($query, 'field name'))
	// error

Does this do what you want? I don't get exactly what you want to be honest Toungue

Close enough. I figured it out from there. Thanks!
To verify if a column exists, you could simply use :

    if($db->field_exists('field_name', "table_name")){
        return true;
    }

Or just test if one of your settings exists with Pirata method...
(2010-04-18, 05:44 PM)exdiogene Wrote: [ -> ]To verify if a column exists, you could simply use :

    if($db->field_exists('field_name', "table_name")){
        return true;
    }

Or just test if one of your settings exists with Pirata method...

I know, but as the original post mentioned, I don't have a column to verify.