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


PHP Database::sql方法代码示例

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


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

示例1: delete_unused_urls

    public function delete_unused_urls()
    {
        Database::begin();
        try {
            Database::sql('DELETE FROM post_link WHERE
				post_id NOT IN (SELECT id FROM post)');
            Database::sql('DELETE FROM post_update_link WHERE
				update_id NOT IN (SELECT id FROM post_update)');
            Database::sql('DELETE FROM post_link_url WHERE
				link_id NOT IN (SELECT id FROM post_link)');
            Database::sql('DELETE FROM post_update_link_url WHERE
				link_id NOT IN (SELECT id FROM post_update_link)');
            Database::sql('DELETE FROM post_url WHERE
				id NOT IN (SELECT url_id FROM post_link_url) AND
				id NOT IN (SELECT url_id FROM post_update_link_url)');
            $count = Database::count_affected();
            if ($count > self::MAX_LINK_DELETIONS) {
                Database::rollback();
                throw new Error_Cron('Too many post urls pending for deletion');
            }
            Database::commit();
        } catch (PDOException $e) {
            Database::rollback();
            throw new Error_Cron('Error with database, while deleting post urls');
        }
    }
开发者ID:4otaku,项目名称:4otaku,代码行数:26,代码来源:post.php

示例2: edittag

	function edittag() {

		Check::rights();

		if (query::$post['old_alias'] != query::$post['alias']) {
			$params = array(
				'|'.query::$post['old_alias'].'|',
				'|'.query::$post['alias'].'|',
			);

			Database::sql('update post set tag = replace(tag,?,?)', $params);
			Database::sql('update video set tag = replace(tag,?,?)', $params);
			Database::sql('update art set tag = replace(tag,?,?)', $params);
		}

		$variants = array_unique(array_filter(explode(' ',str_replace(',', ' ', query::$post['variants']))));
		if (!empty($variants)) {
			$variants = '|'.implode('|',$variants).'|';
		} else {
			$variants = '|';
		}

		Database::update('tag', array(
			'alias' => query::$post['alias'],
			'name' => query::$post['name'],
			'variants' => $variants,
			'color' => query::$post['color']
		), query::$post['id']);
	}
开发者ID:4otaku,项目名称:4otaku,代码行数:29,代码来源:admin.php

示例3: myplugin_activate

function myplugin_activate()
{
    $db = new Database();
    $db->connect();
    // Create Items Table
    $filesTableExists = $db->select("items");
    if (!$filesTableExists) {
        $sql = "CREATE TABLE items (\n\t\t\t\t\tid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t\tname VARCHAR(200) NOT NULL,\n\t\t\t\t\tuploaded_timestamp timestamp,\n\t\t\t\t\tlast_updated_timestamp timestamp\n\t\t\t\t)";
        $result = $db->sql($sql);
        if ($result) {
            echo "Items Table created.<br>";
        } else {
            echo "Error When Creating Items Table<br>";
        }
    } else {
        echo "Items Table already exists.<br>";
    }
    // Create Files Table
    $filesTableExists = $db->select("files");
    if (!$filesTableExists) {
        //change on uploaded attr
        $sql = "CREATE TABLE files (\n\t\t\t\t\tid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t\tfileName VARCHAR(300) NOT NULL,\n\t\t\t\t\tname VARCHAR(200) NOT NULL,\n\t\t\t\t\tpath VARCHAR(200) NOT NULL,\n\t\t\t\t\tviews INT NOT NULL,\n\t\t\t\t\tuploadedTimestamp timestamp,\n\t\t\t\t\tlastUpdatedTimestamp timestamp\n\t\t\t\t)";
        $result = $db->sql($sql);
        if ($result) {
            echo "Files Table created.<br>";
        } else {
            echo "Error When Creating Files Table<br>";
        }
    } else {
        echo "Files Table already exists.<br>";
    }
    // Create File Connector Table
    $fileConnectorTableExists = $db->select("file_connector");
    if (!$fileConnectorTableExists) {
        $sql = "CREATE TABLE file_connector (\n\t\t\t\t\tid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t\tfile_id INT NOT NULL,\n\t\t\t\t\titem_id INT NOT NULL,\n\t\t\t\t\tlabel VARCHAR(50) NOT NULL,\n\t\t\t\t\tfeatured_image INT NOT NULL,\n\t\t\t\t\tdisplay INT NOT NULL\n\n\t\t\t\t)";
        $result = $db->sql($sql);
        if ($result) {
            echo "Category Connector Table created.<br>";
        } else {
            echo "Error When Creating Category Connector Table<br>";
        }
    } else {
        echo "Category Connector Table already exists.<br>";
    }
}
开发者ID:mawilliamson,项目名称:version-control,代码行数:45,代码来源:index.php

示例4: createSql

 /**
  *
  * creating new implementation of mysqli, with Database configuration
  *
  * @param string $db_name name of the database
  *
  * @return bool
  */
 static function createSql($db_name)
 {
     self::$sql = new mysqli(DB_HOST, DB_USER, DB_PASS, $db_name);
     if (!self::$sql) {
         return false;
     }
     self::$sql->set_charset('utf8');
     return true;
 }
开发者ID:cobicarmel,项目名称:agenda,代码行数:17,代码来源:db.class.php

示例5: get_asignado

 public static function get_asignado($usuario)
 {
     //DB Conection
     $db = new Database();
     $db->connect();
     $sql = "SELECT CONCAT_WS(' ', IF(nombre != '', nombre, ''), IF(apellido != '', apellido, '')) AS nombre_completo, email, HEX(uuid_usuario) as uuid_usuario FROM usuarios WHERE uuid_usuario IN('" . $usuario . "')\n\t\t\t\tAND status = 'Activo'";
     $db->sql($sql);
     $results = $db->getResult();
     return array('nombre_completo' => $results[0]['nombre_completo'], 'uuid_usuario' => $results[0]['uuid_usuario']);
 }
开发者ID:acampos1916,项目名称:corcione_produccion,代码行数:10,代码来源:Notificaciones.php

示例6: getByEmail

 public function getByEmail($email)
 {
     $db = new Database();
     $db->sql("select s.id,u.Email,u.FirstName,u.LastName,s.Project,s.Location, case when(select GradesPosted from Settings) = 1 then s.Grade else null end as Grade\nfrom Users as u inner join Students as s on u.StudentId = s.id\nwhere u.Email = '" . $email . "'");
     $res = $db->getResult();
     if (count($res) == 0) {
         return null;
     }
     return $res;
 }
开发者ID:M7ammed,项目名称:Mobile-Judge-App,代码行数:10,代码来源:Students.php

示例7: add

 public static function add(&$data)
 {
     // Fields
     $SessionId = md5(microtime());
     $Ip = Database::escape($_SERVER['REMOTE_ADDR']);
     $UserAgent = Database::escape($_SERVER['HTTP_USER_AGENT']);
     $Created = time();
     $Data = Database::escape(serialize($data));
     $sql = "INSERT INTO `SystemSession` (`id`, `__timestamp__`, `__operation__`, `SessionId`, `Ip`, `UserAgent`, `Created`, `Data`) VALUES (NULL, " . time() . ", 'INSERT', '{$SessionId}', '{$Ip}', '{$UserAgent}', '{$Created}', '{$Data}')";
     // Run query
     $result = Database::sql($sql);
     $id = Database::getInsertId();
     return self::ROW($id);
 }
开发者ID:fulldump,项目名称:8,代码行数:14,代码来源:extended.class.php

示例8: getContact

 public function getContact($email)
 {
     $db = new Database();
     $db->sql('select FirstName, LastName, Email from Users where Email = \'' . $email . '\'');
     $res = $db->getResult();
     $total = 0;
     if (array_key_exists('LastName', $res)) {
         $res = array($res);
         $total = count($res);
     } else {
         $res = $email;
     }
     return array('total' => $total, 'data' => $res);
 }
开发者ID:M7ammed,项目名称:Mobile-Judge-App,代码行数:14,代码来源:Email.php

示例9: profile

function profile($req, $res)
{
    try {
        $id = $req->id;
        $data = Database::sql("select * from students where id = {$id}");
    } catch (Exception $e) {
        exit($e->getMessage());
    }
    if (!$data) {
        $res->code(404);
        echo 'Not Found';
    } else {
        $res->header('Content-Type', 'application/json');
        echo json_encode($data);
    }
}
开发者ID:samdubey,项目名称:ads2,代码行数:16,代码来源:back-index.php

示例10: setAccept

 public function setAccept($judgeId, $studentId, $acceptance)
 {
     $db = new Database();
     $success = $db->update('JudgeStudentGrade', array('Accepted' => $acceptance ? 1 : 0), 'JudgeId = ' . $judgeId . ' and StudentId = ' . $studentId);
     $msg = $db->getResult();
     if (!$success) {
         return array('success' => false, 'msg' => $msg);
     }
     $db->select('JudgeStudentGrade', 'Grade, Accepted', null, 'StudentId = ' . $studentId);
     $res = $db->getResult();
     if (array_key_exists('Grade', $res)) {
         $res = array($res);
     }
     $grade = 0;
     $reviewed = 0;
     $accepted = 0;
     $total = 0;
     foreach ($res as $judge) {
         $total++;
         if (is_null($judge['Accepted'])) {
             continue;
         }
         if (intval($judge['Accepted']) === 1) {
             $accepted++;
             $grade += intval($judge['Grade']);
         }
         $reviewed++;
     }
     if ($total == $reviewed && $accepted > 0) {
         $grade /= $accepted;
         $db->update('Students', array('Grade' => $grade), 'id = ' . $studentId);
         return array('success' => true, 'grade' => $grade);
     } else {
         $db->sql('UPDATE Students SET Grade = NULL WHERE id = ' . $studentId . ';');
         return array('success' => true, 'grade' => null);
     }
 }
开发者ID:M7ammed,项目名称:Mobile-Judge-App,代码行数:37,代码来源:PendingGrades.php

示例11: getUsuarios

 private static function getUsuarios($user_info)
 {
     //DB Conection
     $db = new Database();
     $db->connect();
     $sql = "SELECT usr.id_usuario, HEX(uuid_usuario) as uuid_usuario, HEX(ucat.uuid_categoria) as uuid_categoria, reporta_rol, reporta_usuario, id_rol, ucat.key\n\t\t\t\tFROM usuarios AS usr\n\t\t\t\tLEFT JOIN usuario_rol as urol ON urol.id_usuario = usr.id_usuario\n\t\t\t\tLEFT JOIN usuarios_categoria as ucat ON ucat.uuid_categoria = usr.uuid_categoria\n\t\t\t\tWHERE reporta_rol = " . $user_info[0]["id_rol"];
     if (!empty($user_info[0]["key"]) && $user_info[0]["key"] != 'admin') {
         $sql .= " AND HEX(ucat.uuid_categoria) = " . $user_info[0]["uuid_categoria"];
     }
     $sql .= " AND reporta_usuario = 0  OR reporta_usuario =  " . $user_info[0]["id_usuario"];
     $db->sql($sql);
     $result = $db->getResult();
     if (!empty($result) && count($result) > 0) {
         foreach ($result as $usuario) {
             array_push(self::$array_helper, $usuario["uuid_usuario"]);
             if (!in_array($usuario["uuid_usuario"], self::$array_helper, true)) {
                 self::getUsuarios(self::$array_helper, $usuario);
             }
         }
     } else {
         array_push(self::$array_helper, $user_info[0]["uuid_usuario"]);
     }
     return self::$array_helper;
 }
开发者ID:acampos1916,项目名称:corcione_produccion,代码行数:24,代码来源:Reportes.php

示例12: Database

"<?php 
            }
            ?>
 maxlength="9" required="required" aria-describedby="helpBlock">
						<span id="helpBlock" class="help-block">Format: 2000/2000</span>
					</div>
				</div>

				<div class="form-group">
					<label for="inputProgram" class="col-sm-2 control-label">Program:</label>
					<div class="col-sm-10">
						<select name="program" id="inputProgram" class="form-control" required="required">
							<?php 
            $dp = new Database();
            $dp->connect();
            $dp->sql('select id,nama from program union select id,nama from programs');
            $dp = $dp->getResult();
            foreach ($dp as $dp) {
                ?>
							<option value="<?php 
                echo $dp['id'];
                ?>
" <?php 
                if (isset($_GET['id'])) {
                    echo selek($dp['id'], $d[0]['idprogram']);
                }
                ?>
><?php 
                echo $dp['nama'];
                ?>
</option>
开发者ID:teknomatika,项目名称:kursus,代码行数:31,代码来源:kelas.php

示例13: ob_end_clean

<?php

include '../inc.common.php';
ob_end_clean();
$news = Database::get_full_vector('news');
Database::sql('ALTER TABLE  `news` ADD  `extension` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER  `image`');
foreach ($news as $id => $item) {
    rename(IMAGES . SL . 'full' . SL . $item['image'], IMAGES . SL . 'news' . SL . 'full' . SL . $item['image']);
    rename(IMAGES . SL . 'thumbs' . SL . $item['image'], IMAGES . SL . 'news' . SL . 'thumb' . SL . preg_replace('/\\.[a-z]+$/ui', '.jpg', $item['image']));
    Database::update('news', array('image' => preg_replace('/\\.[a-z]+$/ui', '', $item['image']), 'extension' => preg_replace('/^.*\\./ui', '', $item['image'])), $id);
    Database::update('comment', array('post_id' => $id), 'post_id = ?', $item['url']);
}
Database::sql('ALTER TABLE `news` DROP `url`;');
Database::sql('ALTER TABLE  `news` ADD  `author` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER  `extension` ,
ADD  `category` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER  `author`;');
Database::sql('update news set category = \'|website|\' where 1;');
Database::sql('update news set author = \'|nameless|\' where 1;');
Database::sql('update news set pretty_text = \'\' where 1;');
Database::sql('INSERT INTO  `category` (`id` ,`alias` ,`name` ,`area`)VALUES (NULL ,  \'website\',  \'Новости сайта\',  \'|news|\');');
Database::sql('INSERT INTO  `category` (`id` ,`alias` ,`name` ,`area`)VALUES (NULL ,  \'otaku\',  \'Новости индустрии\',  \'|news|\');');
开发者ID:4otaku,项目名称:4otaku,代码行数:20,代码来源:port_news.php

示例14: DELETE

 public function DELETE($physical = true)
 {
     if ($physical) {
         $sql = "DELETE FROM `Comment` WHERE id='" . $this->id . "'";
         unset(self::$data[$this->id]);
     } else {
         $sql = "UPDATE `Comment` SET `__timestamp__` = " . time() . ", `__operation__` = 'DELETE' WHERE `id`='" . $this->id . "'";
     }
     Database::sql($sql);
 }
开发者ID:fulldump,项目名称:8,代码行数:10,代码来源:auto.class.php

示例15: setTitle

 public function setTitle($value)
 {
     $this->row['Title'] = $value;
     $value = Database::escape($value);
     $timestamp = time();
     $sql = "UPDATE `Blog` SET `Title`='{$value}',`__timestamp__` = {$timestamp}, `__operation__` = 'UPDATE' WHERE `id`='{$this->id}'";
     Database::sql($sql);
 }
开发者ID:fulldump,项目名称:8,代码行数:8,代码来源:auto.class.php


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