Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 访问权限转移_Php_Ms Access_Com_Adodb - Fatal编程技术网

Php 访问权限转移

Php 访问权限转移,php,ms-access,com,adodb,Php,Ms Access,Com,Adodb,我在这里匆忙地问了几个问题,但我进展得很快,我不断地改变事情,结果却遇到了一个不同的问题,根本不知道是什么原因造成的。我是一个PHP MYSQL人,我必须通过COM类使用Access 基本上,客户端有多个服务器,每个服务器都有一个access数据库,每个服务器都有一个CMS,这些表应该包含相同的数据,并且不同步。我的工作就是想办法重新同步它们 我将数据放入一个数组中,序列化并将其保存到主服务器上的一个文件中(所有服务器都应该同步到该文件),然后在其他服务器上下载该文件,并逐项取消序列化,检查它是

我在这里匆忙地问了几个问题,但我进展得很快,我不断地改变事情,结果却遇到了一个不同的问题,根本不知道是什么原因造成的。我是一个PHP MYSQL人,我必须通过COM类使用Access

基本上,客户端有多个服务器,每个服务器都有一个access数据库,每个服务器都有一个CMS,这些表应该包含相同的数据,并且不同步。我的工作就是想办法重新同步它们

我将数据放入一个数组中,序列化并将其保存到主服务器上的一个文件中(所有服务器都应该同步到该文件),然后在其他服务器上下载该文件,并逐项取消序列化,检查它是否在数据库中,如果没有插入它。插入失败。我尝试为每个项目构建一个sql查询,并执行$this->conn->Execute();这是在愚蠢的事情上一行一行的失败,所以我现在尝试这个:

function syncCMS()
    {
       $this->output['msg'] .= "<p><b>The following properties were added to the database on ." . $this->hsite . "</b></p>";
       $this->get_field_names();
       $this->make_connection(); //assigns connection to $this->conn
        $rs = new COM('ADODB.Recordset');
        $rs->CursorType = 2;
        $rs->CursorLocation = 1;
        $rs->LockType = 4;
        $rs->Open($this->table_name,$this->conn);
        foreach ($this->awayPropertyDetails as $key => $property)
        {
            $this->check_for_property($property['pname']);
            if (!$this->property_exists || $this->mode == "fullSync")
            {
               unset($values);
               $bfields = array("pshow","rent","best", "oda1",  "oda2", "oda3", "oda4", "oda5", "oda6", "odap", "topool","tomountain","tofitness","tosauna"); //stores the yes/no values
               $q = "INSERT INTO " . $this->table_name . " (" . $this->dbfields . ") VALUES (";
                foreach ($property as $k => $value)
                {

                    if ($k == "Kimlik") {
                        $value = null;
                    }
                    if ($k == "tarih")
                    {
                        $value = date("d/m/Y");
                        $value = "'" . $value . "'";
                    }
        if (in_array($k,$bfields))
                {
                   if ($value == "")
                   {
                       $value = 'FALSE';
                   }
                   else 
                   {
                       $value = 'TRUE';
                   }
                }
                     $rs->fields->$k = $value;
$this->output['msg'] .= $property['pname'] . " added";
                }

        $rs->BatchUpdate();
                $rs->Close();
                $this->conn->Close();
               //$this->download_images($property['OBJECT_NR'],$k);
                //$this->output['msg'] .= "<p>Images added</p>";

            }


       }
$message .= "</ul>";
$this->output['msg'] .= $message;
        $this->sendOutput();
        //print_r($property);*/
    }
函数syncCMS()
{
$this->output['msg'].=“以下属性已添加到上的数据库。”。$this->hsite。”

”; $this->get_field_names(); $this->make_connection();//将连接分配给$this->conn $rs=新COM('ADODB.Recordset'); $rs->CursorType=2; $rs->CursorLocation=1; $rs->LockType=4; $rs->Open($this->table\u name,$this->conn); foreach($this->awayPropertyDetails as$key=>$property) { $this->check_for_属性($property['pname']); 如果(!$this->property_存在| |$this->mode==“fullSync”) { 未结算(价值); $bfields=数组(“pshow”、“rent”、“best”、“oda1”、“oda2”、“oda3”、“oda4”、“oda5”、“oda6”、“odap”、“topol”、“tomountin”、“tofitness”、“tosauna”);//存储是/否值 $q=“插入到“$this->table_name.”(“$this->dbfields.”)值(“; foreach($k=>$value的属性) { 如果($k==“Kimlik”){ $value=null; } 如果($k==“塔里赫”) { $value=日期(“d/m/Y”); $value=“””“$value。””; } if(在数组中($k,$b字段)) { 如果($value==“”) { $value='FALSE'; } 其他的 { $value='TRUE'; } } $rs->fields->$k=$value; $this->output['msg'].=$property['pname'].“added”; } $rs->BatchUpdate(); $rs->Close(); $this->conn->Close(); //$this->下载图片($property['OBJECT\u NR'],$k); //$this->output['msg']。=“添加的图像”

”; } } $message.=“”; $this->output['msg']。=$message; $this->sendOutput(); //打印(物业)*/ }
得到这个:

致命错误:未捕获异常“com_exception”,消息为“无法查找'Kimlik':未知名称”。在D:\inetpub中

Kimlik是第一个字段的名称,自动编号字段,我把它取出来,问题转移到了第二个字段。

我是通过以下方法解决的:

$sql = "SELECT * FROM " . $this->table_name;
if (!$this->property_exists || $this->mode == "fullSync")
            {
               $this->make_connection();
               $rs->Open($sql,$this->conn);
              $rs->addnew();
               foreach($rs->Fields as $field)
               {
                   if ($field->name != "Kimlik")
                   {
                   $rs->Fields[$field->name] = $property[$field->name];
                   }
               }

              $rs->Update();
              $rs->Close();
              $this->conn->Close();

               $msg = $this->download_images($property['OBJECT_NR'],$k);
               $this->output['msg'] .= $property['pname'] . " added<br/>" . $msg . "<br/><br/>";

            }
$sql=“从“$this->table\u name;
如果(!$this->property_存在| |$this->mode==“fullSync”)
{
$this->make_connection();
$rs->Open($sql,$this->conn);
$rs->addnew();
foreach($rs->字段为$field)
{
如果($field->name!=“Kimlik”)
{
$rs->Fields[$field->name]=$property[$field->name];
}
}
$rs->Update();
$rs->Close();
$this->conn->Close();
$msg=$this->下载图片($property['OBJECT\u NR',$k);
$this->output['msg'].=$property['pname'].“添加了$msg。”

; }
您能使用ODBC而不是COM对象吗?如果是这样,您可能会发现使用ODBC更容易,这应该在PHP的Windows版本中始终可用。我认为Charles应该首先给出他的答案作为答案。使用Charles的建议将迫使询问者进入“访问方式”,这在这种情况下可能是最好的(尽管不方便)。