vendor/davedevelopment/phpmig/src/Phpmig/Adapter/Illuminate/Database.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
/**
 * @package    Phpmig
 * @subpackage Phpmig\Adapter
 */
namespace Phpmig\Adapter\Illuminate;

use PDO;
use \Phpmig\Migration\Migration,
    \Phpmig\Adapter\AdapterInterface;
use RuntimeException;

/**
 * @author Andrew Smith http://github.com/silentworks
 */
class Database implements AdapterInterface
{
    /**
     * @var string
     */
    protected $tableName;

    /**
     * @var \Illuminate\Database\Connection
     */
    protected $adapter;

    public function __construct($adapter, $tableName, $connectionName = '')
    {
        $this->adapter = $adapter->connection($connectionName);
        $this->tableName = $tableName;
    }

    /**
     * Get all migrated version numbers
     *
     * @return array
     */
    public function fetchAll()
    {
        $fetchMode = (method_exists($this->adapter, 'getFetchMode')) ?
            $this->adapter->getFetchMode() : PDO::FETCH_OBJ;

        $all = $this->adapter
            ->table($this->tableName)
            ->orderBy('version')
            ->get();

        if(!is_array($all)) {
            $all = $all->toArray();
        }

        return array_map(function($v) use($fetchMode) {

            switch ($fetchMode) {

                case PDO::FETCH_OBJ:
                    return $v->version;

                case PDO::FETCH_ASSOC:

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。