Cita:
El procedimiento almacenado crea una tabla temporal y le introduce los datos retornados del SELECT. Luego en PHP trato de ejecutar este procedimiento almacenado de esta forma:CREATE PROCEDURE [dbo].[spTABLE_TEMPORARY_PLAYER]
@Player VARCHAR(10),
@Name VARCHAR(50),
@LastName VARCHAR(50),
@Email VARCHAR(50),
@Password VARCHAR(50),
@Phone VARCHAR(50),
@Zip VARCHAR(50),
@Status VARCHAR(50)
AS
BEGIN
IF OBJECT_ID('tempDB..##PlayerTemp','U') IS NOT NULL
DROP TABLE ##PlayerTemp;
SELECT IdPlayer, Player, Name, LastName, Email, Password, IdBook
INTO ##PlayerTemp
FROM PLAYER
WHERE Player LIKE @Player AND Name LIKE @Name AND LastName LIKE @LastName AND
Email LIKE @Email AND Password LIKE @Password AND Phone LIKE @Phone AND
Zip LIKE @Zip AND Status = @Status
END
@Player VARCHAR(10),
@Name VARCHAR(50),
@LastName VARCHAR(50),
@Email VARCHAR(50),
@Password VARCHAR(50),
@Phone VARCHAR(50),
@Zip VARCHAR(50),
@Status VARCHAR(50)
AS
BEGIN
IF OBJECT_ID('tempDB..##PlayerTemp','U') IS NOT NULL
DROP TABLE ##PlayerTemp;
SELECT IdPlayer, Player, Name, LastName, Email, Password, IdBook
INTO ##PlayerTemp
FROM PLAYER
WHERE Player LIKE @Player AND Name LIKE @Name AND LastName LIKE @LastName AND
Email LIKE @Email AND Password LIKE @Password AND Phone LIKE @Phone AND
Zip LIKE @Zip AND Status = @Status
END
Código PHP:
$insTlb = "EXEC [dbo].[spTABLE_TEMPORARY_PLAYER] '%".$account."%' '%".$firstName."%' '%".$lastName."%' '%".$email."%' '%".$pass."%' '%".$phNumber."%' '%".$zip."%' ".$activeAux;
$this->strData = $this->strConnect->query($insTlb);
Código PHP:
$sql = " SELECT TOP 10000 P.[IdPlayer],
P.[Player],
L.[username],
L.[password],
L.[ip_address],
L.[login_date],
L.[success],
D.[Description],
B.[host_name],
P.[Name] + ' ' + P.[LastName] AS 'Name',
P.Email
FROM [CPW-SQLP105].[BackOffice].[dbo].[login] L, [dbo].[##PlayerTemp] P, BOOK D, [CPW-SQLP105].[BackOffice].[dbo].[book] B
WHERE D.[IdBook] = P.[IdBook] AND L.[book_id] = B.[book_id] AND D.[IdBook] = L.[book_id] AND
P.[player] = L.[username] AND B.[id] = L.[website_id] AND
L.[login_date] >= convert(datetime,('2013-01-30 20:10:11')) AND L.[login_date] <= convert(datetime,('2013-11-01 20:10:11'))
AND L.[success] = 'N'";
Cita:
NOTA: La linea 71 es donde esta el error y contiene esto: $this->strData = $this->strConnect->query($insTlb); EXEC [dbo].[spTABLE_TEMPORARY_PLAYER] '%p1%' '%%' '%%' '%%' '%%' '%%' '%%' 'E'
[Mon Nov 04 18:09:10 2013] [error] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 0 [FreeTDS][SQL Server]Statement(s) could not be prepared. (SQLPrepare[0] at /build/buildd-php5_5.3.3-7+squeeze14-i386-lt_SZ2/php5-5.3.3/ext/pdo_odbc/odbc_driver.c:206)' in /var/www/mas/mas-v1.0.2/class/class.search.php:71\nStack trace:\n#0 /var/www/mas/mas-v1.0.2/class/class.search.php(71): PDO->query('EXEC [dbo].[spT...')\n#1 /var/www/mas/mas-v1.0.2/results.php(13): search->searchAdvance('p1', '', '', '', '', '0', '', '2013/11/03 18:0...', '2013/11/04 18:0...', '', '', 'E', 'Y', false)\n#2 {main}\n thrown in /var/www/mas/mas-v1.0.2/class/class.search.php on line 71
[Mon Nov 04 18:09:10 2013] [error] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 0 [FreeTDS][SQL Server]Statement(s) could not be prepared. (SQLPrepare[0] at /build/buildd-php5_5.3.3-7+squeeze14-i386-lt_SZ2/php5-5.3.3/ext/pdo_odbc/odbc_driver.c:206)' in /var/www/mas/mas-v1.0.2/class/class.search.php:71\nStack trace:\n#0 /var/www/mas/mas-v1.0.2/class/class.search.php(71): PDO->query('EXEC [dbo].[spT...')\n#1 /var/www/mas/mas-v1.0.2/results.php(13): search->searchAdvance('p1', '', '', '', '', '0', '', '2013/11/03 18:0...', '2013/11/04 18:0...', '', '', 'E', 'Y', false)\n#2 {main}\n thrown in /var/www/mas/mas-v1.0.2/class/class.search.php on line 71