Mysql Raw Query Missing Data

Mysql Raw Query Missing Data

khellendros74khellendros74 Posts: 4Questions: 2Answers: 0

Hi,

i m using internal engine to push my own query, whereas my query should give me (and give my a lot of result _ 48 in the exemple) FetchAll return only 1 result

this query get one date by month during 4 years

$years = 4;
$result = $db->raw()
->bind( ":years", $years )
->exec("WITH RECURSIVE dates(Date) AS
(
SELECT DATE(now()) as Date
UNION ALL
SELECT DATE(DATE_ADD(Date, INTERVAL 1 month)) FROM dates WHERE Date < DATE(DATE_ADD(now(), INTERVAL :years year))
)
SELECT DATE(Date) FROM dates
");
$result->fetchAll(PDO::FETCH_ASSOC);

any clues ?

Thanks

This question has an accepted answers - jump to answer

Answers

  • khellendros74khellendros74 Posts: 4Questions: 2Answers: 0

    ok my bad, i frogot to init $years in my code
    it works perfectly

  • allanallan Posts: 62,066Questions: 1Answers: 10,174 Site admin
    Answer ✓

    Thanks for the update - good to hear you got it working!

    Allan

Sign In or Register to comment.