public function execute($sqlQuery, $sqlParams) { if (empty($sqlQuery)) { throw new \InvalidArgumentException("sqlQuery should not be empty"); } if (!is_array($sqlParams)) { throw new \InvalidArgumentException("sqlParams should be an array"); } $this->sqlQuery = $sqlQuery; $this->sqlParams = Encoding::toUtf8($sqlParams); return $this->prepareAndRun(); }
public function getAll() { $this->csvArray = array(); $isHeaderLine = true; while (($csvLine = fgets($this->csvFile)) !== false) { $csvLineArray = $this->splitCsvLine($csvLine); if ($isHeaderLine) { $this->setColumnsNames($csvLineArray); $isHeaderLine = false; } else { $this->csvArray[] = $this->mapCsvLineToObject($csvLineArray); } } fclose($this->csvFile); return Encoding::toUtf8($this->csvArray); }
public function testEncodeComplexItemToUtf8() { $latin1 = new \stdClass(); $latin1->n1 = new \stdClass(); $latin1->n = $this->iso88591; $latin1->n1->n2 = $this->iso88591; $latin1->a1 = array($this->iso88591, $this->iso88591, "a2" => array($this->iso88591, $this->iso88591), "o" => $latin1->n1); $utf8 = Encoding::toUtf8($latin1); $this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->n); $this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->n1->n2); $this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1[0]); $this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1[1]); $this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1["a2"][0]); $this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1["a2"][1]); $this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1["o"]->n2); }
public function testUtf8InsertionIsNotDoubleEncoded() { $stringUtf8 = "des accents en \"utf-8\" : éèàù & Straße"; $columnsToValues = array("intcol" => 7, "utf8col" => Encoding::toUtf8($stringUtf8)); $insertId = $this->db->insert($this->testsTable, $columnsToValues); $getOneRowSql = "SELECT * FROM {$this->testsTable} WHERE `id` = :id"; $sqlParams = array("id" => $insertId); $row = $this->db->getOneRow($getOneRowSql, $sqlParams); $this->assertEquals($stringUtf8, $row->utf8col); }
public function testIsLatin1FileReadAsUtf8() { $this->csvFile = new CsvFile(__DIR__ . '/Data/iso88591.csv', "\t"); $csvContent = $this->csvFile->getAll(); $this->assertEquals(Encoding::toUtf8("CD-R 52x certifié, 25 pièces en cake box"), $csvContent[0]->ProductName); }