MAMP:추가 ODBC 또는 SQL Server 지원
-
05-07-2019 - |
문제
제가 이야기하는 원격 SQL Server2000 데이터베이스입니다.내가 사용하는 MAMP 로컬로 저를 계속 사용하고 싶습니다.그러나 길을 잃었어요 무엇을 할 필요가 추가 지원이 말하기를 위해 이 데이터베이스에서 PHP.그것처럼 보이거나 ODBC 또는 SQL 서버에서 PHP 작동하지만 이러한 모듈없이 기본적으로 설치되어 있습니다.
할 수 있는 누군가에 대한 지침을 제공한 지원을 추가하는 방법에 대한 ODBC 또는 SQL Server MAMP?
해결책
이 질문, 처럼 보인을 받아야 합 드라이버 버전에 대한 PHP.
여기에는 다른 링크: Connecting to MS SQL server from PHP 를 사용하여 MAMP on OSX.
다른 팁
을 얻을 수 있었 자신의 작업:
요약:
로 붙여넣항:
curl -s http://php-osx.liip.ch/install.sh | bash -
(와 함께 작동 OS10.7)
오픈
/usr/local/php5/etc/freetds.conf
텍스트 편집기에서 그 항목을 추가한 mssql server 끝:[MSHOSTNAME] host = mshostname.example.com port = 1433 tds version = 8.0
저장 PHP 파일에서 당신의 사이트 폴더 활성화하고 웹이 공유한다.
<?php $myUser = "your_name"; $myPass = "your_password"; $myDB = "examples"; //connection to the database $dbhandle = mssql_connect(MSHOSTNAME, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); //declare the SQL statement that will query the database $query = "SELECT id, name, year "; $query .= "FROM cars "; $query .= "WHERE name='BMW'"; //execute the SQL query and return records $result = mssql_query($query); $numRows = mssql_num_rows($result); echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>"; //display the results while($row = mssql_fetch_array($result)) { echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>"; } //close the connection mssql_close($dbhandle); ?>
제휴하지 않습니다 StackOverflow