Geburtstagskinder anzeigen

Hey!

Hab aktuell folgenden Code:

public function getBirthday()
{
    $today_date = getdate();
    if ($today_date["mon"] < 10)
        $birthmonth = "0" . $today_date["mon"];
    else
        $birthmonth = $today_date["mon"];
    if ($today_date["mday"] < 10)
        $birthday = "0" . $today_date["mday"];
    else
        $birthday = $today_date["mday"];
    $sSql = "SELECT oxid FROM oxuser WHERE OXBIRTHDATE LIKE '%-'" . $birthmonth . "-" . $birthday . "'";
    }

Ich bin mir ehrlich gesagt recht unsicher, wie ich aus dem sql statement jetzt alle Geburtstagskinder in nem Array liefern kann. Kann mir da jemand auf die Sprünge helfen?

statt “oxid” in select oxid könnte man einfach die gewünschte Felder angeben. Name, Email etc

ja das ist mir auch bewusst.
Ich bin mir nur nicht sicher, wie ich bei Oxid dann den SQL Code ausführen lasse und das Ergebnis anzeigen.
Wie funktioniert das ganze?

Versuchs mal damit:

ehm danke? Nur steht da leider nichts :smiley:

Tja würde es gerne posten… bekomme allerdings Fehlermeldung 403 Forbidden.

dann versuchs vielleicht mal per Nachricht? Komisch das ganze

Auch schon probiert, selbe Problem.

dann auf https://pastebin.com/ mal probieren und hier posten

https://pastebin.com/xxK31pFc

statt oxid halt name etc.

sollte
$db = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
$query = “SELECT oxfname FROM oxuser WHERE oxbirthdate LIKE ‘%-’” . $birthmonth . “-” . $birthday . “’”;
$db->Execute($query);

dann nicht funktionieren? so wurde es in nem anderen Beitrag gemacht, aber klappt nicht wirklich. Bekomm nur die Maintenance Seite

Was steht in der oxidshop.log?

$db->select($query);

?

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘10-25’ at line 1

auch nachdem der SQL Command zu dem abgeändert wurde
$sSql = "SELECT oxfname FROM oxuser WHERE oxbirthdate LIKE '%-'" . $birthmonth . "-" . $birthday;

Da ist ein Hochkomma zuviel.
Oder vergleiche direkt in smarty mit date_format:

$oUser = $this->getUser();
$birthday = $oUser->oxuser__oxbirthdate->value;

direkt in Smarty habe ich das ganze bereits gelöst. Ich habe aber was anderes vor und mach es deshalb im Basketcontroller.

Sollte mir vielleicht mal eine neue Brille zulegen, jedoch hab ich anscheinend noch immer einen Syntaxfehler… den ich einfach nicht sehe, obwohl er direkt vor mir ist :smiley:

SELECT oxfname FROM oxuser WHERE oxbirthdate LIKE ‘%-“.$birthmonth.”-“.$birthday.”’";

nein auch noch ein Syntax Error.
Sehr komisch

Am Anfang muss noch ein "

"SELECT oxfname FROM oxuser WHERE oxbirthdate LIKE '%-".$birthmonth."-".$birthday."'";

:rofl: Das dürfte klar sein.

Nicht nur kopieren!!! Die Hochkommata werden oft falsch wiedergegeben und müssen manuell ersetzt werden.