當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。