2017-04-03 2 views
0

Ich habe ein Haupt Hosting-Account in goddady zB a.comGoDaddy: Wie eine Datenbank zu einer Add-on Domain hinzuzufügen

Und fügte ich ein Addon Domain zB b.com

ich eine Datenbank db_a erstellt, Mit a.com richtig arbeiten.

Ich habe eine Datenbank db_b erstellt und versuche mit b.com zu arbeiten, wo kann ich sie so konfigurieren, dass db_b von b.com als Host = localhost erreichbar ist?

Antwort

0

Nach einer langen Zeit der Verwirrung und Debugging, und ich fand den Grund/Lösung. Aber immer noch nicht sicher, warum Godaddy PDO dieses Problem hat.

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); 

kein Fehler - wie verwirrend. Und ich dies testen, funktioniert:

<?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); 

Und nun komme ich mit dieser Lösung, aber nicht sicher, ob es GoDaddy PDO Fehler ist?

<?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); 

Fazit:

Es sieht aus wie GoDaddy PDO nicht Dbname verwenden, müssen Sie manuell nach neuen PDO und vor allen anderen SQLs 'Verwendung Dbname' laufen

Verwandte Themen