将数据插入表格

时间:2014-05-09 07:54:31

标签: php sql sugarcrm

我有自定义模块。 我想根据来自另一个模块的查询插入数据。 我使用了下面的代码。

function DuplicateReport()
{
    $dup_report = new dp_Duplicate_Data();
    $sql = "SELECT count(id) as cnt from contacts INNER JOIN (SELECT first_name,last_name,count(*) as rows FROM `contacts` where deleted = 0 GROUP BY first_name,last_name HAVING count(rows) > 1) as p where contacts.deleted=0 AND p.`first_name` = contacts.`first_name` and p.`last_name` = contacts.`last_name`";
    $result = $GLOBALS['db']->query($sql);
    $dup_name_no = mysql_num_rows($result); 
    $dup_report->contact_name = $dup_name_no;
    $dup_report->save();
}

但是没有插入。请帮助。

0 个答案:

没有答案