本文整理汇总了PHP中query类的典型用法代码示例。如果您正苦于以下问题:PHP query类的具体用法?PHP query怎么用?PHP query使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNice
function getNice()
{
if ($this->config['source']['type'] == 'table' && isset($this->config['source']['name'])) {
global $thinkedit;
$config = new config();
//$table = $thinkedit->newTable($this->config['source']['name']);
//
//$source->filter('id', '=', $this->getRaw());
$source_table = $this->config['source']['name'];
$title_fields = $config->getTitleFields($source_table);
require_once 'query.class.php';
$query = new query();
$query->addTable($this->config['source']['name']);
$query->addWhere('id', '=', $this->getRaw());
$results = $query->select();
if (count($results) > 0) {
foreach ($config->getTitleFields($source_table) as $field) {
$out .= $results[0][$field] . ' ';
}
return $out;
} else {
return $this->getRaw();
}
} else {
return $this->getRaw();
}
}
示例2: createImageFromFile
/**
* Create a image from a file. Do not add the file to the object library
* @param string Path to the source file
* @param string Description Text for ALT-Tag
* @param string Copright text for the image
* @param string Variation-ID of the image
*/
function createImageFromFile($sourceFile, $alt = "", $copyright = "", $variation = 1, $categoryId = 1)
{
global $c, $db;
$id = nextGUID();
$info = pathinfo($sourceFile);
$extension = $info["extension"];
$extension2 = strtoupper($extension);
$name = parseSQL($info["basename"]);
if ($extension2 == "JPG" || $extension2 == "GIF" || $extension2 == "PNG") {
$size = getimagesize($sourceFile);
$width = $size[0];
$height = $size[1];
copy($sourceFile, $c["devfilespath"] . $id . "." . $extension);
$thumb = new Img2Thumb($c["devfilespath"] . $id . "." . $extension, 120, 120, $c["devfilespath"] . "t" . $id);
$sql = "INSERT INTO pgn_image (FKID, FILENAME, ALT, COPYRIGHT, WIDTH, HEIGHT) VALUES ";
$sql .= "({$id}, '{$id}.{$extension}', '{$alt}', '{$copyright}', {$width}, {$height})";
$query = new query($db, $sql);
$query->free();
// Create Library Entry for this image
$cid = nextGUID();
$imageModule = getDBCell("modules", "MODULE_ID", "MODULE_NAME='Image'");
$sql = "INSERT INTO content (CID, MODULE_ID, NAME, CATEGORY_ID, MT_ID) VALUES ";
$sql .= "({$cid}, {$imageModule}, '{$name}', {$categoryId}, 0)";
$query = new query($db, $sql);
$query->free();
$sql = "INSERT INTO content_variations (CID, VARIATION_ID, FK_ID) VALUES ";
$sql .= "({$cid}, {$variation}, {$id})";
$query = new query($db, $sql);
$query->free();
return $cid;
} else {
return null;
}
}
示例3: get_by_report
public static function get_by_report($report_id)
{
$q = new query(RUDE_DATABASE_TABLE_EDUCATION_PREVIEW);
$q->where(RUDE_DATABASE_FIELD_REPORT_ID, (int) $report_id);
$q->query();
return $q->get_object_list();
}
示例4: getQuery
/**
* @return query
*/
public function getQuery()
{
$query = new query();
$query->setArguments($this->args);
$query->setQueryString($this->query);
return $query;
}
示例5: get_by_shortname
public static function get_by_shortname($shortname)
{
$q = new query(RUDE_DATABASE_TABLE_FACULTIES);
$q->where(RUDE_DATABASE_FIELD_SHORTNAME, $shortname);
$q->query();
return $q->get_object();
}
示例6: syncVariations
/**
* syncronize variations with entered data to the database.
* The configuration for this function must be set manually.
* I.E. there must be the $oid-Variable set and there must(!)
* be also the global vars content_variations_VARIATION_ID_XX
* and content_MODULE_ID
* set which are automatically set by the SelectMultiple2Input.
*/
function syncVariations()
{
global $db, $oid, $content_MODULE_ID;
$module = value("content_MODULE_ID", "NUMERIC");
if ($module == "0") {
$module = $content_MODULE_ID;
}
includePGNSource($module);
//delete all variations first.
$del = "UPDATE content_variations SET DELETED=1 WHERE CID = {$oid}";
$query = new query($db, $del);
// get list of variations
$variations = createNameValueArray("variations", "NAME", "VARIATION_ID", "DELETED=0");
for ($i = 0; $i < count($variations); $i++) {
$id = $variations[$i][1];
if (value("content_variations_VARIATION_ID_" . $id) != "0") {
// create or restore variation
// check, if variations already exists and is set to deleted.
$sql = "SELECT COUNT(CID) AS ANZ FROM content_variations WHERE CID = {$oid} AND VARIATION_ID = {$id}";
$query = new query($db, $sql);
$query->getrow();
$amount = $query->field("ANZ");
if ($amount > 0) {
$sql = "UPDATE content_variations SET DELETED=0 WHERE CID = {$oid} AND VARIATION_ID = {$id}";
} else {
$fk = nextGUID();
$sql = "INSERT INTO content_variations (CID, VARIATION_ID, FK_ID, DELETED) VALUES ( {$oid}, {$id}, {$fk}, 0)";
$PGNRef = createPGNRef($module, $fk);
$PGNRef->sync();
}
$query = new query($db, $sql);
}
}
}
示例7: findContentUsageClusterNodes
/**
* Find clusters, in which a plugin-entry is used.
* @param integer ID of the plugin-Key
*/
function findContentUsageClusterNodes($oid)
{
global $db;
// Initializing Array
$clusters = array();
// Determine cluster_templates using the object as static content...
$sql = "SELECT CLT_ID FROM cluster_template_items WHERE FKID = {$oid}";
$query = new query($db, $sql);
while ($query->getrow()) {
// Determine clusters using this template
$sql = "SELECT CLNID FROM cluster_node WHERE CLT_ID = " . $query->field("CLT_ID");
$subquery = new query($db, $sql);
while ($subquery->getrow()) {
array_push($clusters, $subquery->field("CLNID"));
}
$subquery->free();
}
$query->free();
// determine clusters using this content as library link...
$sql = "SELECT CLID FROM cluster_content WHERE FKID = {$oid} OR CLCID = {$oid}";
$query = new query($db, $sql);
while ($query->getrow()) {
// Determine clusters using this template
$sql = "SELECT CLNID FROM cluster_variations WHERE CLID=" . $query->field("CLID");
$subquery = new query($db, $sql);
while ($subquery->getrow()) {
array_push($clusters, $subquery->field("CLNID"));
}
$subquery->free();
}
$query->free();
$clusters = array_unique($clusters);
return $clusters;
}
示例8: process
/**
* save the changes...
*/
function process()
{
global $errors, $selected, $create, $sitepage_CLNID, $cluster_node_NAME, $db, $oid, $sid, $clt;
$this->check();
if ($selected != "0" && $sitepage_CLNID != "0" && $sitepage_CLNID != "") {
$mid = getVar("mid");
$sql = "UPDATE sitepage SET CLNID = {$sitepage_CLNID} WHERE SPID = {$oid}";
$query = new query($db, $sql);
$query->free();
// reload page, now in editing mode...
global $db;
$db->close();
header("Location: sitepagebrowser.php?sid={$sid}&mid={$mid}&action=editobject&go=update&oid={$oid}");
exit;
} else {
if ($create != "0" && $errors == "") {
$mid = getVar("mid");
$nextId = nextGUID();
$sql = "INSERT INTO cluster_node (CLNID, CLT_ID, NAME, DELETED) VALUES({$nextId}, {$clt}, '{$cluster_node_NAME}', 0)";
$query = new query($db, $sql);
$sql = "UPDATE sitepage SET CLNID = {$nextId} WHERE SPID = {$oid}";
$query = new query($db, $sql);
$query->free();
$backup = $oid;
$oid = $nextId;
syncClusterVariations();
$oid = $backup;
global $db;
$db->close();
header("Location: sitepagebrowser.php?sid={$sid}&mid={$mid}&action=editobject&go=update&oid={$oid}");
exit;
}
}
}
示例9: get_by_name
public static function get_by_name($name)
{
$q = new query(RUDE_DATABASE_TABLE_QUALIFICATIONS);
$q->where(RUDE_DATABASE_FIELD_NAME, $name);
$q->query();
return $q->get_object();
}
示例10: scopeMap
/**
* scope by detail to be used by google maps in dashboard
* @param query $query query object
* @return mixed new query object
*/
public function scopeMap($query)
{
$attrs = ['data_type', 'problem_type', 'code', 'name', 'lat', 'lng', 'tambon_name', 'amphoe_name', 'province_name', 'part', 'basin'];
// $attrs = ['problem_type', 'code', 'name', 'lat', 'lng', 'tambon_name', 'amphoe_name', 'province_name', 'part', 'basin'];
$query->join('tele_station', 'problems.station_code', '=', 'tele_station.code')->selectRaw(implode(", ", $attrs) . ', sum(num) as num')->groupBy($attrs);
return $query;
}
示例11: get_by_order
public static function get_by_order($education_id)
{
$q = new query(RUDE_DATABASE_TABLE_EDUCATION_ITEMS_VALUES);
$q->where('education_id', (int) $education_id);
$q->order_by('order_num', 'ASC');
$q->query();
return $q->get_object_list();
}
示例12: get_popup
public static function get_popup($user_id)
{
$q = new query(RUDE_DATABASE_TABLE_SETTINGS);
$q->where(RUDE_DATABASE_FIELD_USER_ID, (int) $user_id);
$q->where(RUDE_DATABASE_FIELD_NAME, 'popup');
$q->query();
return $q->get_object();
}
示例13: loginUser
function loginUser($user_id)
{
$query = new query();
$row = $query->getRow("idusuario, nombreusuario, tipousuario", "usuario", "WHERE idusuario = {$user_id}");
$_SESSION['logged'] = 1;
$_SESSION['nombreusuario'] = $row['nombreusuario'];
$_SESSION['idusuario'] = $row['idusuario'];
$_SESSION['tipousuario'] = $row['tipousuario'];
}
示例14: drawPGNTeaser
/**
* Draw a teaser defined with the teaser plugin
* @id internal id of the teaser. matched pgn_teaser.fkid.
*/
function drawPGNTeaser($id)
{
global $cds, $db;
$result = '';
$query = new query($db, "Select * FROM pgn_teaser Where FKID=" . $id);
if ($query->getrow()) {
$href = $query->field("HREF");
if (substr($href, 0, 4) == "www.") {
$href = 'http://' . $href;
}
$popup = $href != "";
$spid = $query->field('SPID');
if ($spid != "0" && $href == "") {
$menu = new Menu(null, $spid, $cds->variation, $cds->level);
$href = $menu->getLink();
}
$imageid = $query->field("IMAGEID");
$aTag = '<a href="' . $href . '"';
if ($popup) {
$aTag .= ' target="_blank"';
}
$aTag .= '>';
// image teaser
if ($query->field("ISIMAGETEASER") == "1") {
$result = $aTag . $cds->content->getById($imageid) . '</a>';
} else {
// usual teaser
$headline = $query->field("HEADLINE");
$body = $query->field("BODY");
$linktext = $query->field("LINKTEXT");
if ($linktext == "") {
$linktext = "read more";
}
$result = '<div class="teaser">';
if ($headline != "") {
$result .= '<b>' . $headline . '</b><br>';
}
if ($imageid != "0") {
$result .= $aTag . $cds->content->getById($imageid) . '</a><br>';
}
if ($body != "") {
$result .= $body;
}
if ($query->field("RESOLVECHILDS") != "1" || $spid == "0" && $href == "") {
$result .= ' ' . $aTag . $linktext . '</a>';
} else {
$childs = $menu->lowerLevel();
for ($i = 0; $i < count($childs); $i++) {
$result .= '<br/>';
$result .= $childs[$i]->getTag();
}
}
$result .= '</div>';
}
}
return $result;
}
示例15: delVar
/**
* Deletes a variable from the variable stack
* @param string name of the variable
*/
function delVar($name) {
$back = "";
global $auth, $db;
$userId = $auth->userId;
$sql = "DELETE FROM temp_vars WHERE USER_ID=$userId and NAME='$name'";
$query = new query($db, $sql);
$query->free();
}