12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- /**
- * Install file for User Import module
- * Date of creation: 17.05.2017
- * Creator: Yuliia Polna
- * TODO:
- * - make normal test db
- * - manage updating of module
- * - add logs
- */
- use Drupal\user_import\Service\MysqlConnectService;
- use Drupal\user_import\Service\AddUserService;
- function user_import_install(){
- $servername = "localhost";
- $username = "root";
- $password = "Abccpm80";
- $dbname = "test";
- $dbConnect = new MysqlConnectService();
- $addUser = new AddUserService();
- $connection = $dbConnect->connect($servername,$username,$password,$dbname);
- $query = "SELECT * FROM adsuser WHERE access='MITARBEITER' ";
- $result = mysqli_query($connection,$query) or die("Query failed");
- $i = 0; //
- while ($row = mysqli_fetch_array($result)) {
- if ($i < 3) { //
- if(!($addUser->checkIfExists(utf8_encode($row['username'])))) {
- $addUser->createUser($row);
- }
- $i++; //
- } else { //
- break; //
- } //
- }
- }
|