Connection to Mysql could not be established: SQLSTATE[HY000] [1044] Access denied for user 'ytc_30003'@'localhost' to database 'yokopine_webapp'
$retry = new CommandRetry(new ErrorCodeWaitStrategy(static::RETRY_ERROR_CODES, 5), 4); |
|
try { |
|
$retry->run($action); |
|
} catch (PDOException $e) { |
|
throw new MissingConnectionException( |
|
[ |
|
'driver' => App::shortName(static::class, 'Database/Driver'), |
|
'reason' => $e->getMessage(), |
|
], |
if (!empty($config['encoding'])) { |
|
$dsn .= ";charset={$config['encoding']}"; |
|
} |
|
|
|
$this->_connect($dsn, $config); |
|
|
|
if (!empty($config['init'])) { |
|
$connection = $this->getConnection(); |
|
foreach ((array)$config['init'] as $command) { |
* @param \Cake\Database\DriverInterface $driver The driver to use. |
|
*/ |
|
public function __construct(DriverInterface $driver) |
|
{ |
|
$driver->connect(); |
|
$this->_driver = $driver; |
|
} |
|
|
|
/** |
*/ |
|
public function schemaDialect(): SchemaDialect |
|
{ |
|
if ($this->_schemaDialect === null) { |
|
$this->_schemaDialect = new MysqlSchemaDialect($this); |
|
} |
|
|
|
return $this->_schemaDialect; |
|
} |
*/ |
|
public function __construct(Connection $connection) |
|
{ |
|
$this->_connection = $connection; |
|
$this->_dialect = $connection->getDriver()->schemaDialect(); |
|
} |
|
|
|
/** |
|
* Get the list of tables available in the current connection. |
} |
|
|
|
if (!empty($this->_config['cacheMetadata'])) { |
|
return $this->_schemaCollection = new CachedCollection( |
|
new SchemaCollection($this), |
|
empty($this->_config['cacheKeyPrefix']) ? $this->configName() : $this->_config['cacheKeyPrefix'], |
|
$this->getCacher() |
|
); |
|
} |
{ |
|
if ($this->_schema === null) { |
|
$this->_schema = $this->_initializeSchema( |
|
$this->getConnection() |
|
->getSchemaCollection() |
|
->describe($this->getTable()) |
|
); |
|
if (Configure::read('debug')) { |
|
$this->checkAliasLengths(); |
*/ |
|
public function addDefaultTypes(Table $table) |
|
{ |
|
$alias = $table->getAlias(); |
|
$map = $table->getSchema()->typeMap(); |
|
$fields = []; |
|
foreach ($map as $f => $type) { |
|
$fields[$f] = $fields[$alias . '.' . $f] = $fields[$alias . '__' . $f] = $type; |
|
} |
parent::__construct($connection); |
|
$this->repository($table); |
|
|
|
if ($this->_repository !== null) { |
|
$this->addDefaultTypes($this->_repository); |
|
} |
|
} |
|
|
|
/** |
* @return \Cake\ORM\Query |
|
*/ |
|
public function query(): Query |
|
{ |
|
return new Query($this->getConnection(), $this); |
|
} |
|
|
|
/** |
|
* Creates a new Query::subquery() instance for a table. |
* @return \Cake\ORM\Query The query builder |
|
*/ |
|
public function find(string $type = 'all', array $options = []): Query |
|
{ |
|
$query = $this->query(); |
|
$query->select(); |
|
|
|
return $this->callFinder($type, $query, $options); |
|
} |
} |
|
|
|
public function findByCode($productCode) |
|
{ |
|
$productClasse = $this->find() |
|
->where([ |
|
'product_code' => $productCode, |
|
'class_category_id1 IS' => null, |
|
'class_category_id2 IS' => null]) |
|
|
if(false !== mb_strpos($param1, 'html')) { |
|
// 商品の場合は商品明細にリダイレクト |
|
$productCode = str_replace('.html', '', $param1); |
|
$productClasse = $this->ProductClasses->findByCode($productCode); |
|
if(!empty($productClasse)) { |
|
$newUrl = SITE_URL.'netshop/products/detail/'.$productClasse->product_id; |
|
} |
|
|
* @throws \UnexpectedValueException If return value of action is not `null` or `ResponseInterface` instance. |
|
*/ |
|
public function invokeAction(Closure $action, array $args): void |
|
{ |
|
$result = $action(...$args); |
|
if ($result !== null && !$result instanceof ResponseInterface) { |
|
throw new UnexpectedValueException(sprintf( |
|
'Controller actions can only return ResponseInterface instance or null. ' |
|
. 'Got %s instead.', |
} |
|
if (count($passed)) { |
|
$args = array_merge($args, $passed); |
|
} |
|
$controller->invokeAction($action, $args); |
|
|
|
$result = $controller->shutdownProcess(); |
|
if ($result instanceof ResponseInterface) { |
|
return $result; |
} |
|
|
|
$controller = $this->controllerFactory->create($request); |
|
|
|
return $this->controllerFactory->invoke($controller); |
|
} |
|
} |
|
|
return $middleware->process($request, $this); |
|
} |
|
|
|
if ($this->fallbackHandler) { |
|
return $this->fallbackHandler->handle($request); |
|
} |
|
|
|
$response = new Response([ |
|
'body' => 'Middleware queue was exhausted without returning a response ' |
if ($method === 'GET' && $cookieData === null) { |
|
$token = $this->createToken(); |
|
$request = $request->withAttribute('csrfToken', $this->saltToken($token)); |
|
/** @var mixed $response */ |
|
$response = $handler->handle($request); |
|
|
|
return $this->_addTokenCookie($token, $request, $response); |
|
} |
|
|
if ($this->queue->valid()) { |
|
$middleware = $this->queue->current(); |
|
$this->queue->next(); |
|
|
|
return $middleware->process($request, $this); |
|
} |
|
|
|
if ($this->fallbackHandler) { |
|
return $this->fallbackHandler->handle($request); |
*/ |
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
{ |
|
if (!in_array($request->getMethod(), $this->methods, true)) { |
|
return $handler->handle($request); |
|
} |
|
[$type] = explode(';', $request->getHeaderLine('Content-Type')); |
|
$type = strtolower($type); |
|
if (!isset($this->parsers[$type])) { |
if ($this->queue->valid()) { |
|
$middleware = $this->queue->current(); |
|
$this->queue->next(); |
|
|
|
return $middleware->process($request, $this); |
|
} |
|
|
|
if ($this->fallbackHandler) { |
|
return $this->fallbackHandler->handle($request); |
); |
|
} |
|
$matching = Router::getRouteCollection()->getMiddleware($middleware); |
|
if (!$matching) { |
|
return $handler->handle($request); |
|
} |
|
|
|
$middleware = new MiddlewareQueue($matching); |
|
$runner = new Runner(); |
if ($this->queue->valid()) { |
|
$middleware = $this->queue->current(); |
|
$this->queue->next(); |
|
|
|
return $middleware->process($request, $this); |
|
} |
|
|
|
if ($this->fallbackHandler) { |
|
return $this->fallbackHandler->handle($request); |
} |
|
|
|
$assetFile = $this->_getAssetFile($url); |
|
if ($assetFile === null || !is_file($assetFile)) { |
|
return $handler->handle($request); |
|
} |
|
|
|
$file = new SplFileInfo($assetFile); |
|
$modifiedTime = $file->getMTime(); |
if ($this->queue->valid()) { |
|
$middleware = $this->queue->current(); |
|
$this->queue->next(); |
|
|
|
return $middleware->process($request, $this); |
|
} |
|
|
|
if ($this->fallbackHandler) { |
|
return $this->fallbackHandler->handle($request); |
*/ |
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
{ |
|
try { |
|
return $handler->handle($request); |
|
} catch (RedirectException $exception) { |
|
return $this->handleRedirect($exception); |
|
} catch (Throwable $exception) { |
|
return $this->handleException($exception, $request); |
if ($this->queue->valid()) { |
|
$middleware = $this->queue->current(); |
|
$this->queue->next(); |
|
|
|
return $middleware->process($request, $this); |
|
} |
|
|
|
if ($this->fallbackHandler) { |
|
return $this->fallbackHandler->handle($request); |
$this->queue = $queue; |
|
$this->queue->rewind(); |
|
$this->fallbackHandler = $fallbackHandler; |
|
|
|
return $this->handle($request); |
|
} |
|
|
|
/** |
|
* Handle incoming server request and return a response. |
} |
|
|
|
$this->dispatchEvent('Server.buildMiddleware', ['middleware' => $middleware]); |
|
|
|
$response = $this->runner->run($middleware, $request, $this->app); |
|
|
|
if ($request instanceof ServerRequest) { |
|
$request->getSession()->close(); |
|
} |
// Bind your application to the server. |
|
$server = new Server(new Application(dirname(__DIR__) . '/config')); |
|
|
|
// Run the request/response through the application and emit the response. |
|
$server->emit($server->run()); |
|
|
If you want to customize this error message, create templates/Error/missing_connection.php