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


PHP Query::exec方法代码示例

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


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

示例1: save

 /**
  * Save model data.
  * If model is new PK is null - we generate INSERT SQL request.
  * If model data already exists in DB, PK > 0 - we generate UPDATE request.
  * Method return true if model data saved successfully. False if error.
  */
 public function save($validate = true)
 {
     if ($validate === true && $this->validate() === false) {
         return false;
     }
     $columns = $this->getClearColumns();
     $values = array();
     foreach ($columns as $column) {
         $values[] = $this->{$column};
     }
     $keyPosition = array_search($this->pkColumnName(), $columns);
     array_splice($columns, $keyPosition, 1);
     array_splice($values, $keyPosition, 1);
     if ((int) $this->{$this->pkColumnName()} > 0) {
         $query = new Query("update");
         $query->addTable($this->tableName());
         foreach ($columns as $key => $column) {
             $query->addField($column, $values[$key]);
         }
         $query->where->add($this->pkColumnName() . " = " . $this->{$this->pkColumnName()});
         $result = $query->exec();
     } else {
         $query = new Query("insert");
         $query->addTable($this->tableName());
         foreach ($columns as $key => $column) {
             $query->addField($column, $values[$key]);
         }
         $result = $query->exec();
         $this->ADDRESSID = $query->last_insert_id();
     }
     return $result;
 }
开发者ID:zahar-g,项目名称:small_mvc_frmwrk,代码行数:38,代码来源:Model.php

示例2: execQuery

function execQuery($sql, $params = array(), &$processedCount = 0)
{
    global $db;
    if (empty($params)) {
        $q = new Query($db);
        $q->exec($sql);
        return $q->processedCount();
    }
    $q = createQuery($sql, $params);
    $q->execute();
    $processedCount = $q->processedCount();
    return $db->lastInsertId();
}
开发者ID:sd-studio,项目名称:sh,代码行数:13,代码来源:db.php

示例3: get_active_theme

function get_active_theme()
{
    $theme_name = "";
    // Get a name of the active theme.
    $sql = "SELECT t.theme_name FROM theme t JOIN settings s WHERE t.themeid = s.themeid";
    $q = new Query();
    $q->connect();
    $rows = $q->exec($sql);
    if (count($rows) > 0) {
        $theme_name = $rows[0]["theme_name"];
    }
    $q->close();
    // Check theme directory existence.
    $theme = "../themes/" . $theme_name;
    if (file_exists($theme . "/style.css")) {
        return $theme_name;
    } else {
        return "";
    }
}
开发者ID:Giordano-Bruno,项目名称:GiordanoBruno,代码行数:20,代码来源:theme.php

示例4: getList

 public static function getList($parameters = array())
 {
     $query = new Query(static::getEntity());
     if (isset($parameters['select'])) {
         $query->setSelect($parameters['select']);
     } else {
         $query->setSelect(array('*'));
     }
     if (isset($parameters['filter'])) {
         $query->setFilter($parameters['filter']);
     }
     if (isset($parameters['group'])) {
         $query->setGroup($parameters['group']);
     }
     if (isset($parameters['order'])) {
         $query->setOrder($parameters['order']);
     }
     if (isset($parameters['limit'])) {
         $query->setLimit($parameters['limit']);
     }
     if (isset($parameters['offset'])) {
         $query->setOffset($parameters['offset']);
     }
     if (isset($parameters['count_total'])) {
         $query->countTotal($parameters['count_total']);
     }
     if (isset($parameters['options'])) {
         $query->setOptions($parameters['options']);
     }
     if (isset($parameters['runtime'])) {
         foreach ($parameters['runtime'] as $name => $fieldInfo) {
             $query->registerRuntimeField($name, $fieldInfo);
         }
     }
     if (isset($parameters['data_doubling'])) {
         $parameters['data_doubling'] ? $query->enableDataDoubling() : $query->disableDataDoubling();
     }
     return $query->exec();
     // return array?
 }
开发者ID:nProfessor,项目名称:Mytb,代码行数:40,代码来源:datamanager.php

示例5: get_users

/**
 * Obtiene los usuarios y los <li> del
 * submenu de la derecha.
 *
 * @return array
 */
function get_users()
{
    global $db;
    global $id_users;
    $q = new Query($db);
    $q->exec('SELECT users.id_users
                   , users.username
                   , users.name
                   , users.description
              FROM users');
    $data = array();
    $submenu = '';
    for ($i = 0; $i < $q->numrows; $i++) {
        $data[$q->data['id_users']] = $q->data;
        $selected = $id_users == $q->data['id_users'] ? ' class="selected"' : '';
        $submenu .= '
<li><a href="?id_users=' . $q->data['id_users'] . '"' . $selected . '>' . $q->data['name'] . '</a></li>';
        $q->nxt();
    }
    $q->free();
    return array($data, $submenu);
}
开发者ID:joksnet,项目名称:php-old,代码行数:28,代码来源:functions.php

示例6: DmQuery

require_once "../functions/inputFuncs.php";
require_once '../classes/DmQuery.php';
$dmQ = new DmQuery();
$dmQ->connect();
$mbrClassifyDm = $dmQ->getAssoc('mbr_classify_dm');
$mbrStatusDm = array("y" => $loc->getText("mbrActive"), "n" => $loc->getText("mbrInactive"));
$customFields = $dmQ->getAssoc('member_fields_dm');
$dmQ->close();
// Get & show the latest BarcodeNumber.
require_once "../shared/common.php";
require_once "../classes/Query.php";
$barcode = "0";
$sql = "SELECT MAX(barcode_nmbr) AS bn FROM member";
$q = new Query();
$q->connect();
$rows = $q->exec($sql);
if (count($rows) > 0) {
    $barcode = $rows[0]["bn"];
}
$q->close();
$barcode_help = $loc->getText("mbrLatestBarcode") . ": " . $barcode . " <br />";
$barcode_help .= '<input type="checkbox" id="chk_auto_barcode" name="chk_auto_barcode" value="1" /> ' . $loc->getText("mbrAutoBarcode");
$fields = array("mbrFldsClassify" => inputField('select', "classification", $mbr->getClassification(), NULL, $mbrClassifyDm), "mbrFldsStatus" => inputField('select', "status", $mbr->getStatus(), NULL, $mbrStatusDm), "mbrFldsCardNmbr" => inputField('text', "barcodeNmbr", $mbr->getBarcodeNmbr(), NULL, NULL, $barcode_help), "mbrFldsLastName" => inputField('text', "lastName", $mbr->getLastName()), "mbrFldsFirstName" => inputField('text', "firstName", $mbr->getFirstName()), "mbrFldsHomePhone" => inputField('text', "homePhone", $mbr->getHomePhone()), "mbrFldsWorkPhone" => inputField('text', "workPhone", $mbr->getWorkPhone()), "mbrFldsCel" => inputField('text', "cel", $mbr->getCel()), "mbrFldsEmail" => inputField('text', "email", $mbr->getEmail()), "mbrFldsFoto" => inputField('text', "foto", $mbr->getFoto()), "MailingAddress:" => inputField('textarea', "address", $mbr->getAddress()), "mbrFldsPassUser" => inputField('text', "passUser", $mbr->getPassUser()), "mbrFldsBornDt" => inputField('text', "bornDt", $mbr->getBornDt()), "mbrFldsOther" => inputField('textarea', "other", $mbr->getOther()));
foreach ($customFields as $name => $title) {
    $fields[$title . ':'] = inputField('text', 'custom_' . $name, $mbr->getCustom($name));
}
?>

<table class="primary">
  <tr>
    <th colspan="2" valign="top" nowrap="yes" align="left">
开发者ID:Giordano-Bruno,项目名称:GiordanoBruno,代码行数:31,代码来源:mbr_fields.php

示例7: getCustomFields

 function getCustomFields($mbrid)
 {
     # KLUDGE to make sure we don't clobber the results handle
     # when we're called from fetchmember().
     # FIXME - redo query stuff to avoid this issue
     $q = new Query();
     $q->connect();
     $sql = $q->mkSQL('select * from member_fields where mbrid=%N', $mbrid);
     $rows = $q->exec($sql);
     $fields = array();
     foreach ($rows as $r) {
         $fields[$r['code']] = $r['data'];
     }
     return $fields;
 }
开发者ID:Giordano-Bruno,项目名称:GiordanoBruno,代码行数:15,代码来源:MemberQuery.php

示例8: fieldExists

 /**
  * Verifica a existência de um campo
  *
  * @param string $tableName Nome da tabela a ser verificada
  * @param string $fieldName Nome do campo a ser verificado
  *
  * @return boolean Existe o campo?
  */
 private function fieldExists($tableName, $fieldName)
 {
     // Os nomes passados estão no padrão?
     if (!$this->validateName($tableName) || !$this->validateName($fieldName)) {
         return false;
     }
     // Pesquisa o campo na tabela
     $consulta = Query::exec("SHOW COLUMNS FROM {$tableName} WHERE Field = '{$fieldName}'");
     // O campo foi encontrado?
     return isset($consulta[0]['Field']);
 }
开发者ID:szagot,项目名称:conn,代码行数:19,代码来源:CreateTable.php

示例9: delete

 /**
  * Deletes the note entry from the database
  */
 public function delete($key)
 {
     if (!isset($this->pkey)) {
         $this->fetch_data();
     }
     if ($this->valid_key($key)) {
         $query = "DELETE FROM notes WHERE UID = ?";
         $handle = new Query($this->pdo, $query);
         $params = $this->members_to_array("UID");
         //I'm lazy
         $handle->exec($params);
         return $handle->success;
     }
     return self::E_INVALID_PKEY;
 }
开发者ID:hrn4n,项目名称:argon,代码行数:18,代码来源:note.class.php

示例10: update

 function update()
 {
     $inscols = 'UPDATE `' . $this->table . '` SET ';
     foreach ($this->col as $c => $cc) {
         if (isset($this->_col[$c])) {
             if ($cc == 'NOW()') {
                 $inscols .= '`' . $c . '` = ' . $cc . ',';
             } else {
                 $inscols .= '`' . $c . '` = \'' . $cc . '\',';
             }
         }
     }
     $inscols = substr($inscols, 0, strlen($inscols) - 1);
     $q = new Query($this->db);
     $q->exec($inscols . ' WHERE ' . $this->field . ' = \'' . $this->vars . '\'');
 }
开发者ID:joksnet,项目名称:php-old,代码行数:16,代码来源:db.php

示例11: Query

            <li><a href="?action=upload">Upload File</a></li>
        </ul>
        <h2>Manage</h2>
        <ul>
            <li><a href="?action=manageuploads">Uploads</a></li>
            <li><a href="?action=manageposts">Posts</a></li>
            <li><a href="?action=manageoptions">Options</a></li>
        </ul>';
            break;
    }
} else {
    if (isset($_POST['username'])) {
        $success = false;
        $q = new Query($db);
        $q->exec('SELECT users.*
                  FROM users
                  WHERE users.username = \'' . $_POST['username'] . '\'
                  AND users.password = \'' . md5($_POST['password']) . '\'');
        if ($q->numrows > 0) {
            $success = true;
            $_SESSION['login'] = $q->data;
            $_SESSION['login']['password'] = '';
            // Security
        }
        $q->free();
        if ($success) {
            redirect('?rand=' . rand());
        }
    }
    $page_title = 'Login';
    $content = isset($success) && !$success ? 'Not Success. Sorry.' : '';
    $content .= '
开发者ID:joksnet,项目名称:php-old,代码行数:32,代码来源:index.php

示例12: Query

<?php

/*
 * Testing a few simple queries to see if the Query wrapper class works properly
 */
include "../src/core.php";
$query = new Query($pdo_link, "SELECT 2+2");
print_r($query->exec() == true);
$query->query = "CREATE TEMPORARY TABLE potatos (ID int PRIMARY KEY AUTO_INCREMENT, name varchar(20))";
print_r($query->exec() == true);
$testing = ['Juana', 'Maria', 'Pablo'];
$query->query = "INSERT INTO potatos (name) VALUES (?)";
foreach ($testing as $name) {
    print_r($query->exec([$name]) == true);
}
$query->query = "SELECT * FROM potatos";
print_r($query->exec() == true);
while ($row = $query->fetch()) {
    print_r(is_array($row) == true);
}
/*Output should look like this: 111111111*/
开发者ID:hrn4n,项目名称:argon,代码行数:21,代码来源:sql.php

示例13: parseSql

/**
 * bool parseSql(string $text)
 *
 * Parses a SQL text
 *
 * @param string $text sentences to parse
 * @return bool false if an error occurs
 * @access public
 * @since 0.8
 */
function parseSql($text)
{
    $controlledErrors = array(1060, 1091);
    $installQ = new Query();
    $installQ->captureError(true);
    /**
     * reading through SQL text executing SQL only when ";" is encountered and if is out of brackets
     */
    $count = strlen($text);
    $sqlSentence = "";
    $outBracket = true;
    for ($i = 0; $i < $count; $i++) {
        $char = $text[$i];
        if ($char == "(") {
            $outBracket = false;
        }
        if ($char == ")") {
            $outBracket = true;
        }
        if ($char == ";" && $outBracket) {
            $result = $installQ->exec($sqlSentence);
            if ($installQ->isError() && !in_array($installQ->getDbErrno(), $controlledErrors)) {
                echo HTML::para(sprintf(_("Process sql [%s]"), $sqlSentence));
                $installQ->close();
                Error::query($installQ, false);
                echo Msg::error(sprintf(_("Error: %s"), $installQ->getDbError()));
                return false;
            }
            $sqlSentence = "";
        } else {
            $sqlSentence .= $char;
        }
    }
    $installQ->close();
    return true;
}
开发者ID:edubort,项目名称:openclinic-1,代码行数:46,代码来源:parse_sql_file.php


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