$sql = 'SELECT name FROM user WHERE id = 123';
$user_name = $GLOBALS['dbi']->fetchValue($sql);
produces
$user_name = 'John Doe'
public fetchValue ( string $query, integer $row_number, integer | string $field, object $link = null ) : mixed | ||
$query | string | The query to execute |
$row_number | integer | row to fetch the value from, starting at 0, with 0 being default |
$field | integer | string | field to fetch the value from, starting at 0, with 0 being default |
$link | object | mysql link |
return | mixed | value of first field in first row from result or false if not found |
/** * Returns the CREATE statement for this table * * @return mixed */ public function showCreate() { return $this->_dbi->fetchValue('SHOW CREATE TABLE ' . Util::backquote($this->_db_name) . '.' . Util::backquote($this->_name), 0, 1); }