@param Driver $driver
@param array  $columns

@return StreamedResponse
5550
public function exportToExcel(Driver $driver, array $columns)
    {
        $csvData = $this->findAllRecords($driver, $columns);
        $response = new StreamedResponse(function () use ($csvData) {
            $resources = fopen('php://output', 'w');

            foreach ($csvData as $item) {
                fputcsv($resources, $item);
            }
        });

        $dispositionHeader = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, sprintf('%s.csv', date('YmdHis')));

        $response->headers->set('Content-Type', 'text/csv; charset=utf-8');
        $response->headers->set('Pragma', 'public');
        $response->headers->set('Cache-Control', 'maxage=1');
        $response->headers->set('Content-Disposition', $dispositionHeader);

        return $response;
    }
78804
public function findOrFail($id, $columns = ['*'])
    {
        if (Uuid::validate($id)) {
            return $this->findOrFailByUuid($id, $columns);
        } else {
            return parent::findOrFail($id, $columns);
        }
    }
251498
public function select($columns = "*") : QueryBuilder
    {
        $this->_query[] = "SELECT";

        //Parse column(s)
        if(is_array($columns)) {
            $select_columns = "";

            $size = sizeof($columns);
            for($i = 0; $i < $size; $i++) {
                if($i > 0) {
                    $select_columns .= ', ';
                }

                $select_columns .= '`'. $this->sanitize((string)$columns[$i]) .'`';
            }

            $this->_query[] = $select_columns;

            return $this;
        }

        $select_columns = "*";
        if(
            !empty($columns) &&
            $columns !== "*"
        ) {
            $select_columns = '`'. $this->sanitize((string)$columns) .'`';
        }

        $this->_query[] = $select_columns;

        return $this;
    }
1055581
public function select(string $column, string ...$columns)
    {
        $instance = $this->selectQueryInstance();

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

        return $instance;
    }
759864
public function withColumns(array $columns): self
    {
        $selector = clone $this;
        $selector->loader = $selector->loader->withColumns($columns);

        return $selector;
    }
1150392
public static function createConnectionObj($driver, array $config)
    {
        switch ($driver) {
            case 'mysql' :
                return new Mysql($config);
                break;
            case 'postgresql' :
                return new Postgresql($config);
                break;
            case 'sqlite' :
                return new Sqlite($config);
                break;
            case 'oracle' :
                return new Oracle($config);
                break;
            default :
                $debug_msg = "~/config/database.php文件配置错误！不支持的数据库驱动类型 - " . strval($driver);
                throw new \InvalidArgumentException($debug_msg);
        }
    }
1342021
public function driver($driver)
    {
        $this->container['sms.sender'] = $this->container->share(function ($app) use ($driver) {
            return (new DriverManager($app))->driver($driver);
        });

        $this->driver = $this->container['sms.sender'];
    }
220597
public function select($column, ...$columns) {
        $this->params = [];
        if (count($columns)) {
            array_unshift($columns, $column);
            $columnStr = implode('`,`', $columns);
            $this->sql = "SELECT `{$columnStr}` ";
        } else {
            $this->sql = "SELECT {$column} ";
        }
        return $this;
    }
303675
public function setColumns(array $columns)
    {
        foreach ($columns as $column) {
            $this->columns[] = new Request\Column($column);
        }

        return $this;
    }
836783
public function getFresh($columns = array('*'))
	{
		if (is_null($this->columns)) $this->columns = $columns;

        return $this->runSelect();
	}
377649
private function executeTableShowHeader(array $columns): void
  {
    $separator = '+';
    $header    = '|';

    foreach ($columns as $column)
    {
      $separator .= str_repeat('-', $column['length'] + 2).'+';
      $spaces    = ($column['length'] + 2) - mb_strlen((string)$column['header']);

      $spacesLeft  = (int)floor($spaces / 2);
      $spacesRight = (int)ceil($spaces / 2);

      $fillerLeft  = ($spacesLeft>0) ? str_repeat(' ', $spacesLeft) : '';
      $fillerRight = ($spacesRight>0) ? str_repeat(' ', $spacesRight) : '';

      $header .= $fillerLeft.$column['header'].$fillerRight.'|';
    }

    echo "\n", $separator, "\n";
    echo $header, "\n";
    echo $separator, "\n";
  }
875603
public function withColumns(array $columns): self
    {
        $loader = clone $this;
        $loader->columns = array_merge(
            [$loader->schema[Record::SH_PRIMARY_KEY]],
            $columns
        );

        return $loader;
    }
878930
public function insertBatchStream(string $tableName, array $columns = [], string $format = 'CSV')
    {
        if ($this->getCountPendingQueue() > 0) {
            throw new QueryException('Queue must be empty, before insertBatch, need executeAsync');
        }

        if (! in_array($format, self::SUPPORTED_FORMATS, true)) {
            throw new QueryException('Format not support in insertBatchFiles');
        }

        if (empty($columns)) {
            $sql = 'INSERT INTO ' . $tableName . ' FORMAT ' . $format;
        } else {
            $sql = 'INSERT INTO ' . $tableName . ' ( ' . implode(',', $columns) . ' ) FORMAT ' . $format;
        }

        return $this->transport()->writeStreamData($sql);
    }
1085671
public static function dump($where = [], $columns = [])
    {
        $columns = (empty($columns))
            ? static::COLUMNS
            : array_values(self::getTypedColumns($columns));

        $database = self::getDatabase();
        return $database->select(static::TABLE, $columns, $where);
    }
1215644
public function findOrFail($id, $columns = ['*'])
    {
        try {
            $resource = parent::findOrFail($id, $columns);
        } catch (ModelNotFoundException $e) {
            throw new NotFoundHttpException('Resource \'' . class_basename($e->getModel()) . '\' with given UUID ' . $id . ' not found');
        }

        return $resource;
    }
788092
public function getView(Driver $driver)
    {
        $output = array(
            'count' => 0,
            'data' => array(),
        );

        if ($this->request->isMethod('POST')) {
            $output = $this->doBulkCreate($driver);
        }

        if (0 === count($output['data'])) {
            $message = 'message.insert_bulk_failed';
        } else {
            $message = 'message.insert_bulk';
        }

        $this->view->setParam('status', empty($output['data']) ? false : true);
        $this->view->setParam('message', $this->translator->trans($message, array(
            '%count%' => count($output['data']),
            '%deleted%' => $output['count'],
            '%data%' => implode(', ', $output['data']),
        ), $this->translationDomain));

        return $this->view;
    }
205526
public function delete(array $columns = null): \PDOStatement
    {
        /* @var $response \PDOStatement */
        $queryObject = $this->getQuery('delete', $columns);

        $this->connection->setLastQuery($queryObject);

        $this->fireEvents(EventHandler::EVENT_BEFORE_DELETE, $queryObject);

        [$response, $executionTime] = $this->statement($queryObject->getSql(), $queryObject->getBindings());
        $this->fireEvents(EventHandler::EVENT_AFTER_DELETE, $queryObject, [
            'execution_time' => $executionTime,
        ]);

        return $response;
    }