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


PHP PDO::execute方法代码示例

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


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

示例1: execute

 /**
  * 执行SQL语句
  * @access public
  * @param string $sql  SQL指令
  * @param mixed $parse  是否需要解析SQL
  * @return false | integer
  */
 public function execute($sql, $parse = false)
 {
     if (!is_bool($parse) && !is_array($parse)) {
         $parse = func_get_args();
         array_shift($parse);
     }
     $sql = $this->parseSql($sql, $parse);
     return $this->db->execute($sql);
 }
开发者ID:yuhaizr,项目名称:Y2Game,代码行数:16,代码来源:Model.class.php

示例2: execute

 public function execute($values = array())
 {
     global $debug;
     $debug->printArray($values, '$values');
     try {
         $t = parent::execute($values);
         // maybe do some logging here?
     } catch (PDOException $e) {
         // maybe do some logging here?
         die('funkytown2');
         //throw $e . $debug;
     }
     return $t;
 }
开发者ID:mark-orussa,项目名称:Adrlist,代码行数:14,代码来源:Dbc.php

示例3: PDO

<?php

$dir = 'sqlite:./record.sqlite';
$dbh = new PDO($dir) or die("cannot open the database");
$sql = "CREATE TABLE record(id INTEGER, type, name, value, ctime, mtime PRIMARY KEY(id DESC));";
$dbh->execute($sql);
$dhb->execute("insert record values(1, 1, 'chen', 26, '2016-5-23 21:39:17', '2016-5-23 21:39:28')");
开发者ID:pandaoknight,项目名称:samplecode,代码行数:7,代码来源:prepare_data.php

示例4: json_encode

<?php

$oDb = new PDO("sqlite:" . __DIR__ . "/cds.sqlite");
//$sQuery =  "';DROP DATABASE testme;#'";
$sQuery = "pop";
if (isset($_GET['Genre'])) {
    $sQuery = $_GET['Genre'];
}
$oDb->prepare("SELECT * FROM `cds` WHERE genre = :genre");
$oDb->bindParam("genre", $sQuery);
$oDb->execute();
$aResults = $oDb->fetchAll(PDO::FETCH_OBJ);
echo json_encode($aResults);
开发者ID:rhildred,项目名称:PROG8020MidtermPrep,代码行数:13,代码来源:sqlsth.php

示例5: time

            } else {
                $filename = time() . '_' . $_FILES['profilePicture']['name'];
                while (file_exists(SERVER_PATH . 'img\\' . $filename)) {
                    $filename = time() . '_' . $_FILES['profilePicture']['name'];
                }
                move_uploaded_file($_FILES['profilePicture']['tmp_name'], SERVER_PATH . 'img\\' . $filename);
            }
        }
    } else {
        new Message("Ongeldig bestand");
        header("location: gegevens-wijzigen-form.php");
    }
    if ($filename) {
        $queriegeg = 'UPDATE users SET profile_picture = :profile_picture WHERE id = :id';
        $placeholders = array(':profile_picture' => $filename, ':id' => $user->getId());
        $databaseWrapper->query($queriegeg, $placeholders);
        new Message("De gegevens zijn gewijzigd!", "success");
        header("location: gegevens-wijzigen-form.php");
    }
    if (isset($_POST['email'])) {
        $email = $_POST['email'];
        $querie = 'UPDATE users SET email = :email WHERE id = :id';
        $db->prepare($querie);
        $db->binvalue(':id', $user->getId());
        $db->binvalue(':email', $email);
        $db->execute();
    } else {
        $error = new Message("Vul een e-mailadres of een paswoord in", "error");
        relocate('registratie-form.php');
    }
}
开发者ID:arnevanbavel,项目名称:web-backend-2015-2016,代码行数:31,代码来源:file-upload-gegevens-process.php

示例6: save

 public function save()
 {
     # Table Name && Created/Updated Fields
     $table_name = $this->table_name();
     $data = $this->record;
     $time = date('Y-m-d H:i:s');
     if (is_array($this->record)) {
         //existing
         $data = $this->record[0];
         $data->updated_at = $time;
         if (isset($data->id)) {
             $this->id = $data->id;
         } else {
             // return false;
         }
     } else {
         //new record
         $data = $this->record;
         $data->created_at = $time;
         $data->updated_at = '0000-00-00 00:00:00';
     }
     $properties = $this->loadPropertiesFromDatabase();
     # Create SQL Query
     $sql_set_string = '';
     $total_properties_count = count($properties);
     $x = 0;
     // first create values
     foreach ($properties as $k => $v) {
         $val = $v->Field;
         $type = $v->Type;
         if ($data->{$val} == NULL) {
             $values[] = '';
         } else {
             $values[] = str_replace("`", "``", $data->{$val});
         }
         $x++;
     }
     // set the sql statement
     if (count($values) != $total_properties_count) {
         $total_properties_count = count($values);
     }
     $x = 0;
     foreach ($properties as $k => $v) {
         $val = $v->Field;
         $type = $v->Type;
         $sql_set_string .= '`' . $val . '` = ?';
         if ($x < $total_properties_count - 1) {
             $sql_set_string .= ', ';
         } else {
             $sql_set_string .= '';
         }
         $x++;
     }
     # Final SQL Statement
     $sql2 = '`' . $table_name . "` SET " . $sql_set_string;
     if ($this->exists()) {
         $final_sql = 'UPDATE ' . $sql2 . ' WHERE `id` = ?;';
         $values[] = $data->id;
     } else {
         $final_sql = "INSERT INTO " . $sql2 . ';';
     }
     if (static::validate() === false) {
         return false;
     }
     $q = false;
     if ($this->validate()) {
         $q = $this->db->execute($final_sql, $values);
         $this->lastId = $this->db->lastId;
     }
     if ($q) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:betasyntax,项目名称:framework,代码行数:75,代码来源:BaseModel.php


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