<?php

namespace GriffinForms\Admin\Sql;

class Fields extends \GriffinForms\Admin\Sql\Lists
{
    protected function setSearchColumns()
    {
        $this->search_columns = array(
            'name',
            'heading',
            'description',
            'field_type'
        );
    }

    public function getReusableFieldCount()
    {
        global $wpdb;
        $table = $this->config->getTable('field');
        $count = $wpdb->get_var(
            $wpdb->prepare(
                'SELECT COUNT(id) AS ItemCount FROM %i WHERE is_reusable = 1',
                $table
                )
            );
        return $count;
    }

    protected function isReusableQuery($value)
    {
        return 'is_reusable= 1';
    }
}