通过 PHP 连接到 Sharepoint 数据库

2022-01-24 00:00:00 connection database sharepoint php

我不熟悉 Sharepoint.我想使用 PHP 查询或读取 Sharepoint 数据库.

I am not familiar with Sharepoint. I would like to query or read Sharepoint database using PHP.

有什么办法可以做到吗?

Is there a way I can do that?

在此先感谢您.非常感谢任何帮助.

Thank you in advanc. Any help is greatly appreciated.

推荐答案

您应该考虑使用适用于 SharePoint 的 Camelot PHP 工具,它是专门为 SharePoint 列表构建的 Camelot XML 格式的文档化 PHP 框架.

You should consider using the Camelot PHP Tools for SharePoint, it's a well documented php framework for the Camelot XML format specially constructed for SharePoint lists.

文档和下载

  • http://docs.bendsoft.com/camelot-php-tools/
  • http://www.bendsoft.com/downloads/sharepoint-php-tools/

您还需要 Camelot SharePoint 集成工具包、http://camelottoolkit.codeplex.com/ 和 Camelot .NET 连接器(http://www.bendsoft.com/net-sharepoint-connector/).

You will also need the Camelot SharePoint Integration Toolkit, http://camelottoolkit.codeplex.com/ and the Camelot .NET Connector (http://www.bendsoft.com/net-sharepoint-connector/).

将连接器安装在可以访问 SharePoint 服务器的盒子上,这可能是与 SharePoint 服务器相同的服务器,然后将集成工具包安装在与连接器相同的服务器上.设置集成工具包中包含的集成服务(按照说明进行操作),然后您就完成了.网站上也有一些指导视频.

Install the Connector on a box that can reach the SharePoint server, this may be the same server as the SharePoint server, then install the Integration Toolkit on the same server as the Connector. Set up the integration service that is included in the integration toolkit (follow the instructions) and then you are done. There are a few instruction videos on the websites as well.

使用它的好处是,您将能够通过 API 使用常见的 SQL 查询与 SharePoint 列表和库进行对话,而永远不会使用底层的 mssql 数据库.

The upsides of using this is that you will be able to talk to SharePoint lists and libraries through the API by using common SQL queries, the underlying mssql database is never used.

使用 SQL 从 SharePoint 中选择数据

$SharePointQuery = new SharePointQuery(array(
    'sql' => "SELECT * FROM Tasks WHERE ID > 10",
    'connection_name' => 'SharePointConnection1'
));

按列表和视图名称从 SharePoint 中选择数据

$SharePointQuery = new SharePointQuery(
    array(
        'listName' => 'Tasks',
        'viewName' => 'All Tasks',
        'includeAttachements' => false,
        'connection_name' => 'SharePointConnection1',
        'columns' => ''
    )
);

使用 SQL 和 SharePointNonQuery 在 SharePoint 中插入数据

$SharePointNonQuery = new SharePointNonQuery(array(
    'sql' => "INSERT INTO Tasks (Title,AssignedTo,Status,Priority,DueDate,PercentComplete) VALUES ('Test task from PHP',1,'In Progress','(1) High', '".  date('Y-m-d H:i:s') ."',0.95)",
    'method' => 'ExecuteNonQuery',
    'connection_name' => 'SharePointConnection1'
));

还有一些存储过程可以帮助你进行一些操作,比如文档库的高级处理

There are also stored procedures to help you with some operations, like advanced handling of document libraries

下载文件

$download = new CamelotDownloadFile(array(
    "file" => $_GET["file"],
    "listName" => 'Shared Documents',
    "connection_name" => 'SharePointConnection1'
));

$download->download_file();

上传文件

$args = array(  
    "file" => $_FILES,
    "listName" => 'Shared Documents',
    "folder" => 'Folder/',
    "connection_name" => 'SharePointConnection2'
); 

$UploadFile = new CamelotUploadFile($args);

相关文章