本文整理汇总了PHP中DBQuery类的典型用法代码示例。如果您正苦于以下问题:PHP DBQuery类的具体用法?PHP DBQuery怎么用?PHP DBQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCompanyDepartment
function getCompanyDepartment($company_id)
{
global $AppUI;
$q = new DBQuery();
$q->addTable('companies');
$q->addQuery('company_name');
$q->addWhere('company_id = ' . $company_id);
$company_name = $q->loadResult();
if (!$company_name) {
$AppUI->setMsg('Company not found', UI_MSG_ERROR);
echo $AppUI->getMsg();
return;
}
$q->addTable('departments');
$q->addQuery('dept_id,dept_parent,dept_name');
$q->addWhere('dept_company = ' . $company_id);
$q->addOrder('dept_parent, dept_name');
$depts = $q->loadHashList('dept_id');
if (!$depts) {
$AppUI->setMsg('Company [ ' . $company_name . ' ] has no department', UI_MSG_WARNING);
echo $AppUI->getMsg();
return;
}
include 'modules/public/resources.info.php';
}
示例2: createTables
/**
* This creates all the tables as defined in self::$required_tables
*/
public function createTables()
{
foreach (self::$required_tables as $statement) {
$query = new DBQuery($statement);
$query->execute();
}
}
示例3: setComplete
function setComplete($id)
{
global $AppUI;
$task = new CTask();
if ($task->load($id)) {
$q = new DBQuery();
$q->addTable('user_tasks');
$q->addQuery('user_id');
$q->addWhere('task_id = ' . $id);
$q->addWhere('user_id = ' . $AppUI->user_id);
$r = $q->loadResult();
if ($r != $AppUI->user_id) {
$p = new CProject($task->task_project);
if (!$p->project_id || $p->getManager() != $AppUI->user_id) {
return 'Error';
}
}
$q->addTable('tasks');
$q->addUpdate('task_percent_complete', '100');
$q->addWhere('task_id = ' . $id);
$q->exec();
return 'OK';
}
return 'Error';
}
示例4: delete
function delete()
{
$q = new DBQuery();
$q->addTable('departments', 'dep');
$q->addQuery('dep.*');
$q->addWhere('dep.dept_parent = ' . $this->dept_id);
$res = $q->exec();
if (db_num_rows($res)) {
$q->clear();
return "deptWithSub";
}
$q->clear();
$q->addTable('projects', 'p');
$q->addQuery('p.*');
$q->addWhere('p.project_department = ' . $this->dept_id);
$res = $q->exec();
if (db_num_rows($res)) {
$q->clear();
return "deptWithProject";
}
// $sql = "DELETE FROM departments WHERE dept_id = $this->dept_id";
$q->clear();
$q->addQuery('*');
$q->setDelete('departments');
$q->addWhere('dept_id = ' . $this->dept_id);
if (!$q->exec()) {
$result = db_error();
} else {
$result = NULL;
}
$q->clear();
return $result;
}
示例5: remove
function remove()
{
$q = new DBQuery();
$q->dropTable('projects_statistics');
$q->exec();
$q->clear();
return null;
}
示例6: remove
public function remove()
{
$q = new DBQuery();
$q->setDelete('modules');
$q->addWhere("mod_directory = 'importers'");
$q->exec();
return true;
}
示例7: 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();
}
示例8: 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();
}
}
}
}
示例9: bind
public function bind($hash)
{
if (!is_array($hash)) {
return get_class($this) . "::bind failed";
} else {
$q = new DBQuery();
$q->bindHashToObject($hash, $this);
$q->clear();
return null;
}
}
示例10: delete
function delete()
{
global $dPconfig;
$this->_message = "deleted";
// delete the main table reference
$q = new DBQuery();
$q->setDelete('links');
$q->addWhere('link_id = ' . $this->link_id);
if (!$q->exec()) {
return db_error();
}
return NULL;
}
示例11: listCompaniesByType
function listCompaniesByType($type)
{
global $AppUI;
$q = new DBQuery();
$q->addQuery('company_id, company_name');
$q->addTable('companies');
foreach ($type as $t) {
$q->addWhere('company_type =' . $t);
}
$this->setAllowedSQL($AppUI->user_id, $q);
$q->addOrder('company_name');
return $q->loadHashList();
}
示例12: _buildQuery
function _buildQuery()
{
$q = new DBQuery();
$q->addTable($this->table);
$q->addQuery('*');
$sql = '';
foreach ($this->search_fields as $field) {
$sql .= " {$field} LIKE '%{$this->keyword}%' or ";
}
$sql = substr($sql, 0, -4);
$q->addWhere($sql);
return $q->prepare(true);
}
示例13: getFolderSelectList
function getFolderSelectList()
{
global $AppUI;
$folders = array(0 => '');
$q = new DBQuery();
$q->addTable('file_folders');
$q->addQuery('file_folder_id, file_folder_name, file_folder_parent');
$q->addOrder('file_folder_name');
$sql = $q->prepare();
// $sql = "SELECT file_folder_id, file_folder_name, file_folder_parent FROM file_folders";
$vfolders = arrayMerge(array('0' => array(0, $AppUI->_('Root'), -1)), db_loadHashList($sql, 'file_folder_id'));
$folders = array_filter($vfolders, "check_perm");
return $folders;
}
示例14: remove
function remove()
{
$q = new DBQuery();
$q->dropTable('activity');
$q->exec();
$q->clear();
$q->dropTable('timesheet');
$q->exec();
$q->clear();
$q->dropTable('task_timesheet');
$q->exec();
$q->clear();
return db_error();
}
示例15: 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;
}