Précédent   Forum du club des développeurs et IT Pro > PHP > PHP & SGBD > PHP & SQL-Server
PHP & SQL-Server Forum d'entraide sur SQL-Server avec PHP. Avant de poster -> FAQ SQL-Server
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 14/11/2012, 00h19   #1
zenoX
Invité de passage
 
Homme
Développeur Web
Inscription : octobre 2012
Messages : 3
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France, Haute Savoie (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : octobre 2012
Messages : 3
Points : 1
Points : 1
Par défaut Procédure stockée et PDO

Hello,
J'aurais une petit question sur l'utilisation des procédure stockée avec PDO et MSSQL,

Code :
1
2
3
4
5
6
7
8
<?php
$stmt = mssql_init('createAccount');
mssql_bind($stmt, '@account', $sUsername, SQLVARCHAR, false, false, 32);
mssql_bind($stmt, '@pw', $sPassword, SQLVARCHAR, false, false, 32); //mssql_bind($stmt, '@pw', md5($salt.$password), SQLVARCHAR, false, false, 32); withh Hash
mssql_bind($stmt, '@email', $sEmail, SQLVARCHAR, false, false, 100);
mssql_bind($stmt, '@birthday', $dBirthday, SQLVARCHAR, false, false, 100);
mssql_execute($stmt) or die ("<strong>Error occurred while executing the statement.</strong>");
mssql_free_statement($stmt);
Ma procédure :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[createAccount]
@account varchar(32),
@pw varchar(32),
@cash int = 0,
@vote int = 0,
@totalcash int = 0,
@email varchar(100) = '',
@birthday varchar(100) = ''
as
set nocount on
set xact_abort on
 
if not exists (select * from ACCOUNT_TBL where account = @account)
begin
 
	begin tran
	INSERT ACCOUNT_TBL(account,password,isuse,member,id_no1,id_no2,realname,cash,vote,totalcash)
	VALUES(@account, @pw, 'T', 'A', '', '', '', @cash,@vote,@totalcash)
	INSERT ACCOUNT_TBL_DETAIL(account,gamecode,tester,m_chLoginAuthority,regdate,BlockTime,EndTime,WebTime,isuse,secession, email, birthday)
	VALUES(@account,'A000','2','F',GETDATE(),CONVERT(CHAR(8),GETDATE()-1,112),CONVERT(CHAR(8),DATEADD(year,10,GETDATE()),112),CONVERT(CHAR(8),GETDATE()-1,112),'T',NULL, @email, @birthday)
	insert AccountPlay (Account, PlayDate)
	select @account, convert(int, convert(char(8), getdate(), 112))
 
	if @@error <> 0
	begin
		rollback tran
		select -1
	end
	else
	begin
		commit tran
		select 1
	end
end
else
begin
	select 0
end
La mon code avec une requéte de base sans PDO , mais qu'elle serait l'équivalent avec PDO?

Merci d'avance
zenoX est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 20h57.


 
 
 
 
Partenaires

Hébergement Web