本文整理汇总了PHP中CB\DB\dbQuery函数的典型用法代码示例。如果您正苦于以下问题:PHP dbQuery函数的具体用法?PHP dbQuery怎么用?PHP dbQuery使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbQuery函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* create an object with specified params
* @param array $p object properties
* @return int created id
*/
public function create($p = false)
{
if ($p === false) {
$p = $this->data;
}
// check input params
if (!isset($p['target_id'])) {
throw new \Exception("No target id specified for shortcut creation", 1);
}
//check if target is also shortuc and replace with its target
if (Objects::getType($p['target_id']) == 'shortcut') {
$res = DB\dbQuery('SELECT target_id
FROM tree
WHERE id = $1', $p['target_id']) or die(DB\dbQueryError());
if ($r = $res->fetch_assoc()) {
$p['target_id'] = $r['target_id'];
}
$res->close();
}
$p['name'] = 'link to #' . $p['target_id'];
if (empty($p['template_id'])) {
$p['template_id'] = \CB\Config::get('default_shortcut_template');
}
$this->data = $p;
return parent::create($p);
}
示例2: onNodeDbCreate
/**
* create system folders specified in created objects template config as system_folders property
* @param object $o
* @return void
*/
public function onNodeDbCreate($o)
{
if (!is_object($o)) {
return;
}
$template = $o->getTemplate();
if (empty($template)) {
return;
}
$templateData = $template->getData();
if (empty($templateData['cfg']['system_folders'])) {
return;
}
$folderIds = Util\toNumericArray($templateData['cfg']['system_folders']);
if (empty($folderIds)) {
return;
}
$p = array('sourceIds' => array(), 'targetId' => $o->getData()['id']);
$browserActionsClass = new Browser\Actions();
$res = DB\dbQuery('SELECT id
FROM tree
WHERE pid in (' . implode(',', $folderIds) . ')
AND dstatus = 0');
while ($r = $res->fetch_assoc()) {
$p['sourceIds'][] = $r['id'];
}
$res->close();
// $browserActionsClass->copy($p);
$browserActionsClass->objectsClass = new \CB\Objects();
$browserActionsClass->doRecursiveAction('copy', $p['sourceIds'], $p['targetId']);
}
示例3: delete
/**
* delete a record by its id
* @param int $id
* @return boolean
*/
public static function delete($id)
{
static::validateParamTypes(array('id' => $id));
DB\dbQuery('DELETE from `' . static::$tableName . '` ' . 'WHERE id = $1', $id) or die(DB\dbQueryError());
$rez = DB\dbAffectedRows() > 0;
return $rez;
}
示例4: getContentItems
public function getContentItems()
{
$p =& $this->requestParams;
$folderTemplates = \CB\Config::get('folder_templates');
$p['fl'] = 'id,system,path,name,case,date,date_end,size,cid,oid,cdate,uid,udate,template_id,acl_count,cls,status,task_status,dstatus';
if (@$p['from'] == 'tree') {
$p['templates'] = $folderTemplates;
}
if (is_numeric($this->lastNode->id)) {
$p['pid'] = $pid;
}
$p['dstatus'] = 1;
$p['fq'] = $this->fq;
$s = new \CB\Search();
$rez = $s->query($p);
if (!empty($rez['data'])) {
for ($i = 0; $i < sizeof($rez['data']); $i++) {
$d =& $rez['data'][$i];
$res = DB\dbQuery('SELECT cfg
, (SELECT 1
FROM tree
WHERE pid = $1' . (@$p['from'] == 'tree' ? ' AND `template_id` IN (0' . implode(',', $folderTemplates) . ')' : '') . ' LIMIT 1) has_childs
FROM tree
WHERE id = $1', $d['id']) or die(DB\dbQueryError());
if ($r = $res->fetch_assoc()) {
$d['cfg'] = Util\toJSONArray($r['cfg']);
$d['has_childs'] = !empty($r['has_childs']);
}
$res->close();
}
}
return $rez;
}
示例5: read
/**
* read objects data in bulk manner
* @param array $ids
* @return array
*/
public static function read($ids)
{
$rez = array();
$ids = Util\toNumericArray($ids);
if (!empty($ids)) {
$sql = 'SELECT t.*
,ti.pids
,ti.path
,ti.case_id
,ti.acl_count
,ti.security_set_id
,o.data
,o.sys_data
FROM tree t
JOIN tree_info ti
ON t.id = ti.id
LEFT JOIN objects o
ON t.id = o.id
WHERE t.id in (' . implode(',', $ids) . ')';
$res = DB\dbQuery($sql) or die(DB\dbQueryError());
while ($r = $res->fetch_assoc()) {
$r['data'] = Util\jsonDecode($r['data']);
$r['sys_data'] = Util\jsonDecode($r['sys_data']);
$rez[] = $r;
}
$res->close();
}
return $rez;
}
示例6: checkTableExistance
public static function checkTableExistance()
{
return DB\dbQuery('CREATE TABLE IF NOT EXISTS `guids`(
`id` bigint(20) unsigned NOT NULL auto_increment ,
`name` varchar(200) COLLATE utf8_general_ci NOT NULL ,
PRIMARY KEY (`id`) ,
UNIQUE KEY `guids_name`(`name`)
) ENGINE=InnoDB DEFAULT CHARSET=\'utf8\' COLLATE=\'utf8_general_ci\'', array());
}
示例7: deleteByNodeId
public static function deleteByNodeId($nodeId, $userId = false)
{
if ($userId == false) {
$userId = \CB\User::getId();
}
DB\dbQuery('DELETE FROM ' . static::getTableName() . ' WHERE user_id = $1 AND node_id = $2', array($userId, $nodeId)) or die(DB\dbQueryError());
$rez = DB\dbAffectedRows() > 0;
return $rez;
}
示例8: delete
/**
* delete core record form __casebox.cores table
* and drop database
* @param varchar $idOrName
* @return boolean
*/
public static function delete($idOrName)
{
$id = static::toId($idOrName);
$data = static::read($id);
$rez = parent::delete($id);
if ($rez) {
$dbName = Config::get('prefix') . '_' . $data['name'];
DB\dbQuery("DROP DATABASE `{$dbName}`") or die(DB\dbQueryError());
}
return $rez;
}
示例9: getName
public function getName($id = false)
{
if ($id == false) {
$id = $this->id;
}
$rez = 'no name';
$res = DB\dbQuery('SELECT name FROM tree WHERE id = $1', $id) or die(DB\dbQueryError());
if ($r = $res->fetch_assoc()) {
$rez = $r['name'];
}
$res->close();
return $rez;
}
示例10: getRecords
/**
* update a record
* @param array $p array with properties
* @return array
*/
public static function getRecords($ids)
{
$rez = array();
$ids = Util\toNumericArray($ids);
$res = DB\dbQuery('SELECT *
FROM `' . static::getTableName() . '`
WHERE id in (0' . implode(',', $ids) . ')');
while ($r = $res->fetch_assoc()) {
$rez[] = $r;
}
$res->close();
return $rez;
}
示例11: getVersionByMD5
/**
* get oldest version ids after a given skipCount
* @param int $fileId
* @param varchar $md5
* @return array | false
*/
public static function getVersionByMD5($fileId, $md5)
{
$rez = array();
$res = DB\dbQuery('SELECT f.*
FROM files_versions f
JOIN files_content c ON f.content_id = c.id
AND c.md5 = $2
WHERE f.file_id = $1', array($fileId, $md5));
if ($r = $res->fetch_assoc()) {
$rez = $r;
}
return $rez;
}
示例12: copy
/**
* copy a record
* @param int $id
* @return boolean
*/
public static function copy($sourceId, $targetId)
{
DB\dbQuery('INSERT INTO `objects`
(`id`
,`data`
,`sys_data`)
SELECT
$2
,`data`
,`sys_data`
FROM `objects`
WHERE id = $1', array($sourceId, $targetId)) or die(DB\dbQueryError());
return DB\dbAffectedRows() > 0;
}
示例13: getName
public function getName($id = false)
{
if ($id == false) {
$id = $this->id;
}
$rez = 'no name';
$res = DB\dbQuery('SELECT name, iconCls FROM templates WHERE id = $1', $id);
if ($r = $res->fetch_assoc()) {
$rez = $r['name'];
$this->iconCls = $r['iconCls'];
}
$res->close();
return $rez;
}
示例14: readNames
/**
* read recods in bulk for given names
* @param array $names
* @return associative array ('name' => id)
*/
public static function readNames($names)
{
$rez = array();
$params = array();
for ($i = 1; $i <= sizeof($names); $i++) {
$params[] = '$' . $i;
}
$sql = 'SELECT id, name
FROM ' . static::getTableName() . '
WHERE name in (' . implode(',', $params) . ')';
$res = DB\dbQuery($sql, $names) or die(DB\dbQueryError());
while ($r = $res->fetch_assoc()) {
$rez[$r['name']] = $r['id'];
}
$res->close();
return $rez;
}
示例15: getContentPaths
/**
* get relative content paths for given file ids
* path is relative to casebox files directory
* @param array $ids
* @return array associative array (id => relative_content_path)
*/
public static function getContentPaths($ids)
{
$rez = array();
$ids = Util\toNumericArray($ids);
if (!empty($ids)) {
$sql = 'SELECT f.id, c.`path`, f.content_id
FROM files f
JOIN files_content c
ON f.content_id = c.id
WHERE f.id in (' . implode(',', $ids) . ')';
$res = DB\dbQuery($sql) or die(DB\dbQueryError());
while ($r = $res->fetch_assoc()) {
$rez[$r['id']] = $r['path'] . DIRECTORY_SEPARATOR . $r['content_id'];
}
$res->close();
}
return $rez;
}