コード例 #1
0
ファイル: contacts_ldap.php プロジェクト: eureka2/web2project
                 //Try to find a matching company name in the system, if not them set contact_company to 0
                 $q = new w2p_Database_Query();
                 $q->addQuery('company_id');
                 $q->addTable('companies');
                 $q->addWhere('company_name LIKE \'' . mb_trim($pairs['contact_company']) . '\'');
                 $company_id = $q->loadResult();
                 $pairs['contact_company'] = $company_id ? $company_id : 0;
                 $q->clear();
                 //Try to find a matching department name in the system, if not them set contact_department to 0
                 $q->addQuery('dept_id');
                 $q->addTable('departments');
                 $q->addWhere('dept_name LIKE \'' . mb_trim($pairs['contact_department']) . '\'');
                 $dept_id = $q->loadResult();
                 $pairs['contact_department'] = $dept_id ? $dept_id : 0;
                 $q->clear();
                 $contact_id = $q->insertArray($sql_table, $pairs);
                 $q->clear();
                 foreach ($contact_array as $name => $value) {
                     $q->addTable('contacts_methods');
                     $q->addInsert('contact_id', $contact_id);
                     $q->addInsert('method_name', $name);
                     $q->addInsert('method_value', $value);
                     $q->exec();
                     $q->clear();
                 }
             }
         }
         $s .= '</tr>';
     }
     $s .= '</table>';
 }