Frage

This query works when run from the command line (sqlcmd). I can't figure out how to make it work within a php script.

exec sp_executesql N'select N2."Name" from (("dbo"."BasicAnimal" N0 left join "dbo"."AnimalGroup" N1 on (N0."Group" = N1."OID")) left join "dbo"."AbstractGroup" N2 on (N1."OID" = N2."OID"))where (N0."GCRecord" is null and (((N0."IsCulled" = @p0) and N0."ExitDate" is null) or (not (N0."Group" is null) and N0."ExitDate" is null)))',N'@p0 nvarchar(8)',@p0=N'False'
go

If I swap out the above query from the php script with something basic like:

select * from dbo.AnimalGroup

it works...

The problem is that the query itself contains single and double quotes so I can't created a php variable like:

$sql='query goes here'

or

$sql="query goes here"
War es hilfreich?

Lösung

You can do this:

$sql = 'single "dobuble"  \' again single quotes\' '
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top