2017-04-03 1 views
0

내가 메인 호스팅 계정을 가지고에 데이터베이스를 추가 그리고 나는 데이터베이스 db_a를 만든 애드온 도메인 예를 들어 b.com에서 GoDaddy : goddady 예를 들어 a.com</p> <p>에 부가 도메인

을 추가하는 방법, a.com과 올바르게 작업합니다.

db_b 데이터베이스를 만들었고 b.com 작업을 시도했는데 db_b가 b = host = localhost로 액세스 할 수 있도록 db_b를 구성 할 수 있습니까?

답변

0

큰 혼란과 디버깅 후에, 나는 이유/해결책을 발견했습니다. 그러나 왜 Godaddy PDO가이 문제를 가지고 있는지 확실하지 않습니다.

PHP의 v5.4.45

<?php 
$pdo = new PDO('mysql:localhost;dbname=mydb', $user, $pass); 

$sth = $pdo->prepare('select * from tab limit 1'); 
$sth->execute(); 
$row = $sth->fetchAll(); 
echo '<pre>select * from test -- not working -- '; 
print_r($row); 

$sth = $pdo->prepare('select now()'); 
$sth->execute(); 
$row = $sth->fetchAll(PDO::FETCH_ASSOC); 
echo "\nselect now -- working -- "; 
print_r($row); 

$sth = $pdo->prepare('show databases'); 
$sth->execute(); 
$row = $sth->fetchAll(PDO::FETCH_ASSOC); 
echo "\nshow databases -- working -- "; 
print_r($row); 

$sth = $pdo->prepare('show tables'); 
$sth->execute(); 
$row = $sth->fetchAll(PDO::FETCH_ASSOC); 
echo "\nshow tables -- not working -- "; 
print_r($row); 

$sth = $pdo->prepare('show privileges'); 
$sth->execute(); 
$row = $sth->fetchAll(PDO::FETCH_ASSOC); 
echo "\nshow privileges -- working but not right -- "; 
print_r($row); 

$sth = $pdo->prepare('select * from information_schema.TABLES where TABLE_SCHEMA != \'information_schema\''); 
$sth->execute(); 
$row = $sth->fetchAll(PDO::FETCH_ASSOC); 
echo "\nselect * from information_schema.TABLES -- working -- "; 
print_r($row); 

없음 오류 없습니다 - 어떻게 혼란. 그리고 난이 작품을 테스트 :

<?php 
$pdo = new PDO('mysql:localhost;dbname=mydb', $user, $pass); 

$sth = $pdo->prepare('select * from mydb.tab limit 1'); 
$sth->execute(); 
$row = $sth->fetchAll(); 
echo '<pre>select * from test -- working !!! -- '; 
print_r($row); 

그리고 지금 나는이 솔루션을 생각해 낸다.

<?php 
$pdo = new PDO('mysql:localhost', $user, $pass); 

$sth = $pdo->prepare('use mydb'); 
$sth->execute(); 

$sth = $pdo->prepare('select * from tab limit 1'); 
$sth->execute(); 
$row = $sth->fetchAll(); 
echo '<pre>select * from test -- working !!! -- '; 
print_r($row); 

결론 :

그것은 GoDaddy이 PDO는 DBNAME을 사용하지 않는 것처럼, 당신은 수동으로 새로운 PDO 후 다른 SQL을하기 전에 '사용 DBNAME'을 실행해야 보이는