Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gunaevart/a4d14470ccda287a21769da46bebe4ce to your computer and use it in GitHub Desktop.
Save gunaevart/a4d14470ccda287a21769da46bebe4ce to your computer and use it in GitHub Desktop.
<?php
class Connect {
public $mysqli;
public function __construct() {
$this->mysqli = new mysqli('localhost', 'root', '', 'octaber');
}
public function selectQuery() {
$result_set = $this->mysqli->query("SELECT * FROM `testtable`");
if (!$result_set) return false;
while ($row = $result_set->fetch_assoc()){
$data[$i] = $row;
$i++;
}
return $data;
}
}
<?php
require __DIR__ . '/class/Connect.php';
$connect = new Connect();
$myrow = $connect->selectQuery();
echo '<PRE>';
print_r($myrow);
echo '</PRE>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment