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


PHP database::query方法代码示例

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


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

示例1: details

 public function details()
 {
     // details combines seeing with editing
     $id = $_GET['id'];
     $columns = array('nom, prenom, nom_khmer, prenom_khmer, sex_id,  active_id');
     $neat_columns = array('Last Name', 'First Name', 'Last Name Khmer', 'First Name Khmer', 'Genre', 'Active', 'Update', 'Delete');
     $form = array('action' => '?controller=teachers&action=update&id=' . $id, 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", 'action_links' => array(1 => array('delete', '?controller=teachers&action=delete&id=')), 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('text' => 'nom'), 2 => array('text' => 'prenom'), 3 => array('text' => 'nom_khmer'), 4 => array('text' => 'prenom_khmer'), 5 => array('drop_down' => 'sex_id'), 6 => array('drop_down' => 'active_id'), 7 => array('submit' => 'update')));
     $connection = new database();
     $table = new simple_table_ops();
     $sql = 'SELECT sex_id, sex FROM sexes';
     $sex_result = $connection->query($sql);
     $sql2 = 'SELECT active_id, active FROM actives';
     $active_result = $connection->query($sql2);
     $drop_down = array('sex_id' => array('sex' => $sex_result), 'active_id' => array('active' => $active_result));
     $table->set_table_name('teachers');
     $table->set_id_column('teacher_id');
     $table->set_table_column_names($columns);
     $table->set_html_table_column_names($neat_columns);
     $table->set_values_form();
     // set values found in database into form elements when building top_form
     $table->set_drop_down($drop_down);
     $table->set_form_array($form);
     $content = '<table>';
     $content .= $table->details();
     $content .= '</table>';
     $output['content'] = $content;
     return $output;
 }
开发者ID:dagasaga,项目名称:css,代码行数:28,代码来源:teachersController.php

示例2: __save

 /**
  * Fetches hashed data from db and put into instance
  */
 private function __save()
 {
     $class = $this->class;
     $database = new database($class::$database);
     if ($this->get_attributes()) {
         $columns = "(`{$class::$entity_id_column}`, `{$class::$key_column}`, `{$class::$value_column}`, `date_added`, `date_updated`)";
         $placeholders = $values = $duplicate_keys = array();
         foreach ($this->get_attributes() as $key => $value) {
             $placeholders[] = "(%d, %s, %s, NOW(), NOW())";
             $values[] = $this->entity_id;
             $values[] = $key;
             $values[] = $value;
             $duplicate_keys[] = "`{$class::$value_column}` = VALUES(`{$class::$value_column}`)";
         }
         $duplicate_keys[] = '`date_updated` = VALUES(`date_updated`)';
         $database->query("INSERT INTO {$class::$table} {$columns} VALUES " . implode(', ', $placeholders) . " ON DUPLICATE KEY UPDATE " . implode(', ', $duplicate_keys), $values);
     }
     if ($unset_keys = array_diff($this->original_keys, array_keys($this->get_attributes()))) {
         // we unset something
         print_r(array($this->entity_id, $unset_keys));
         database::enable_log();
         $database->query("DELETE FROM {$class::$table} WHERE `{$class::$entity_id_column}` = %d AND `{$class::$key_column}` IN (%s)", array($this->entity_id, $unset_keys));
     }
     return true;
 }
开发者ID:revcozmo,项目名称:dating,代码行数:28,代码来源:entity_hash.php

示例3: create_usage_graph

function create_usage_graph($from_date, $end_date)
{
    //create an instance of class database here
    $con = new database();
    //set up query string
    $query_members = "SELECT * FROM people_online WHERE people_online.member = 'y' \r\n\t\t\t\t\t  AND people_online.log_date BETWEEN '{$from_date}' AND '{$end_date}'";
    $query_visitors = "SELECT * FROM people_online WHERE people_online.member = 'n' \r\n\t\t\t\t\t  AND people_online.log_date BETWEEN '{$from_date}' AND '{$end_date}'";
    $rs_members = $con->query($query_members) or die($con->error());
    $rs_visitors = $con->query($query_visitors) or die($con->error());
    // COMMENT : must use OOP style ( use the $con object uve created  ) not a procedural one...-mh
    $data_member = mysql_fetch_assoc($rs_members);
    // this is wrong...
    $data_visitors = mysql_fetch_assoc($rs_visitors);
    $data_member = $con->getnumrows($rs_members);
    $data_visitors = $con->getnumrows($rs_visitors);
    $data = $data_member + $data_visitors;
    if ($data == 0) {
        echo '<script>alert("Sorry, no usage results found.");window.close();</script>';
        exit;
    }
    //echo 'm='.$data_member;
    //echo 'v='.$data_visitors;
    $arr_label = array("Members", "Visitors");
    //$arr_data = array($data_member['MEMBERS'], $data_visitors['VISITORS']);
    $arr_data = array($data_member, $data_visitors);
    //start displaying the graph
    $from_date = explode('-', $from_date);
    $from_date = strdate($from_date[1], '', '') . ' ' . $from_date[2] . ',' . $from_date[0];
    $end_date = explode('-', $end_date);
    $end_date = strdate($end_date[1], '', '') . ' ' . $end_date[2] . ',' . $end_date[0];
    $graph = new graph_creator(320, 600, "People Online As of {$from_date} to {$end_date}", $arr_label, $arr_data, $center_value = 0.45);
    $graph->create_pie_graph();
}
开发者ID:sudogem,项目名称:brcms,代码行数:33,代码来源:create_graphs.php

示例4: getFondos

 public static function getFondos()
 {
     $db = new database();
     $sql = "select subtitulos,img_cursos from cursos WHERE id<=4;";
     $db->query($sql);
     return $db->cargaMatriz();
 }
开发者ID:InmaGutierrez,项目名称:webCoding,代码行数:7,代码来源:model.php

示例5: upload

function upload($file_name, $file_type, $file_path, $file_title)
{
    if (!empty($_FILES["fileUpload"]) && !empty($_POST["imgTitle"])) {
        $file_type = $_FILES['fileUpload']['type'];
        $file_title = $_POST["imgTitle"];
        if ($file_type == "image/gif") {
            $file_path = $_FILES['fileUpload']['tmp_name'];
            $file_name = $_FILES['fileUpload']['name'];
            $new_path = "upload/img/" . $file_name;
            $file_error = $_FILES["fileUpload"]["error"];
            if ($file_error == 0 && move_uploaded_file($file_path, $new_path)) {
                $sql = "INSERT INTO gif.images (`title_img`, `name_img`, `id_user`) VALUES ('{$file_title}','{$file_name}', '0');";
                $upload = new database();
                $upload->connect();
                $query = $upload->query($sql);
                if (!empty($query)) {
                    $success = "Upload file và ghi dư liệu thành công.";
                    return $success;
                } else {
                    $success = "Upload file thành công.";
                    return $success;
                }
            }
            return $file_error;
        } else {
            $error = "File không đúng định dạng GIF";
            return $error;
        }
    }
}
开发者ID:lionlone,项目名称:gif,代码行数:30,代码来源:upload.php

示例6: sprintf

    function __construct(database $db, user $user)
    {
        $this->db =& $db;
        $this->user =& $user;
        $usertype = Kit::GetParam('usertype', _SESSION, _INT, 0);
        $this->groupid = Kit::GetParam('groupid', _REQUEST, _INT, 0);
        // Do we have a user group selected?
        if ($this->groupid != 0) {
            // If so then we will need to get some information about it
            $SQL = <<<END
\t\t\tSELECT \tgroup.GroupID,
\t\t\t\t\tgroup.Group
\t\t\tFROM `group`
\t\t\tWHERE groupID = %d
END;
            $SQL = sprintf($SQL, $this->groupid);
            if (!($results = $db->query($SQL))) {
                trigger_error($db->error());
                trigger_error(__("Can not get Group information."), E_USER_ERROR);
            }
            $aRow = $db->get_assoc_row($results);
            $this->group = $aRow['Group'];
        }
        // Include the group data classes
        include_once 'lib/data/usergroup.data.class.php';
    }
开发者ID:abbeet,项目名称:server39,代码行数:26,代码来源:group.class.php

示例7: query

 function query($query)
 {
     $ex_echo = null;
     $mt = $this->getmicrotime();
     $return = parent::query($query);
     $time = $this->getmicrotime() - $mt;
     $r = @parent::only_query('EXPLAIN ' . $query);
     //$r=mysql_query('EXPLAIN '.$query, $this->mysql_link);
     $explain = $this->result_to_data($r);
     $ex_echo .= '<table border="1">';
     if (is_array($explain)) {
         foreach ($explain as $key => $value) {
             if ($key == 0) {
                 $ex_echo .= '<tr>';
                 foreach ($value as $key2 => $value2) {
                     $ex_echo .= '<td>' . $key2 . '</td>';
                 }
                 $ex_echo .= '</tr>';
             }
             $ex_echo .= '<tr>';
             foreach ($value as $key2 => $value2) {
                 $ex_echo .= '<td>' . $value2 . '</td>';
             }
             $ex_echo .= '</tr>';
         }
     }
     $ex_echo .= '</table>';
     echo '<tr><td>' . $query . '</td><td>' . $ex_echo . '</td><td>' . $time . '</td></tr>';
     return $return;
 }
开发者ID:WNA-GR,项目名称:wind-wna,代码行数:30,代码来源:mysql.php

示例8: gc

 public function gc($maxlifetime)
 {
     $db = new database();
     $db->query("DELETE FROM tbl_session\n                  WHERE session_lastaccesstime < DATE_SUB(NOW(),\n                  INTERVAL " . $maxlifetime . " SECOND)");
     $db->execute();
     return true;
 }
开发者ID:nfreader,项目名称:baseline,代码行数:7,代码来源:session.php

示例9: get

    public static function get($id = null)
    {
        $database = new database();
        $q = '
			SELECT
				' . RUDE_DATABASE_TABLE_SPECIALTIES . '.*,
				' . RUDE_DATABASE_TABLE_FACULTIES . '.' . RUDE_DATABASE_FIELD_NAME . ' AS faculty_name,
				' . RUDE_DATABASE_TABLE_FACULTIES . '.' . RUDE_DATABASE_FIELD_SHORTNAME . ' AS faculty_shortname,
				' . RUDE_DATABASE_TABLE_QUALIFICATIONS . '.' . RUDE_DATABASE_FIELD_NAME . ' AS qualification_name
			FROM
				' . RUDE_DATABASE_TABLE_SPECIALTIES . '
			LEFT JOIN
				' . RUDE_DATABASE_TABLE_FACULTIES . ' ON ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_FACULTY_ID . ' = ' . RUDE_DATABASE_TABLE_FACULTIES . '.' . RUDE_DATABASE_FIELD_ID . '
			LEFT JOIN
				' . RUDE_DATABASE_TABLE_QUALIFICATIONS . ' ON ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_QUALIFICATION_ID . ' = ' . RUDE_DATABASE_TABLE_QUALIFICATIONS . '.' . RUDE_DATABASE_FIELD_ID . '
		';
        if ($id !== null) {
            $q .= PHP_EOL . 'WHERE ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_ID . ' = ' . (int) $id;
        }
        $q .= '
			GROUP BY
				' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_ID;
        $database->query($q);
        if ($id !== null) {
            return $database->get_object();
        }
        return $database->get_object_list();
    }
开发者ID:ThisNameWasFree,项目名称:rude-univ,代码行数:28,代码来源:rude-specialties.php

示例10: getProximosCursos

 public static function getProximosCursos()
 {
     $db = new database();
     $sql = "SELECT * FROM cursos WHERE id=3";
     $db->query($sql);
     return $db->cargaMatriz();
 }
开发者ID:InmaGutierrez,项目名称:webCoding,代码行数:7,代码来源:model.php

示例11: index

 public function index()
 {
     $database = new database();
     $query = $database->query();
     date_default_timezone_set('Europe/London');
     require_once "database.php";
     $now = time();
     $hour = $now - 60 * 60;
     $day = $now - 24 * 60 * 60;
     $month = $now - 30 * 24 * 60 * 60;
     // fetch clicks -hour
     $sql = "SELECT name, COUNT(*) as clicks FROM clicks WHERE time >=" . $hour . " GROUP BY name";
     $clicksMinusHour = $query->fetch($sql);
     // fetch clicks -day
     $sql = "SELECT name, COUNT(*) as clicks FROM clicks WHERE time >=" . $day . " GROUP BY name";
     $clicksMinusDay = $query->fetch($sql);
     // fetch clicks -month
     $sql = "SELECT name, COUNT(*) as clicks FROM clicks WHERE time >=" . $month . " GROUP BY name";
     $clicksMinusMonth = $query->fetch($sql);
     if (count($clicksMinusHour) < 1) {
         $array = array('name' => 'null', 'clicks' => 'null');
         $clicksMinusHour[] = $array;
     }
     if (count($clicksMinusDay) < 1) {
         $array = array('name' => 'null', 'clicks' => 'null');
         $clicksMinusDay[] = $array;
     }
     if (count($clicksMinusMonth) < 1) {
         $array = array('name' => 'null', 'clicks' => 'null');
         $clicksMinusMonth[] = $array;
     }
     $this->setVar('clicksMinusHour', $clicksMinusHour);
     $this->setVar('clicksMinusDay', $clicksMinusDay);
     $this->setVar('clicksMinusMonth', $clicksMinusMonth);
 }
开发者ID:nicolas-thompson,项目名称:scheduler,代码行数:35,代码来源:reporting.php

示例12: sprintf

 /**
  * Layout Page Logic
  * @return 
  * @param $db Object
  */
 function __construct(database $db, user $user)
 {
     $this->db =& $db;
     $this->user =& $user;
     $this->sub_page = Kit::GetParam('sp', _GET, _WORD, 'view');
     $this->layoutid = Kit::GetParam('layoutid', _REQUEST, _INT);
     // If we have modify selected then we need to get some info
     if ($this->layoutid != '') {
         // get the permissions
         Debug::LogEntry('audit', 'Loading permissions for layoutid ' . $this->layoutid);
         $this->auth = $user->LayoutAuth($this->layoutid, true);
         if (!$this->auth->edit) {
             trigger_error(__("You do not have permissions to edit this layout"), E_USER_ERROR);
         }
         $this->sub_page = "edit";
         $sql = " SELECT layout, description, userid, retired, xml FROM layout ";
         $sql .= sprintf(" WHERE layoutID = %d ", $this->layoutid);
         if (!($results = $db->query($sql))) {
             trigger_error($db->error());
             trigger_error(__("Cannot retrieve the Information relating to this layout. The layout may be corrupt."), E_USER_ERROR);
         }
         if ($db->num_rows($results) == 0) {
             $this->has_permissions = false;
         }
         while ($aRow = $db->get_row($results)) {
             $this->layout = Kit::ValidateParam($aRow[0], _STRING);
             $this->description = Kit::ValidateParam($aRow[1], _STRING);
             $this->retired = Kit::ValidateParam($aRow[3], _INT);
             $this->xml = $aRow[4];
         }
     }
 }
开发者ID:rovak73,项目名称:xibo-cms,代码行数:37,代码来源:layout.class.php

示例13: show

 function show($id, $text = "")
 {
     if (!session::get("tooltips")) {
         // display text from database
         if ($id) {
             $helpArray = fetch_to_array(database::query("SELECT * FROM system WHERE name='{$id}'"), "");
             if ($helpArray) {
                 $entry = current($helpArray);
             }
             $right = right::get_field($id);
             $user = right::get("rights");
             $temp = $entry[text];
             // admin informations
             if (right::superuser()) {
                 $temp .= "<hr><table>";
                 $temp .= "<tr><td>fieldname</td><td>{$id}</td></tr>";
                 // fieldname
                 $temp .= "<tr><td>edit</td><td>" . right::int2string($right[edit]) . "</td></tr>";
                 // edit rights
                 $temp .= "<tr><td>view</td><td>" . right::int2string($right[view]) . "</td></tr>";
                 // view rights
                 $temp .= "</table>";
                 $clickEvent = " onmousedown = edit(&#34;{$id}&#34;)";
             }
             if ($text) {
                 $temp .= "<hr>{$text}";
             }
             return "onmouseover='return overlib(&#34;" . $temp . "&#34;);' onmouseout='return nd()' {$clickEvent}";
         }
         // display special text
     }
 }
开发者ID:nibble-arts,项目名称:openthesaurus,代码行数:32,代码来源:help.php

示例14: remove_metadata_field

 static function remove_metadata_field()
 {
     $migrated = modOpts::GetOption('metadata_migrated');
     if ($migrated) {
         return;
     }
     try {
         $obj = utopia::GetInstance('uWidgets', false);
         $obj->BypassSecurity(true);
         $ds = database::query('SELECT * FROM tabledef_Widgets WHERE `block_type` = ? AND `__metadata` IS NOT NULL', array('uCustomWidget'));
         while ($row = $ds->fetch()) {
             $pk = $row['widget_id'];
             $meta = utopia::jsonTryDecode($row['__metadata']);
             foreach ($meta as $field => $val) {
                 $obj->UpdateField($field, $val, $pk);
             }
         }
         $obj->BypassSecurity(false);
         $ds = database::query('UPDATE tabledef_Widgets SET `__metadata` = NULL WHERE `block_type` = ? AND `__metadata` IS NOT NULL', array('uCustomWidget'));
     } catch (Exception $e) {
     }
     try {
         $obj = utopia::GetInstance('uWidgets', false);
         $obj->BypassSecurity(true);
         $ds = database::query('SELECT * FROM tabledef_Widgets WHERE `block_type` = ? AND `__metadata` IS NOT NULL', array('uTextWidget'));
         while ($row = $ds->fetch()) {
             $pk = $row['widget_id'];
             $meta = utopia::jsonTryDecode($row['__metadata']);
             foreach ($meta as $field => $val) {
                 $obj->UpdateField($field, $val, $pk);
             }
         }
         $obj->BypassSecurity(false);
         $ds = database::query('UPDATE tabledef_Widgets SET `__metadata` = NULL WHERE `block_type` = ? AND `__metadata` IS NOT NULL', array('uTextWidget'));
     } catch (Exception $e) {
     }
     try {
         $obj = utopia::GetInstance('uWidgets', false);
         $obj->BypassSecurity(true);
         $ds = database::query('SELECT * FROM tabledef_Widgets WHERE `block_type` = ? AND `__metadata` IS NOT NULL', array('uTwitterWidget'));
         while ($row = $ds->fetch()) {
             $pk = $row['widget_id'];
             $meta = utopia::jsonTryDecode($row['__metadata']);
             foreach ($meta as $field => $val) {
                 $obj->UpdateField($field, $val, $pk);
             }
         }
         $obj->BypassSecurity(false);
         $ds = database::query('UPDATE tabledef_Widgets SET `__metadata` = NULL WHERE `block_type` = ? AND `__metadata` IS NOT NULL', array('uTwitterWidget'));
     } catch (Exception $e) {
     }
     $ds = database::query('SHOW TABLES');
     while ($t = $ds->fetch(PDO::FETCH_NUM)) {
         try {
             database::query('ALTER TABLE ' . $t[0] . ' DROP `__metadata`');
         } catch (Exception $e) {
         }
     }
     modOpts::SetOption('metadata_migrated', true);
 }
开发者ID:OptimalInternet,项目名称:uCore,代码行数:60,代码来源:metadata.php

示例15: nuevoMensaje

 public static function nuevoMensaje()
 {
     $db = new database();
     $sql = 'INSERT INTO contacto VALUES (NULL, :nombre, :apellidos, :email, :asunto, :mensaje)';
     $params = array(':nombre' => $_POST['nombre'], ':apellidos' => $_POST['apellidos'], ':email' => $_POST['email'], ':asunto' => $_POST['asunto'], ':mensaje' => $_POST['mensaje']);
     $db->query($sql, $params);
     return $db->affectedRows();
 }
开发者ID:InmaGutierrez,项目名称:webCoding,代码行数:8,代码来源:model.php


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