Checks if given field(s) in a given table exists.

@param   string         $table    Table name
@param   string|array   $columns  columns to check
@return  bool
190378
public static function field_exists($table, $columns, $db = null)
	{
		if ( ! is_array($columns))
		{
			$columns = array($columns);
		}

		try
		{
			\DB::select_array($columns)->from($table)->limit(1)->execute($db ? $db : static::$connection);
			return true;
		}
		catch (\Database_Exception $e)
		{
			// check if we have a DB connection at all
			$connection = \Database_Connection::instance($db ? $db : static::$connection)->has_connection();

			// if no connection could be made, re throw the exception
			if ( ! $connection)
			{
				throw $e;
			}

			return false;
		}
	}
386076
public static function table_exists($table, $db = null)
	{
		try
		{
			\DB::select()->from($table)->limit(1)->execute($db ? $db : static::$connection);
			return true;
		}
		catch (\Database_Exception $e)
		{
			// check if we have a DB connection at all
			$connection = \Database_Connection::instance($db ? $db : static::$connection)->has_connection();

			// if no connection could be made, re throw the exception
			if ( ! $connection)
			{
				throw $e;
			}

			return false;
		}
	}
1284509
public function table_exists( Table $table ) {

		$statement = new GenericStatement( "SHOW TABLES LIKE %s" );
		$result = $this->database
			->query_statement( $statement, [ (string) $table ] );

		if ( ! $result->valid() )
			return FALSE;

		/**
		 * @todo refactor this as soon as
		 * we have unified options bit-mask implemented
		 * to get results in single-level arrays
		 *
		 * return $result->contains( $table );
		 */

		$tables = [];
		foreach ( $result as $row ) {
			$tables = array_merge(
				$tables,
				array_values(
					get_object_vars( $row )
				)
			);
		}
		return in_array( $table, $tables );
	}
934220
protected function findColumns($table)
	{
		$columnsTable="INFORMATION_SCHEMA.COLUMNS";
		$where=array();
		$where[]="t1.TABLE_NAME='".$table->name."'";
		if (isset($table->catalogName))
		{
			$where[]="t1.TABLE_CATALOG='".$table->catalogName."'";
			$columnsTable = $table->catalogName.'.'.$columnsTable;
		}
		if (isset($table->schemaName))
			$where[]="t1.TABLE_SCHEMA='".$table->schemaName."'";

		$sql="SELECT t1.*, columnproperty(object_id(t1.table_schema+'.'+t1.table_name), t1.column_name, 'IsIdentity') AS IsIdentity, ".
			 "CONVERT(VARCHAR, t2.value) AS Comment FROM ".$this->quoteTableName($columnsTable)." AS t1 ".
			 "LEFT OUTER JOIN sys.extended_properties AS t2 ON t1.ORDINAL_POSITION = t2.minor_id AND ".
			 "object_name(t2.major_id) = t1.TABLE_NAME AND t2.class=1 AND t2.class_desc='OBJECT_OR_COLUMN' AND t2.name='MS_Description' ".
			 "WHERE ".join(' AND ',$where);
		try
		{
			$columns=$this->getDbConnection()->createCommand($sql)->queryAll();
			if(empty($columns))
				return false;
		}
		catch(Exception $e)
		{
			return false;
		}

		foreach($columns as $column)
		{
			$c=$this->createColumn($column);
			if (is_array($table->primaryKey))
				$c->isPrimaryKey=in_array($c->name, $table->primaryKey);
			else
				$c->isPrimaryKey=strcasecmp($c->name,$table->primaryKey)===0;

			$c->isForeignKey=isset($table->foreignKeys[$c->name]);
			$table->columns[$c->name]=$c;
			if ($c->autoIncrement && $table->sequenceName===null)
				$table->sequenceName=$table->name;
		}
		return true;
	}
122902
private function checkColumns($ok, $table, $cols)
    {
        $fords = false;
        foreach ($cols as $ck => $cv) {
          if ($cv instanceof Expression || $cv instanceof Select || is_string($cv)) {
            if ($ok === $ck) {
                $fords = $ok;
                break;
            } elseif (
              ($cv instanceof Expression && $ok === $cv->getExpression()) ||
              (str_replace('.','$',$ok) === $ck) ||
              (is_string($cv) && ($ok == $table . '.' . $cv) ) ) {
                $fords = $ck;
                break;
            }
          }
        }

        return $fords;
    }
306988
public function tableExists($table)
    {
        $result = $this->query("SHOW TABLES LIKE " . $this->pdo->quote($table));
        return $result->rowCount() > 0;
    }
349175
public function hasTable($table)
    {
        [$schema, $table] = $this->parseSchemaAndTable($table);

        $table = $this->connection->getTablePrefix().$table;

        return count($this->connection->select(
            $this->grammar->compileTableExists(), [$schema, $table]
        )) > 0;
    }
914614
public function select($columns = null, $table = null){
		$result = new Result($this->connection, $columns, $table);
		foreach($this->observers as $observer){
			$result->attachObserver($observer, $this->observers->getInfo());
		}
		return $result;
	}
1055581
public function select(string $column, string ...$columns)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->columns($column, ...$columns);

        return $instance;
    }
1247362
public function hasColumn($table, $column)
    {
        $column = strtolower($column);

        return in_array($column, array_map('strtolower', $this->getColumnListing($table)));
    }
802776
protected function checkFilterColumn($column): bool
    {
        return array_key_exists($column, $this->getAllowFilters()) ||
            \in_array($column, $this->getAllowFilters(), false);
    }
1308655
public function tableExists($table)
	{
		$query = 'SHOW TABLES LIKE ' . str_replace('#__', $this->tablePrefix, $this->quote($table, false));
		$this->setQuery($query)->execute();

		return ($this->getAffectedRows() > 0) ? true : false;
	}
538381
public function isFieldExists($table, $field)
	{
		if (isset($this->tables[$table])) {
			$fields = $this->getFields($table);

			return $fields->where('name', $field)->count() > 0;
		}

		return false;
	}
484318
protected function findColumns($table)
	{
		// it may be good to use CUBRID PHP API to retrieve column info.
		$sql='SHOW COLUMNS FROM '.$table->rawName;
		try
		{
			$columns=$this->getDbConnection()->createCommand($sql)->queryAll();
		}
		catch(Exception $e)
		{
			return false;
		}
		foreach($columns as $column)
		{
			$c=$this->createColumn($column);
			$table->columns[$c->name]=$c;
		}
		return true;
	}
435778
public function into($table, array $columns = [])
    {
        if (count($columns)) {
            $this->setColumns($columns);
        }

        return $this->addRootTable($table);
    }
810722
public function FieldExists($Table, $Field) {
      if (array_key_exists($Table, $this->_Schema)
         && is_array($this->_Schema[$Table])
         && array_key_exists($Field, $this->_Schema[$Table])
         && is_object($this->_Schema[$Table][$Field]))
         return TRUE;
      else
         return FALSE;
   }
357366
def column_exists(self, tablename: str, column: str) -> bool:
        """"""
        sql = """
            SELECT COUNT(*)
            FROM information_schema.columns
            WHERE table_name=?
            AND column_name=?
            AND table_schema={}
        """.format(self.get_current_schema_expr())
        row = self.fetchone(sql, tablename, column)
        return True if row[0] >= 1 else False