How do I turn mysql into Pdo?

Asked

Viewed 54 times

0

I have this Function in mysql.

public function get_logst(){
        $this->connect_database(DAT5);
        $querygetl = mysql_query("select HeroName, ObjIdx from ObjLog where LogType = '5' and
        LogSubType = '2' and DataType = '2' order by LogSerial desc Limit 500");
        $this->__destruct();
        $this->connect_database(DAT3);
        while($arraygetl = mysql_fetch_row($querygetl)){
            $getmonster = mysql_fetch_row(mysql_query("select name from s_monster where 
            type = '$arraygetl[1]'"));
            echo '<tr><td><span class="badge bg-success">'.$arraygetl[0].'</span></td>                                  
                  <td>'.$getmonster[0].'</td></tr>';
        }
    }

And I want to turn into I tried to do it without success:

 $pdo = new PDO("mysql:host=localhost;charset=utf8", "root", "");

 $teste = $pdo->prepare("SELECT bd1.*,bd2.* FROM `S_Data`.`*` as bd1 INNER JOIN `LogDB`.`ObjLog` as bd2 where bd1.`type` = bd2.`ObjIdx`");
 $teste->execute();

 $resultados = $teste->fetchAll(PDO::FETCH_OBJ);

 var_dump($resultados);

I am performing the query in two different banks put on the same host. The only change I also want in Pdo to get all the fields of the tables S_data because it contains all the items has the table s_item and s_monster, only when I put the * does not take returns an array with 0.

  • No need to put crase in the asterisk

  • The query you have in Pdo form is different from the query you have in mysql form. It doesn’t seem to be a translation anymore. And why you use S_Data.* as bd1?

  • why all tables in S_Data has the same format and I want to take all.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.