These are DB binding information for connecting to SQL Server on PHP
SQL Server | PHP | Range | Size(byte) |
Char | SQLCHAR | | |
Varchar | SQLCHAR | | |
Binary | SQLBINARY | | |
Varbinary | SQLBINARY | | |
Tinyint | SQLINT1 | 0 ~ 255 | 1 |
Smallint | SQLINT2 | -2^15(-32,768) ~ 2^15-1(32,767) | 2 |
Int | SQLINT4 | ^31(-2,147,483,648) ~ 2^31-1(2,147,483,647) | 4 |
Real | SQLFLT4 | 3.40E+38에서 -1.18E - 38, 0과 1.18E-38에서 3.40E + 38 | |
Float | SQLFLT8 | 1.79E+308에서 -2.23E-308, 0과 2.23E-308에서 1.79E+308 | |
Smallmoney | SQLMONEY4 | - 214,748.3648 - 214,748.3647 | |
money | SQLMONEY | -922,337,203,685,477.5808 - 922,337,203,685,477.5807 | |
decimal | SQLDECIMAL | | |
numeric | SQLNUMERIC | | |
smalldatetime | SQLDATETIM4 | | |
datetime | SQLDATETIME | | |
image | SQLIMAGE | | |
Text | SQLTEXT | |
<?php
// Connect to MSSQL and select the database
mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi');
mssql_select_db('php');
// Create a new stored prodecure
$stmt = mssql_init('NewUserRecord');
// Bind the field names
mssql_bind($stmt, '@username', 'Kalle', SQLVARCHAR, false, false, 60);
mssql_bind($stmt, '@name', 'Kalle', SQLVARCHAR, false, false, 60);
mssql_bind($stmt, '@age', 19, SQLINT1, false, false, 3);
// Execute
mssql_execute($stmt);
// Free statement
mssql_free_statement($stmt);
?>
// Connect to MSSQL and select the database
mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi');
mssql_select_db('php');
// Create a new stored prodecure
$stmt = mssql_init('NewUserRecord');
// Bind the field names
mssql_bind($stmt, '@username', 'Kalle', SQLVARCHAR, false, false, 60);
mssql_bind($stmt, '@name', 'Kalle', SQLVARCHAR, false, false, 60);
mssql_bind($stmt, '@age', 19, SQLINT1, false, false, 3);
// Execute
mssql_execute($stmt);
// Free statement
mssql_free_statement($stmt);
?>
http://php.net/manual/en/function.mssql-bind.php
댓글 없음:
댓글 쓰기