本文整理汇总了PHP中Illuminate\Database\Connection::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::select方法的具体用法?PHP Connection::select怎么用?PHP Connection::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Connection
的用法示例。
在下文中一共展示了Connection::select方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runSelect
/**
* Run the query as a "select" statement against the connection.
*
* @return array
*/
protected function runSelect()
{
if ($this->useWritePdo) {
return $this->connection->select($this->toSql(), $this->getBindings(), false);
}
return $this->connection->select($this->toSql(), $this->getBindings());
}
示例2: _explainAndShowIndex
private function _explainAndShowIndex(Connection $connection, $sql, $bindings)
{
$explainResults = $connection->select('explain ' . $sql, $bindings);
foreach ($explainResults as $explainResult) {
$results = get_object_vars($explainResult);
$results['sql'] = $sql;
$this->explainResults[] = $results;
if (empty($results['table'])) {
continue;
}
$showIndexResults = $connection->select('show index from ' . $results['table']);
foreach ($showIndexResults as $showIndexResult) {
$this->showIndexResults[] = get_object_vars($showIndexResult);
}
}
}
示例3: processInsertGetIdForOdbc
/**
* Process an "insert get ID" query for ODBC.
*
* @param \Illuminate\Database\Connection $connection
* @return int
*/
protected function processInsertGetIdForOdbc($connection)
{
$result = $connection->select('SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS int) AS insertid');
if (!$result) {
throw new Exception('Unable to retrieve lastInsertID for ODBC.');
}
return $result[0]->insertid;
}
示例4: getTableColumns
private function getTableColumns($callback = null)
{
if ($this->tableColumns === null) {
$this->tableColumns = $this->db->select('SHOW COLUMNS FROM ' . $this->table);
}
$filteredColumns = $callback ? array_filter($this->tableColumns, $callback) : $this->tableColumns;
return array_pluck($filteredColumns, 'Field');
}
示例5: exists
/**
* Determine if any rows exist for the current query.
*
* @return bool
*/
public function exists()
{
$sql = $this->grammar->compileExists($this);
$results = $this->connection->select($sql, $this->getBindings(), !$this->useWritePdo);
if (isset($results[0])) {
$results = (array) $results[0];
return (bool) $results['exists'];
}
}
示例6: get
/**
* Execute the query as a "select" statement.
*
* @param array $columns
* @return array
*/
public function get($columns = array('*'))
{
// If no columns have been specified for the select statement, we will set them
// here to either the passed columns, or the standard default of retrieving
// all of the columns on the table using the "wildcard" column character.
if (is_null($this->columns)) {
$this->columns = $columns;
}
$results = $this->connection->select($this->toSql(), $this->bindings);
$this->processor->processSelect($this, $results);
return $results;
}
示例7: runSelect
/**
* Run the query as a "select" statement against the connection.
*
* @return array
*/
protected function runSelect()
{
return $this->connection->select($this->toSql(), $this->getBindings());
}
示例8: getColumnListing
/**
* Get the column listing for a given table.
*
* @param string $table
* @return array
*/
public function getColumnListing($table)
{
$table = $this->connection->getTablePrefix() . $table;
$results = $this->connection->select($this->grammar->compileColumnExists($table));
return $this->connection->getPostProcessor()->processColumnListing($results);
}
示例9: select
/**
* Run a select statement against the database.
*
* @param string $query
* @param array $bindings
* @return \Stidges\LaravelDbNormalizer\Collection
*/
public function select($query, $bindings = array())
{
$records = parent::select($query, $bindings);
return $this->getNormalizer()->normalize($records);
}
示例10: hasTable
/**
* Determine if the given table exists.
*
* @param string $table
* @return bool
*/
public function hasTable($table)
{
$sql = $this->grammar->compileTableExists();
$table = $this->connection->getTablePrefix() . $table;
return count($this->connection->select($sql, array($table))) > 0;
}