php - PDO fetchAll Results returns only one record issue -


i have developed following script in localhost (using wamp 2.2, apache 2.2.1 windows, php 5.3.9, mysql 5.5.20). when upload script production server (apache 2.2.29 unix, php 5.3.29, mysql 5.5.42)

i noticed php+pdo script did not return fetched rows in same way same script in local server.

if try add "order by" sql instance, works on local in production server resulted fetched row same.

also tryed change inner join table order same result. clues? maybe wrong inner join

php + pdo:

$user = ''; $pass = ''; $dsn = 'mysql:host=myhost;dbname=mydbname;charset=utf8';  try {     $pdo = new pdo($dsn, $user, $pass);     $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch (pdoexception $e) {     echo 'error: ' . $e->getmessage(); }  function contents($id) {         global $pdo;     $stmt = $pdo->prepare('select historia.id idhistoria, pub_us.comic, pub_us.id historia inner join pub_us on pub_us.historia = historia.id pub_us.comic = :id order orden');     $stmt->execute(array(':id' => $id));     $data = $stmt->fetchall(pdo::fetch_assoc);     $stmt = null;     return $data; }  $comicid = "fantasticfour/1/001";  $data = contents($comicid);  foreach($data $row) {       echo $row['idhistoria'];     echo " - ";     echo $row['comic'];     echo " - ";     echo $row['id'];  } 

table structure:

table structure historia: id(text, primary key) table structure pub_us: id(int,auto increment, primary key), comic(text), historia(text, related table historia.id) 

data retrieved:

results in local wamp: || idhistoria      || comic               || id    || || fantfour-1-001b || fantasticfour/1/001 || 25356 || || fantfour-1-001  || fantasticfour/1/001 || 16449 || || fantfour-1-001a || fantasticfour/1/001 || 3772  ||  results in server : || idhistoria      || comic               || id   || || fantfour-1-001a || fantasticfour/1/001 || 3772 || 

thanks @rmertins clue, solved problem.

table "historia" innodb engine , table "pub_us" myisam, differences between engines results in 1 row.

solved changing engines same (innodb in case)

thanks comments , clues, expect helps else!


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -