catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

MSSQL Declare #744

Closed AhmadShamli closed 3 years ago

AhmadShamli commented 6 years ago

Hi, is there a way to use declare in the query.? using medoo 1.4.5 currently it returned empty.

example query: declare @StartDate DATETIME='2016-05-01 00:00:00' declare @EndDate DATETIME=getdate() SELECT cast(YEAR(DATEADD(MONTH, x.number, @StartDate)) as varchar) + '-' + cast(RIGHT('0' + RTRIM(MONTH(DATEADD(MONTH, x.number, @StartDate))), 2) as varchar) as Months FROM master.dbo.spt_values x WHERE x.type = 'P' AND x.number <= DATEDIFF(MONTH, @StartDate, @EndDate)

catfan commented 6 years ago

There is no direct way for this. But you can use query() or Medoo::raw for that.

https://medoo.in/api/query https://medoo.in/api/raw