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


PHP resource::exec方法代码示例

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


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

示例1: execute

 /**
  * 插入更新数据
  * @param string $sql 需要执行的sql语句
  * @return int
  */
 public function execute($sql)
 {
     $count = $this->pdo->exec($sql);
     if ($count && false !== strpos($sql, 'insert')) {
         return $this->pdo->lastInsertId();
     }
     return $count;
 }
开发者ID:xs5816,项目名称:micsmart,代码行数:13,代码来源:DB.php

示例2: exec

 /**
  * {@inheritDoc}
  *
  * @param string $sql  SQL statement to execute
  * @param array $params bind_name => value values to interpolate into
  *      the $sql to be executes
  * @return mixed false if query fails, resource or true otherwise
  */
 function exec($sql, $params = array())
 {
     static $last_sql = NULL;
     static $statement = NULL;
     $is_select = strtoupper(substr(ltrim($sql), 0, 6)) == "SELECT";
     if ($last_sql != $sql) {
         $statement = NULL;
         //garbage collect so don't sqlite lock
     }
     if ($params) {
         if (!$statement) {
             $statement = $this->pdo->prepare($sql);
         }
         $result = $statement->execute($params);
         $this->num_affected = $statement->rowCount();
         if ($result) {
             if ($is_select) {
                 $result = $statement;
             } else {
                 $result = $this->num_affected;
             }
         }
     } else {
         if ($is_select) {
             $result = $this->pdo->query($sql);
             $this->num_affected = 0;
         } else {
             $this->num_affected = $this->pdo->exec($sql);
             $result = $this->num_affected + 1;
         }
     }
     $last_sql = $sql;
     return $result;
 }
开发者ID:yakar,项目名称:yioop,代码行数:42,代码来源:pdo_manager.php

示例3: createTables

 /**
  * Creates the database table(s) (if they don't exist)
  *
  * @return void
  */
 public function createTables()
 {
     if (!$this->haveTable('ft_items')) {
         $this->db->exec('CREATE TABLE ft_items (
                     feed_id INTEGER,
                     updated INTEGER,
                     title TEXT,
                     link TEXT,
                     author TEXT,
                     read BOOLEAN
                 )');
     }
     if (!$this->haveTable('ft_feeds')) {
         $this->db->exec('CREATE TABLE ft_feeds (
                     updated INTEGER,
                     etag TEXT,
                     delay INTEGER,
                     channel TEXT,
                     title TEXT,
                     description TEXT,
                     link TEXT,
                     feed_url TEXT,
                     active BOOLEAN
                 )');
     }
 }
开发者ID:hjr3,项目名称:phergie,代码行数:31,代码来源:FeedTicker.php

示例4: __destruct

 /**
  * Destroy this cell collection
  */
 public function __destruct()
 {
     if (!is_null($this->_DBHandle)) {
         $this->_DBHandle->exec('DROP TABLE kvp_' . $this->_TableName);
         $this->_DBHandle->close();
     }
     $this->_DBHandle = null;
 }
开发者ID:Troutzorz,项目名称:csapp,代码行数:11,代码来源:SQLite3.php

示例5: execute

 /**
  * Executes a result-less query against a given database.
  * 
  * @param string $sql The SQL query to execute.
  * 
  * @return mixed Returns the number of rows that were modified or deleted, 
  * or false on failure.
  * 
  * @throws SQLiteException on failure.
  */
 public function execute($sql)
 {
     try {
         return $this->link->exec($sql);
     } catch (PDOException $e) {
         throw new SQLiteException($e->getMessage());
     }
     return false;
 }
开发者ID:elevenone,项目名称:SQLiteDatabase,代码行数:19,代码来源:SQLiteDriver.php

示例6: connect

 /**
  * Init db connection
  *
  * @param string $host
  * @param string $user
  * @param string $psw
  * @param string $dbname
  * @return bool
  */
 public function connect($host, $user, $psw, $dbname)
 {
     if (isset($this->_conn) && $this->_conn instanceof PDO) {
         return true;
     }
     $dsn = "mysql:host={$host};dbname={$dbname}";
     $this->_conn = new PDO($dsn, $user, $psw);
     $this->_conn->exec("set names 'utf8'");
     return true;
 }
开发者ID:happyxlq,项目名称:pd,代码行数:19,代码来源:Engine.class.php

示例7: destroyToken

 /**
  * Destroys the given Token object, by invalidating and removing it from the backend.
  * @access public
  * @param mixed $token Token object.
  * @return boolean True if succesful, false if the Token could not be destroyed.
  */
 public function destroyToken($token)
 {
     if (!$token instanceof Token) {
         return false;
     }
     if (empty($token->username) || empty($token->valid_until) || empty($token->hash)) {
         return false;
     }
     if (!$this->connection->exec(sprintf("DELETE FROM tokens WHERE token_hash = '%s';", sqlite_escape_string($token->hash)))) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:vdchuyen,项目名称:TonicDNS,代码行数:20,代码来源:sqlite_token_backend.php

示例8: createTables

 /**
  * Creates the database table(s) (if they don't exist)
  *
  * @return void
  */
 protected function createTables()
 {
     if (!$this->haveTable('remind')) {
         $this->db->exec('CREATE TABLE
                 remind
                 (
                     time INTEGER,
                     channel TEXT,
                     recipient TEXT,
                     sender TEXT,
                     message TEXT
                 )');
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:19,代码来源:Remind.php

示例9: execute

 /**
  * Executes a prepared statement
  *
  * If the prepared statement included parameter markers, you must either:
  * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
  * bound variables pass their value as input and receive the output value,
  * if any, of their associated parameter markers or pass an array of input-only
  * parameter values
  *
  *
  * @param array $params             An array of values with as many elements as there are
  *                                  bound parameters in the SQL statement being executed.
  * @return boolean                  Returns TRUE on success or FALSE on failure.
  */
 public function execute($params = null)
 {
     if (is_array($params)) {
         foreach ($params as $var => $value) {
             $this->bindValue($var + 1, $value);
         }
     }
     $this->result = $this->connection->exec($this->queryString);
     if ($this->result === false) {
         $this->handleError();
         return false;
     }
     return true;
 }
开发者ID:dator,项目名称:doctrine1-drak,代码行数:28,代码来源:Jdbcbridge.php

示例10: execute

 /**
  * 执行写入语句
  *
  * @access public
  * @param $sql
  * @return int|false
  */
 public function execute($sql)
 {
     $this->connect();
     if (!$this->_linkId) {
         return false;
     }
     try {
         $this->_numRows = $this->_linkId->exec($sql);
     } catch (PDOException $e) {
         trigger_error('MySQL PDO execute error: ' . $e->getMessage() . ' [' . $sql . ']');
     }
     $lastInsID = $this->_linkId->lastInsertId();
     return $lastInsID ? $lastInsID : $this->_numRows;
 }
开发者ID:kungyu,项目名称:camelphp,代码行数:21,代码来源:Pdo.php

示例11: __construct

 /**
  * Initialise this new cell collection
  *
  * @param	PHPExcel_Worksheet	$parent		The worksheet for this cell collection
  */
 public function __construct(PHPExcel_Worksheet $parent)
 {
     parent::__construct($parent);
     if (is_null($this->_DBHandle)) {
         $this->_TableName = str_replace('.', '_', $this->_getUniqueID());
         $_DBName = ':memory:';
         $this->_DBHandle = new SQLite3($_DBName);
         if ($this->_DBHandle === false) {
             throw new Exception($this->_DBHandle->lastErrorMsg());
         }
         if (!$this->_DBHandle->exec('CREATE TABLE kvp_' . $this->_TableName . ' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
             throw new Exception($this->_DBHandle->lastErrorMsg());
         }
     }
 }
开发者ID:JaeHoYun,项目名称:generatedata,代码行数:20,代码来源:SQLite3.php

示例12: moveCell

 /**
  * Move a cell object from one address to another
  *
  * @param	string		$fromAddress	Current address of the cell to move
  * @param	string		$toAddress		Destination address of the cell to move
  * @return	boolean
  */
 public function moveCell($fromAddress, $toAddress)
 {
     if ($fromAddress === $this->_currentObjectID) {
         $this->_currentObjectID = $toAddress;
     }
     $query = "DELETE FROM kvp_" . $this->_TableName . " WHERE id = '" . $toAddress . "'";
     $result = $this->_DBHandle->exec($query);
     if ($result === false) {
         throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
     }
     $query = "UPDATE kvp_" . $this->_TableName . " SET id = '" . $toAddress . "' WHERE id = '" . $fromAddress . "'";
     $result = $this->_DBHandle->exec($query);
     if ($result === false) {
         throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
     }
     return true;
 }
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:24,代码来源:SQLite.php

示例13: onCommandFeedclear

 /**
  * Cleans items from the database
  *
  * @param String $feed_id optional
  *
  * @return void
  */
 public function onCommandFeedclear($feed_id = 'all')
 {
     $nick = $this->event->getNick();
     if ($feed_id == 'all') {
         $this->db->exec('DELETE FROM TABLE ft_items');
         $this->db->prepare('DELETE FROM ft_items')->execute();
         $this->doNotice($nick, "Done!");
     } else {
         if ($this->feedExists($feed_id)) {
             $q = $this->db->prepare('DELETE FROM ft_items WHERE feed_id = :feed_id');
             $q->execute(array('feed_id' => $feed_id));
             $this->doNotice($nick, "Done!");
         } else {
             $this->doNotice($nick, "This feed doesn't exist!");
         }
     }
 }
开发者ID:phergie,项目名称:phergie,代码行数:24,代码来源:FeedManager.php

示例14: exec

 /**
  * @param $command
  *
  * @return string
  */
 public function exec($command)
 {
     $sftpDir = $this->pwd();
     switch ($this->_connType) {
         case SftpHelper::TYPE_SFTP:
         default:
             $execOutput = $this->_connection->exec('cd ' . $sftpDir . ' && ' . $command);
             $this->_lastExecExitStatus = $this->_connection->getExitStatus();
             break;
         case SftpHelper::TYPE_FTP:
             // TODO: test ftp_exec on a server which supports it
             $execOutput = '';
             $res = @ftp_exec($this->_connection, 'cd ' . $sftpDir . ' && ' . $command);
             $this->_lastExecExitStatus = $res ? 0 : 1;
             break;
     }
     return $execOutput;
 }
开发者ID:giovdk21,项目名称:deployii,代码行数:23,代码来源:SftpHelper.php

示例15: execute

 /**
  * @param array $command
  */
 protected function execute($command)
 {
     $this->shell->enableQuietMode();
     $stdOutput = $this->shell->exec($command);
     $stdError = $this->shell->getStdError();
     $exitStatus = $this->shell->getExitStatus();
     $stdout = explode("\n", $stdOutput);
     $stderr = array_filter(explode("\n", $stdError));
     if ($exitStatus != 0) {
         //print_r($stderr);
         throw new RunGitCommandException(sprintf("Error in command shell:%s \n Error Response:%s%s", $command, implode("\n", $stderr), $stdOutput));
     }
     $this->stdout = array_merge($this->stdout, $stdout);
     if (is_array($stderr)) {
         $this->stderr = array_merge($this->stderr, $stderr);
         if ($exitStatus === 0) {
             $this->stdout = array_merge($this->stdout, $stderr);
         }
     }
 }
开发者ID:sshversioncontrol,项目名称:git-web-client,代码行数:23,代码来源:SecLibSshProcess.php


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