These lines of code gets me out this error and i cannot understand it $number_to_keep = db_select('variable', 'va')
    -&gt;fields('va.value')
    -&gt;condition('va.name', 'dblog_row_limit', '=')
    -&gt;execute();


And it gets me out that errors:

Notice: Undefined index: table in SelectQuery->preExecute() (line 1245 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->compile() (line 1079 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->compiled() (line 1097 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: arguments in SelectQuery->arguments() (line 1024 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->arguments() (line 1028 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->compiled() (line 1097 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->__toString() (line 1531 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->__toString() (line 1538 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: alias in SelectQuery->__toString() (line 1543 of /var/www/html/drupal/includes/database/select.inc).
The signature for SelectQuery::fields() is:

public SelectQuery::fields($table_alias, array $fields = array())


So you need:

$number_to_keep = db_select('variable', 'va')
  -&gt;fields('va', array('value'))
  -&gt;condition('va.name', 'dblog_row_limit', '=')
  -&gt;execute();