Never return empty map
parent
211e4158a2
commit
8c2416b711
|
@ -9,20 +9,26 @@ $opt = [
|
||||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
PDO::ATTR_EMULATE_PREPARES => false,
|
PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
];
|
];
|
||||||
$pdo = new PDO($dsn, $database_user, $database_pass, $opt);
|
try {
|
||||||
$stmt = $pdo->query("SELECT `domain` FROM `domain`");
|
$pdo = new PDO($dsn, $database_user, $database_pass, $opt);
|
||||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$stmt = $pdo->query("SELECT `domain` FROM `domain`");
|
||||||
while ($row = array_shift($rows)) {
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
while ($row = array_shift($rows)) {
|
||||||
$has_object = 1;
|
$has_object = 1;
|
||||||
echo strtolower(trim($row['domain'])) . PHP_EOL;
|
echo strtolower(trim($row['domain'])) . PHP_EOL;
|
||||||
}
|
}
|
||||||
$stmt = $pdo->query("SELECT `alias_domain` FROM `alias_domain`");
|
$stmt = $pdo->query("SELECT `alias_domain` FROM `alias_domain`");
|
||||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
while ($row = array_shift($rows)) {
|
while ($row = array_shift($rows)) {
|
||||||
$has_object = 1;
|
$has_object = 1;
|
||||||
echo strtolower(trim($row['alias_domain'])) . PHP_EOL;
|
echo strtolower(trim($row['alias_domain'])) . PHP_EOL;
|
||||||
}
|
}
|
||||||
if ($has_object == 0) {
|
if ($has_object == 0) {
|
||||||
echo "dummy@domain.local";
|
echo "dummy@domain.local";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (PDOException $e) {
|
||||||
|
echo "dummy@domain.local";
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -9,20 +9,26 @@ $opt = [
|
||||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
PDO::ATTR_EMULATE_PREPARES => false,
|
PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
];
|
];
|
||||||
$pdo = new PDO($dsn, $database_user, $database_pass, $opt);
|
try {
|
||||||
$stmt = $pdo->query("SELECT `username` FROM `mailbox` WHERE `wants_tagged_subject` = '1'");
|
$pdo = new PDO($dsn, $database_user, $database_pass, $opt);
|
||||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$stmt = $pdo->query("SELECT `username` FROM `mailbox` WHERE `wants_tagged_subject` = '1'");
|
||||||
while ($row = array_shift($rows)) {
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
while ($row = array_shift($rows)) {
|
||||||
$has_object = 1;
|
$has_object = 1;
|
||||||
echo strtolower(trim($row['username'])) . PHP_EOL;
|
echo strtolower(trim($row['username'])) . PHP_EOL;
|
||||||
}
|
}
|
||||||
$stmt = $pdo->query("SELECT CONCAT(mailbox.local_part, '@', alias_domain.alias_domain) as `tag_ad` FROM `mailbox` INNER JOIN `alias_domain` ON mailbox.domain = alias_domain.target_domain WHERE mailbox.wants_tagged_subject='1';");
|
$stmt = $pdo->query("SELECT CONCAT(mailbox.local_part, '@', alias_domain.alias_domain) as `tag_ad` FROM `mailbox` INNER JOIN `alias_domain` ON mailbox.domain = alias_domain.target_domain WHERE mailbox.wants_tagged_subject='1';");
|
||||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
while ($row = array_shift($rows)) {
|
while ($row = array_shift($rows)) {
|
||||||
$has_object = 1;
|
$has_object = 1;
|
||||||
echo strtolower(trim($row['tag_ad'])) . PHP_EOL;
|
echo strtolower(trim($row['tag_ad'])) . PHP_EOL;
|
||||||
}
|
}
|
||||||
if ($has_object == 0) {
|
if ($has_object == 0) {
|
||||||
echo "dummy@domain.local";
|
echo "dummy@domain.local";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (PDOException $e) {
|
||||||
|
echo "dummy@domain.local";
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue