当前位置: 首页>>代码示例>>PHP>>正文


PHP DBQuery::addInsert方法代码示例

本文整理汇总了PHP中DBQuery::addInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP DBQuery::addInsert方法的具体用法?PHP DBQuery::addInsert怎么用?PHP DBQuery::addInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBQuery的用法示例。


在下文中一共展示了DBQuery::addInsert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 public function store()
 {
     $this->w2PTrimAll();
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . '::store-check failed - ' . $msg;
     }
     $values = parseFormatSysval($this->sysval_value, $this->sysval_key_id);
     //lets delete the old values
     $q = new DBQuery();
     if ($this->sysval_key_id && $this->sysval_title) {
         $q->setDelete('sysvals');
         $q->addWhere('sysval_key_id = ' . (int) $this->sysval_key_id);
         $q->addWhere('sysval_title = \'' . $this->sysval_title . '\'');
         if (!$q->exec()) {
             $q->clear();
             return get_class($this) . '::store failed: ' . db_error();
         }
     }
     foreach ($values as $key => $value) {
         $q->addTable('sysvals');
         $q->addInsert('sysval_key_id', $this->sysval_key_id);
         $q->addInsert('sysval_title', $this->sysval_title);
         $q->addInsert('sysval_value_id', $key);
         $q->addInsert('sysval_value', $value);
         if (!$q->exec()) {
             $q->clear();
             return get_class($this) . '::store failed: ' . db_error();
         }
         $q->clear();
     }
     return null;
 }
开发者ID:joly,项目名称:web2project,代码行数:33,代码来源:syskeys.class.php

示例2: install

 function install()
 {
     $ok = true;
     $q = new DBQuery();
     $sql = "(\n\t\t\tresource_id integer not null auto_increment,\n\t\t\tresource_name varchar(255) not null default '',\n\t\t\tresource_key varchar(64) not null default '',\n\t\t\tresource_type integer not null default 0,\n\t\t\tresource_note text not null default '',\n\t\t\tresource_max_allocation integer not null default 100,\n\t\t\tprimary key (resource_id),\n\t\t\tkey (resource_name),\n\t\t\tkey (resource_type)\n\t\t)";
     $q->createTable('resources');
     $q->createDefinition($sql);
     $ok = $ok && $q->exec();
     $q->clear();
     $sql = "(\n\t\t\tresource_type_id integer not null auto_increment,\n\t\t\tresource_type_name varchar(255) not null default '',\n\t\t\tresource_type_note text,\n\t\t\tprimary key (resource_type_id)\n\t\t)";
     $q->createTable('resource_types');
     $q->createDefinition($sql);
     $ok = $ok && $q->exec();
     $q->clear();
     $sql = "(\n\t\t\tresource_id integer not null default 0,\n\t\t\ttask_id integer not null default 0,\n\t\t\tpercent_allocated integer not null default 100,\n\t\t\tkey (resource_id),\n\t\t\tkey (task_id, resource_id)\n\t\t)";
     $q->createTable('resource_tasks');
     $q->createDefinition($sql);
     $ok = $ok && $q->exec();
     $q->clear();
     $q->addTable('resource_types');
     $q->addInsert('resource_type_name', 'Equipment');
     $q->exec();
     $q->addInsert('resource_type_name', 'Tool');
     $q->exec();
     $q->addInsert('resource_type_name', 'Venue');
     $ok = $ok && $q->exec();
     if (!$ok) {
         return false;
     }
     return null;
 }
开发者ID:illuminate3,项目名称:dotproject,代码行数:31,代码来源:setup.php

示例3: dPsessionWrite

function dPsessionWrite($id, $data)
{
    global $AppUI;
    $q = new DBQuery();
    $q->addQuery('count(*) as row_count');
    $q->addTable('sessions');
    $q->addWhere("session_id = '{$id}'");
    if (($qid =& $q->exec()) && (@$qid->fields['row_count'] > 0 || @$qid->fields[0] > 0)) {
        dprint(__FILE__, __LINE__, 11, "Updating session {$id}");
        $q->query = null;
        $q->addUpdate('session_data', $data);
        if (isset($AppUI)) {
            $q->addUpdate('session_user', $AppUI->last_insert_id);
        }
    } else {
        dprint(__FILE__, __LINE__, 11, "Creating new session {$id}");
        $q->query = null;
        $q->where = null;
        $q->addInsert('session_id', $id);
        $q->addInsert('session_data', $data);
        $q->addInsert('session_created', date('Y-m-d H:i:s'));
    }
    $q->exec();
    $q->clear();
    return true;
}
开发者ID:n2i,项目名称:xvnkb,代码行数:26,代码来源:session.php

示例4: w2PsessionWrite

function w2PsessionWrite($id, $data)
{
    global $AppUI;
    $q = new DBQuery();
    $q->addQuery('count(session_id) as row_count');
    $q->addTable('sessions');
    $q->addWhere('session_id = \'' . $id . '\'');
    if (($qid =& $q->exec()) && ($qid->fields['row_count'] > 0 || $qid->fields[0] > 0)) {
        //dprint(__file__, __line__, 11, "Updating session $id");
        $q->query = null;
        $q->addUpdate('session_data', $data);
        if (isset($AppUI)) {
            $q->addUpdate('session_user', (int) $AppUI->last_insert_id);
        }
    } else {
        //dprint(__file__, __line__, 11, "Creating new session $id");
        $q->query = null;
        $q->where = null;
        $q->addInsert('session_id', $id);
        $q->addInsert('session_data', $data);
        $q->addInsert('session_created', date('Y-m-d H:i:s'));
    }
    $q->exec();
    $q->clear();
    return true;
}
开发者ID:joly,项目名称:web2project,代码行数:26,代码来源:session.php

示例5: testInsertBD

 function testInsertBD()
 {
     $q = new DBQuery();
     $q->addTable('eap');
     $q->addQuery("id,nome,linha,coluna");
     $q->addInsert(nome, 'Build Teste');
     $q->addInsert(linha, 2);
     $q->addInsert(coluna, 3);
     $q->prepareInsert();
     $this->assertEqual($q->exec(), true);
     $q->clear();
 }
开发者ID:hoodoogurus,项目名称:dotprojecteap,代码行数:12,代码来源:test_eap.php

示例6: add

 /**
  * Add an event to the queue.
  *
  * The callback can either be the name of a global function or the
  * name of a class
  * @param mixed $callback function to call when this event is due.
  * @param mixed $args Arguments to pass to the callback
  * @param string $module module, or originator of the event
  * @param string $type type of event (to allow searching)
  * @param integer $id id of originating event.
  * @param integer $date Seconds since 1970 to trigger event.
  * @param integer $repeat_interval seconds to repeat
  * @param integer $repeat_count number of times to repeat
  * @return integer queue id
  */
 public function add($caller, &$args, $method = 'execute', $opts = array())
 {
     global $AppUI;
     if (!isset($AppUI)) {
         $user_id = 0;
     } else {
         $user_id = $AppUI->user_id;
     }
     /* Simple expedient, caller should be the $this pointer of the
        calling class, and the class should provide the method getModuleName.
        This also is only a short-term solution, in reality we should align classes
        and modules so we can autoload */
     $class = get_class($caller);
     $full_method = 'EventQueue_' . $method;
     // Set some default values that are overriden with $opts
     $date = 0;
     $repeat_interval = 0;
     $repeat_count = 1;
     $id = 0;
     $type = '';
     $batch = false;
     extract($opts);
     /* Check that we have a callable string */
     if ($batch) {
         if (!is_callable(array($class, $full_method . '_batched')) && !is_callable(array($class, $full_method))) {
             return false;
         }
     } else {
         if (!is_callable(array($class, $full_method . '_immediate')) && !is_callable(array($class, $full_method))) {
             return false;
         }
     }
     $q = new DBQuery();
     $q->addTable($this->table);
     $q->addInsert('queue_owner', $user_id);
     $q->addInsert('queue_start', $date);
     $q->addInsert('queue_callback', $class . '::' . $method);
     $q->addInsert('queue_data', serialize($args));
     $q->addInsert('queue_repeat_interval', $repeat_interval);
     $q->addInsert('queue_repeat_count', $repeat_count);
     $q->addInsert('queue_module', $caller->getModuleName());
     $q->addInsert('queue_type', $type);
     $q->addInsert('queue_origin_id', $id);
     $q->addInsert('queue_batched', $batch ? 1 : 0);
     if ($q->exec()) {
         $return = db_insert_id();
     } else {
         $return = false;
     }
     $q->clear();
     return $return;
 }
开发者ID:222elm,项目名称:dotprojectFrame,代码行数:67,代码来源:event_queue.class.php

示例7: install

    function install()
    {
        $q = new DBQuery();
        $q->createTable('risks');
        $sql = '(
			`risk_id` int(10) unsigned NOT NULL auto_increment,
			`risk_name` varchar(50) default NULL,
			`risk_description` text,
			`risk_probability` tinyint(3) default 100,
			`risk_status` text default NULL,
			`risk_owner` int(10) default NULL,
			`risk_project` int(10) default NULL,
			`risk_task` int(10) default NULL,
			`risk_impact` int(10) default NULL,
			`risk_duration_type` tinyint(10) default 1,
			`risk_notes` text,
			PRIMARY KEY  (`risk_id`),
			UNIQUE KEY `risk_id` (`risk_id`),
			KEY `risk_id_2` (`risk_id`))
			TYPE=MyISAM';
        $q->createDefinition($sql);
        $q->exec();
        $q->clear();
        $q->createTable('risk_notes');
        $sql = '(
			`risk_note_id` int(11) NOT NULL auto_increment,
			`risk_note_risk` int(11) NOT NULL default \'0\',
			`risk_note_creator` int(11) NOT NULL default \'0\',
			`risk_note_date` datetime NOT NULL default \'0000-00-00 00:00:00\',
			`risk_note_description` text NOT NULL,
			PRIMARY KEY  (`risk_note_id`)
			) TYPE=MyISAM';
        $q->createDefinition($sql);
        $q->exec();
        $q->clear();
        $q->addTable('sysvals');
        $q->addInsert('sysval_key_id', 1);
        $q->addInsert('sysval_title', 'RiskProbability');
        $q->addInsert('sysval_value', "0|Not Specified\n1|Low\n2|Medium\n3|High");
        $q->exec();
        $q->clear();
        $q->addTable('sysvals');
        $q->addInsert('sysval_key_id', 1);
        $q->addInsert('sysval_title', 'RiskStatus');
        $q->addInsert('sysval_value', "0|Not Specified\n1|Open\n2|Closed\n3|Not Applicable");
        $q->exec();
        $q->clear();
        $q->addTable('sysvals');
        $q->addInsert('sysval_key_id', 1);
        $q->addInsert('sysval_title', 'RiskImpact');
        $q->addInsert('sysval_value', "0|Not Specified\n1|Low\n2|Medium\n3|High\n4|Super High");
        $q->exec();
        $q->clear();
        return true;
    }
开发者ID:slawekmikula,项目名称:dotproject,代码行数:55,代码来源:setup.php

示例8: install

 function install()
 {
     $q = new DBQuery();
     $q->createTable('links');
     $q->createDefinition("(\n`link_id` int(11) NOT NULL AUTO_INCREMENT ,\n`link_url` varchar(255) NOT NULL default '',\n`link_project` int(11) NOT NULL default '0',\n`link_task` int(11) NOT NULL default '0',\n`link_name` varchar(255) NOT NULL default '',\n`link_parent` int(11) default '0',\n`link_description` text,\n`link_owner` int(11) default '0',\n`link_date` datetime default NULL ,\n`link_icon` varchar(20) default 'obj/',\n`link_category` int(11) NOT NULL default '0',\nPRIMARY KEY (`link_id`) ,\nKEY `idx_link_task` (`link_task`) ,\nKEY `idx_link_project` (`link_project`) ,\nKEY `idx_link_parent` (`link_parent`) \n) DEFAULT CHARSET utf8");
     $q->exec($sql);
     $q->clear();
     $q->addTable('sysvals');
     $q->addInsert('sysval_key_id', 1);
     $q->addInsert('sysval_title', 'LinkType');
     $q->addInsert('sysval_value', "0|Unknown\n1|Document\n2|Application");
     $q->exec();
     return NULL;
 }
开发者ID:222elm,项目名称:dotprojectFrame,代码行数:14,代码来源:setup.php

示例9: saveNote

 function saveNote($riskId, $userId, $riskDescription)
 {
     $q = new DBQuery();
     $q->addTable('risk_notes');
     $q->addInsert('risk_note_risk', $riskId);
     $q->addInsert('risk_note_creator', $userId);
     $q->addInsert('risk_note_date', 'NOW()', false, true);
     $q->addInsert('risk_note_description', $riskDescription);
     if (!$q->exec()) {
         return db_error();
     } else {
         return true;
     }
 }
开发者ID:slawekmikula,项目名称:dotproject,代码行数:14,代码来源:risks.class.php

示例10: install

    public function install()
    {
        $ok = true;
        $q = new DBQuery();
        $sql = '(
			resource_id integer not null auto_increment,
			resource_name varchar(255) not null default "",
			resource_key varchar(64) not null default "",
			resource_type integer not null default 0,
			resource_note text not null default "",
			resource_max_allocation integer not null default 100,
			primary key (resource_id),
			key (resource_name),
			key (resource_type)
		)';
        $q->createTable('resources', $sql);
        $ok = $ok && $q->exec();
        $q->clear();
        $sql = '(
			resource_type_id integer not null auto_increment,
			resource_type_name varchar(255) not null default "",
			resource_type_note text,
			primary key (resource_type_id)
		)';
        $q->createTable('resource_types', $sql);
        $ok = $ok && $q->exec();
        $q->clear();
        $sql = '(
			resource_id integer not null default 0,
			task_id integer not null default 0,
			percent_allocated integer not null default 100,
			key (resource_id),
			key (task_id, resource_id)
		)';
        $q->createTable('resource_tasks', $sql);
        $ok = $ok && $q->exec();
        $q->clear();
        $q->addTable('resource_types');
        $q->addInsert('resource_type_name', 'Equipment');
        $q->exec();
        $q->addInsert('resource_type_name', 'Tool');
        $q->exec();
        $q->addInsert('resource_type_name', 'Venue');
        $ok = $ok && $q->exec();
        if (!$ok) {
            return false;
        }
        return null;
    }
开发者ID:joly,项目名称:web2project,代码行数:49,代码来源:setup.php

示例11: resource_postsave

/**
 * postsave functions are only called after a succesful save.  They are
 * used to perform database operations after the event.
 */
function resource_postsave()
{
    global $other_resources;
    global $obj;
    $task_id = $obj->task_id;
    dprint(__FILE__, __LINE__, 5, "saving resources, {$other_resources}");
    if (isset($other_resources)) {
        $value = array();
        $reslist = explode(';', $other_resources);
        foreach ($reslist as $res) {
            if ($res) {
                list($resource, $perc) = explode('=', $res);
                $value[] = array($task_id, $resource, $perc);
            }
        }
        // first delete any elements already there, then replace with this
        // list.
        $q = new DBQuery();
        $q->setDelete('resource_tasks');
        $q->addWhere('task_id = ' . $obj->task_id);
        $q->exec();
        $q->clear();
        if (count($value)) {
            foreach ($value as $v) {
                $q->addTable('resource_tasks');
                $q->addInsert('task_id,resource_id,percent_allocated', $v, true);
                $q->exec();
                $q->clear();
            }
        }
    }
}
开发者ID:klr2003,项目名称:sourceread,代码行数:36,代码来源:tasks_dosql.addedit.php

示例12: insertCompany

function insertCompany($company_name)
{
    $q = new DBQuery();
    $q->addTable("companies");
    $q->addInsert('company_name', $company_name);
    db_exec($q->prepareInsert());
    return db_insert_id();
}
开发者ID:hoodoogurus,项目名称:dotprojecteap,代码行数:8,代码来源:upgrade_contacts_company.php

示例13: pinUserTask

 public static function pinUserTask($userId, $taskId)
 {
     $q = new DBQuery();
     $q->addTable('user_task_pin');
     $q->addInsert('user_id', (int) $userId);
     $q->addInsert('task_id', (int) $taskId);
     if (!$q->exec()) {
         return 'Error pinning task';
     } else {
         return true;
     }
 }
开发者ID:joly,项目名称:web2project,代码行数:12,代码来源:tasks.class.php

示例14: store

 function store()
 {
     $this->dPTrimAll();
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . '::store-check failed - ' . $msg;
     }
     if ($this->project_id) {
         $ret = db_updateObject('projects', $this, 'project_id', false);
         addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id);
     } else {
         $ret = db_insertObject('projects', $this, 'project_id');
         addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id);
     }
     //split out related departments and store them seperatly.
     $q = new DBQuery();
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_departments) {
         $departments = explode(',', $this->project_departments);
         foreach ($departments as $department) {
             $q->addTable('project_departments');
             $q->addInsert('project_id', $this->project_id);
             $q->addInsert('department_id', $department);
             $q->exec();
             $q->clear();
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('project_contacts');
     $q->addWhere('project_id=' . $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_contacts) {
         $contacts = explode(',', $this->project_contacts);
         foreach ($contacts as $contact) {
             if ($contact) {
                 $q->addTable('project_contacts');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('contact_id', $contact);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     return !$ret ? get_class($this) . '::store failed <br />' . db_error() : NULL;
 }
开发者ID:srinivasulurao,项目名称:jonel,代码行数:49,代码来源:projects.class.php

示例15: store

 function store()
 {
     global $db;
     if (!is_array($this->options)) {
         $this->options = array();
     }
     //load the dbs options and compare them with the options
     $q = new DBQuery();
     $q->addTable('custom_fields_lists');
     $q->addWhere('field_id = ' . $this->field_id);
     $q->addOrder('list_value');
     if (!($rs = $q->exec())) {
         $q->clear();
         return $db->ErrorMsg();
     }
     $dboptions = array();
     while ($opt_row = $q->fetchRow()) {
         $dboptions[$opt_row['list_option_id']] = $opt_row['list_value'];
     }
     $q->clear();
     $newoptions = array();
     $newoptions = array_diff($this->options, $dboptions);
     $deleteoptions = array_diff($dboptions, $this->options);
     //insert the new options
     foreach ($newoptions as $opt) {
         $optid = $db->GenID('custom_fields_option_id', 1);
         $q = new DBQuery();
         $q->addTable('custom_fields_lists');
         $q->addInsert('field_id', $this->field_id);
         $q->addInsert('list_option_id', $optid);
         $q->addInsert('list_value', db_escape($opt));
         if (!$q->exec()) {
             $insert_error = $db->ErrorMsg();
         }
         $q->clear();
     }
     //delete the deleted options
     foreach ($deleteoptions as $opt => $value) {
         $q = new DBQuery();
         $q->setDelete('custom_fields_lists');
         $q->addWhere('list_option_id = ' . $opt);
         if (!$q->exec()) {
             $delete_error = $db->ErrorMsg();
         }
         $q->clear();
     }
     return $insert_error . ' ' . $delete_error;
 }
开发者ID:illuminate3,项目名称:dotproject,代码行数:48,代码来源:CustomFields.class.php


注:本文中的DBQuery::addInsert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。