mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
Change encoding to real utf8
This commit is contained in:
parent
ac0503c6e9
commit
0f11df6f95
|
|
@ -69,7 +69,7 @@ final class MysqlConnection extends ConnectionAbstract
|
|||
$this->prefix = $dbdata['prefix'] ?? '';
|
||||
|
||||
try {
|
||||
$this->con = new \PDO($this->dbdata['db'] . ':host=' . $this->dbdata['host'] . ':' . $this->dbdata['port'] . ';dbname=' . $this->dbdata['database'] . ';charset=utf8', $this->dbdata['login'], $this->dbdata['password']);
|
||||
$this->con = new \PDO($this->dbdata['db'] . ':host=' . $this->dbdata['host'] . ':' . $this->dbdata['port'] . ';dbname=' . $this->dbdata['database'] . ';charset=utf8mb4', $this->dbdata['login'], $this->dbdata['password']);
|
||||
$this->con->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$this->con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,6 @@ class MysqlGrammar extends Grammar
|
|||
*/
|
||||
protected function compileCreateTableSettings(BuilderAbstract $query, bool $settings) : string
|
||||
{
|
||||
return 'ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1';
|
||||
return 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
`test_base_datetime` datetime DEFAULT NULL,
|
||||
`test_base_datetime_null` datetime DEFAULT NULL, /* There was a bug where it returned the current date because new \DateTime(null) === current date which is wrong, we want null as value! */
|
||||
PRIMARY KEY (`test_base_id`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$GLOBALS['dbpool']->get()->con->prepare(
|
||||
|
|
@ -99,7 +99,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
`test_belongs_to_one_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`test_belongs_to_one_string` varchar(254) NOT NULL,
|
||||
PRIMARY KEY (`test_belongs_to_one_id`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$GLOBALS['dbpool']->get()->con->prepare(
|
||||
|
|
@ -107,7 +107,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
`test_owns_one_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`test_owns_one_string` varchar(254) NOT NULL,
|
||||
PRIMARY KEY (`test_owns_one_id`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$GLOBALS['dbpool']->get()->con->prepare(
|
||||
|
|
@ -116,7 +116,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
`test_has_many_direct_string` varchar(254) NOT NULL,
|
||||
`test_has_many_direct_to` int(11) NOT NULL,
|
||||
PRIMARY KEY (`test_has_many_direct_id`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$GLOBALS['dbpool']->get()->con->prepare(
|
||||
|
|
@ -124,7 +124,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
`test_has_many_rel_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`test_has_many_rel_string` varchar(254) NOT NULL,
|
||||
PRIMARY KEY (`test_has_many_rel_id`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$GLOBALS['dbpool']->get()->con->prepare(
|
||||
|
|
@ -133,7 +133,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
`test_has_many_rel_relations_src` int(11) NOT NULL,
|
||||
`test_has_many_rel_relations_dest` int(11) NOT NULL,
|
||||
PRIMARY KEY (`test_has_many_rel_relations_id`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use phpOMS\DataStorage\Database\Query\Builder;
|
|||
*/
|
||||
class BuilderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected $con = null;
|
||||
protected $con;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class BuilderTest extends \PHPUnit\Framework\TestCase
|
|||
public function testMysqlCreateTable() : void
|
||||
{
|
||||
$query = new Builder($this->con);
|
||||
$sql = 'CREATE TABLE `user_roles` (`user_id` INT NOT NULL AUTO_INCREMENT, `role_id` VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY (`user_id`), FOREIGN KEY (`user_id`) REFERENCES `users` (`ext1_id`), FOREIGN KEY (`role_id`) REFERENCES `roles` (`ext2_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;';
|
||||
$sql = 'CREATE TABLE `user_roles` (`user_id` INT NOT NULL AUTO_INCREMENT, `role_id` VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY (`user_id`), FOREIGN KEY (`user_id`) REFERENCES `users` (`ext1_id`), FOREIGN KEY (`role_id`) REFERENCES `roles` (`ext2_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;';
|
||||
self::assertEquals(
|
||||
$sql,
|
||||
$query->createTable('user_roles')
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user