Здравствуйте, пишу такой запрос на PHP в IIS:
PHP код:
$sql = "select [ContactBase].[ContactId],
[ContactBase].[FirstName],
[ContactBase].[MiddleName],
[ContactBase].[LastName],
[ContactBase].[BirthDate],
[ContactBase].[AccountId] as [aID],
[ContactExtensionBase].[New_contactstatus] as [TypeOfPresent],
[ContactExtensionBase].[New_birthdate] as [NextBirthDate],
[AccountBase].[Name] as [Company]
from
[dbo].[ContactBase], [dbo].[ContactExtensionBase], [dbo].[AccountBase]
where [dbo].[ContactBase].[ContactId] = [dbo].[ContactExtensionBase].[ContactId]
and [dbo].[ContactBase].[AccountId] = [dbo].[AccountBase].[AccountId]
and [dbo].[ContactBase].[BirthDate] <> NULL
order by [NextBirthDate] DESC
";
$query = mssql_query($sql);
while ($r= mssql_fetch_object($query) ) {
echo "".$r->ContactId."<br>";
}
и получаю иероглифы типа:
PHP код:
U^ѓ• •Я±ф0Hѕs-
‚ўЁбЯ»p0Hѕs-
и т.д.
а должно быть вот что
PHP код:
578f2e26-2ae3-df11-bb70-003048be732d
c7f8ec27-35e3-df11-bb70-003048be732d
и т.д.
поле ContactId в CRM таблице является первичным ключом.
Когда пытаюсь применить CAST (field as TEXT) к полю ContactId
PHP код:
$sql = "select case ( [ContactBase].[ContactId] as TEXT) as [cID],
[ContactBase].[FirstName],
[ContactBase].[MiddleName],
[ContactBase].[LastName],
[ContactBase].[BirthDate],
[ContactBase].[AccountId] as [aID],
[ContactExtensionBase].[New_contactstatus] as [TypeOfPresent],
[ContactExtensionBase].[New_birthdate] as [NextBirthDate],
[AccountBase].[Name] as [Company]
from
[dbo].[ContactBase], [dbo].[ContactExtensionBase], [dbo].[AccountBase]
where [dbo].[ContactBase].[ContactId] = [dbo].[ContactExtensionBase].[ContactId]
and [dbo].[ContactBase].[AccountId] = [dbo].[AccountBase].[AccountId]
and [dbo].[ContactBase].[BirthDate] <> NULL
order by [NextBirthDate] DESC
";
$query = mssql_query($sql);
получаю такую ошибку
PHP код:
Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near the
keyword 'as'. (severity 15) in C:\Program Files\Microsoft Dynamics CRM\CRMWeb
birthday.crmpx on line 27
Warning: mssql_query() [function.mssql-query]: Query failed in C:\Program
Files\Microsoft Dynamics CRM\CRMWeb\birthday.crmpx on line 27
Warning: mssql_num_rows(): supplied argument is not a valid MS SQL-result
resource in C:\Program Files\Microsoft Dynamics CRM\CRMWeb\birthday.crmpx on line 44
Помогите пожалуйста.
Я уже третий час мучаюсь ничего не получается, все форумы обыскал нигде нет описания как решить проблему.
Заранее спасибо!