0

Signs of the question instead of Russian letters and does not write Russian letters in the database.

Here is an example code that makes a selection of a news list from a database:

  public static function getList( $numRows=1000000, $order="publicationDate DESC" ) {
    $conn = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
    $sql = "SELECT SQL_CALC_FOUND_ROWS *, UNIX_TIMESTAMP(publicationDate) AS publicationDate FROM articles
            ORDER BY " . $conn->quote($order) . " LIMIT :numRows ";

    $st = $conn->prepare( $sql );
    $st->bindValue( ":numRows", $numRows, PDO::PARAM_INT );
    $st->execute();
    $list = array();

    while ( $row = $st->fetch() ) {
      $article = new Article( $row );
      $list[] = $article;
    }

    $sql = "SELECT FOUND_ROWS() AS totalRows";
    $totalRows = $conn->query( $sql )->fetch();
    $conn = null;
    return ( array ( "results" => $list, "totalRows" => $totalRows[0] ) );
  }

$conn->query( "SET CHARSET utf8" ); - Does not help mysql:charset=utf8; - don`t work Database structure: img

  • change character Collation of mysql table to `utf8_unicode_ci` – urfusion Jul 07 '17 at 12:52
  • @urfusion It is the default but does not help – Roman Kravets Jul 07 '17 at 12:59
  • `?????` usually means that the data was not stored correctly. See "question marks" in http://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored for specifics about the cause. – Rick James Jul 08 '17 at 22:46

0 Answers0