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


PHP resource::prepare方法代码示例

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


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

示例1: __construct

 /**
  * Construct
  *
  * @param registry $registry
  * @param int $currency_id Current currency_id id
  */
 public function __construct($registry, $currency_id)
 {
     $this->_db = $registry->get('db');
     try {
         $statement = $this->_db->prepare('SELECT * FROM `currency`');
         $statement->execute();
     } catch (PDOException $e) {
         if ($this->db->inTransaction()) {
             $this->db->rollBack();
         }
         trigger_error($e->getMessage());
     }
     if ($statement->rowCount()) {
         foreach ($statement->fetchAll() as $currency) {
             $this->_currencies[$currency->currency_id] = array('currency_id' => $currency->currency_id, 'code' => $currency->code, 'rate' => $currency->rate, 'symbol' => $currency->symbol, 'name' => $currency->name);
             if ($currency->currency_id == $currency_id) {
                 $this->_currency_id = $currency->currency_id;
                 $this->_currency_code = $currency->code;
                 $this->_currency_rate = $currency->rate;
                 $this->_currency_name = $currency->name;
                 $this->_currency_symbol = $currency->symbol;
             }
         }
     }
 }
开发者ID:rmcdermott,项目名称:bitsybay,代码行数:31,代码来源:currency.php

示例2: getUser

 public function getUser($login)
 {
     $this->connect();
     $q = $this->bdCon->prepare("select * from " . $this->config['user_tab'] . " where " . $this->config['user_login'] . "='{$login}'");
     $q->execute();
     $res = $q->fetch();
     return $res;
 }
开发者ID:ArnaudD,项目名称:RdvZ,代码行数:8,代码来源:uapvDB.class.php

示例3: array

 /**
  * Get a list of recycle bin contents for the current user
  * @param object $userObj current user object
  * @param resource $db database connection
  * @return array of recycle bin contents
  */
 static function get_recyclebin_contents($userObj, $db)
 {
     $recycle_bin = array();
     // Query the Papers tables.
     $i = 0;
     $stmt = $db->prepare("SELECT property_id AS id, paper_type, paper_title, DATE_FORMAT(deleted,'%Y%m%d%H%i') AS deleted FROM properties WHERE paper_ownerID = ? AND deleted IS NOT NULL");
     $stmt->bind_param('i', $userObj->get_user_ID());
     $stmt->execute();
     $stmt->bind_result($id, $paper_type, $paper_title, $deleted);
     while ($stmt->fetch()) {
         $recycle_bin[$i]['id'] = $id;
         $recycle_bin[$i]['type'] = 'paper';
         $recycle_bin[$i]['name'] = $paper_title;
         $recycle_bin[$i]['deleted'] = $deleted;
         $recycle_bin[$i]['subtype'] = $paper_type;
         $i++;
     }
     $stmt->close();
     // Query the Questions tables.
     $stmt = $db->prepare("SELECT q_id AS id, q_type, leadin_plain, DATE_FORMAT(deleted,'%Y%m%d%H%i') AS deleted FROM questions WHERE ownerID = ? AND deleted IS NOT NULL");
     $stmt->bind_param('i', $userObj->get_user_ID());
     $stmt->execute();
     $stmt->bind_result($id, $q_type, $leadin_plain, $deleted);
     while ($stmt->fetch()) {
         $recycle_bin[$i]['id'] = $id;
         $recycle_bin[$i]['type'] = 'question';
         if ($q_type == 'sct') {
             $parts = explode('~', $leadin_plain);
             $recycle_bin[$i]['name'] = $parts[0];
         } else {
             $recycle_bin[$i]['name'] = $leadin_plain;
         }
         $recycle_bin[$i]['deleted'] = $deleted;
         $recycle_bin[$i]['subtype'] = $q_type;
         $i++;
     }
     $stmt->close();
     // Query the Folder tables.
     $stmt = $db->prepare("SELECT id, name, DATE_FORMAT(deleted,'%Y%m%d%H%i') AS deleted FROM folders WHERE ownerID = ? AND deleted IS NOT NULL");
     $stmt->bind_param('i', $userObj->get_user_ID());
     $stmt->execute();
     $stmt->bind_result($id, $name, $deleted);
     while ($stmt->fetch()) {
         $recycle_bin[$i]['id'] = $id;
         $recycle_bin[$i]['type'] = 'folder';
         $recycle_bin[$i]['name'] = str_replace(';', '\\', $name);
         $recycle_bin[$i]['deleted'] = $deleted;
         $recycle_bin[$i]['subtype'] = '';
         $i++;
     }
     $stmt->close();
     return $recycle_bin;
 }
开发者ID:vinod-co,项目名称:centa,代码行数:59,代码来源:recyclebin.class.php

示例4: _storeData

 /**
  * Store cell data in cache for the current cell object if it's "dirty",
  *     and the 'nullify' the current cell object
  *
  * @return	void
  * @throws	Exception
  */
 private function _storeData()
 {
     if ($this->_currentCellIsDirty) {
         $this->_currentObject->detach();
         $query = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_" . $this->_TableName . " VALUES(:id,:data)");
         $query->bindValue('id', $this->_currentObjectID, SQLITE3_TEXT);
         $query->bindValue('data', serialize($this->_currentObject), SQLITE3_BLOB);
         $result = $query->execute();
         if ($result === false) {
             throw new Exception($this->_DBHandle->lastErrorMsg());
         }
         $this->_currentCellIsDirty = false;
     }
     $this->_currentObjectID = $this->_currentObject = null;
 }
开发者ID:JaeHoYun,项目名称:generatedata,代码行数:22,代码来源:SQLite3.php

示例5: 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

示例6: addItems

 /**
  * Add items on the database
  *
  * @param Integer $feed_id ToDo desc
  * @param Array   $items   ToDo desc
  *
  * @return void
  */
 public function addItems($feed_id, $items)
 {
     if (empty($items)) {
         return;
     }
     $items = array_slice($items, 0, intval($this->getConfig('FeedTicker.itemsLimit', 5)));
     $dli = intval($this->getConfig('FeedTicker.dateLimit', 60 * 60 * 24 * 7));
     $dateLimit = time() - $dli;
     $q = $this->db->prepare('INSERT INTO ft_items (
             feed_id, updated, title, link, author, read
         ) VALUES (
             :feed_id, :updated, :title, :link, :author, :read
         )');
     foreach ($items as $i) {
         if (!empty($i['updated']) and $i['updated'] < $dateLimit) {
             continue;
         }
         // Check if this item already exists
         $sql = 'SELECT COUNT(*) FROM ft_items WHERE feed_id = ' . $this->db->quote($feed_id) . ' AND link = ' . $this->db->quote(trim($i['link']));
         $opa = $this->db->query($sql)->fetchColumn();
         if ((bool) $this->db->query($sql)->fetchColumn()) {
             continue;
         }
         $q->execute(array(':feed_id' => $feed_id, ':updated' => trim($i['updated']), ':title' => trim($i['title']), ':link' => trim($i['link']), ':author' => trim($i['author']), ':read' => 0));
     }
 }
开发者ID:phergie,项目名称:phergie,代码行数:34,代码来源:FeedManager.php

示例7: prepare

	/**
	 * Prepare statement
	 *
	 * @param 	string 		$stmt	The sql statement.
	 */
	function prepare( $stmt ) {

		$this->sql = $stmt;
		
		$this->stmt = $this->conn->prepare( $this->sql );
		
		return $this->stmt;
	}
开发者ID:noverkill,项目名称:classified-ads-script,代码行数:13,代码来源:db.php

示例8: fetchColumn

 /**
  * Fetch value by sql
  *
  * @param string $sql
  * @return mixed
  */
 public function fetchColumn($sql)
 {
     $sth = $this->_conn->prepare($sql);
     if ($sth instanceof PDOStatement) {
         $sth->execute();
         return $sth->fetchColumn();
     }
     return null;
 }
开发者ID:happyxlq,项目名称:pd,代码行数:15,代码来源:Engine.class.php

示例9: __construct

 /**
  * Creates a new OCI8Statement that uses the given connection handle and SQL statement.
  *
  * @param resource $dbh The connection handle.
  * @param string $statement The SQL statement.
  */
 public function __construct($dbh, $statement, SQLite3Connection $conn)
 {
     list($statement, $paramMap) = self::convertPositionalToNamedPlaceholders($statement);
     $this->_sth = $dbh->prepare($statement);
     $this->_dbh = $dbh;
     $this->_ret = null;
     $this->_paramMap = $paramMap;
     $this->_conn = $conn;
 }
开发者ID:joshuacoddingyou,项目名称:php,代码行数:15,代码来源:SQLite3Statement.php

示例10: deleteMessage

 /**
  * Deletes a delivered message
  *
  * @param int    $rowid   ID of the message to delete
  * @param string $channel message's channel
  * @param string $nick    message's recipient
  *
  * @return void
  */
 protected function deleteMessage($rowid, $channel, $nick)
 {
     $nick = strtolower($nick);
     $q = $this->db->prepare('DELETE FROM remind WHERE rowid = :rowid');
     $q->execute(array('rowid' => $rowid));
     if ($this->keepListInMemory) {
         if (isset($this->msgStorage[$channel][$nick]) && $this->msgStorage[$channel][$nick] == $rowid) {
             unset($this->msgStorage[$channel][$nick]);
         }
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:20,代码来源:Remind.php

示例11: __construct

 /**
  * Creates a new OCI8Statement that uses the given connection handle and SQL statement.
  *
  * @param resource $dbh The connection handle.
  * @param string $statement The SQL statement.
  */
 public function __construct($dbh, $statement, SQLite3Connection $conn)
 {
     $this->_dbh = $dbh;
     list($statement, $paramMap) = self::convertPositionalToNamedPlaceholders($statement);
     $this->_sth = $dbh->prepare($statement);
     if (!$this->_sth) {
         throw SQLite3Exception::fromErrorInfo($this->errorInfo());
     }
     $this->_ret = null;
     $this->_paramMap = $paramMap;
     $this->_conn = $conn;
 }
开发者ID:elymatos,项目名称:expressive,代码行数:18,代码来源:SQLite3Statement.php

示例12: __construct

 /**
  * Construct
  *
  * @param registry $registry
  * @param int $language_id Current language id
  */
 public function __construct(Registry $registry, $language_id)
 {
     $this->_db = $registry->get('db');
     try {
         $statement = $this->_db->prepare('SELECT * FROM `language`');
         $statement->execute();
     } catch (PDOException $e) {
         if ($this->db->inTransaction()) {
             $this->db->rollBack();
         }
         trigger_error($e->getMessage());
     }
     if ($statement->rowCount()) {
         foreach ($statement->fetchAll() as $language) {
             $this->_languages[$language->language_id] = array('language_id' => $language->language_id, 'language_code' => $language->code, 'language_locale' => $language->locale, 'language_name' => $language->name);
             if ($language->language_id == $language_id) {
                 $this->_language_id = $language->language_id;
                 $this->_language_code = $language->code;
                 $this->_language_locale = $language->locale;
                 $this->_language_name = $language->name;
             }
         }
     }
 }
开发者ID:RustyNomad,项目名称:bitsybay,代码行数:30,代码来源:language.php

示例13: _parseResults

 /**
  * @method  _parseResults()
  * @access  private
  * @throws  Exception
  * @desc    Parsea los resultados obtenidos en cualquier ejecución de consultas SQL.
  * @see     self::_throwModelException()
  */
 private function _parseResults()
 {
     $this->_resultSet = array();
     $statementWords = explode(' ', $this->_sqlQuery);
     if (preg_match('/SELECT/', strtoupper($statementWords[0]))) {
         $statement = $this->_PDOmySQLConn->prepare($this->_sqlQuery);
         $statement->execute();
         $this->_numRows = $statement->rowCount();
         if ((int) $this->_numRows > 0) {
             while ($row = $this->_resource->fetch(PDO::FETCH_ASSOC)) {
                 array_push($this->_resultSet, $row);
             }
         }
     } else {
         $this->_numRows = $this->_resource->rowCount();
     }
 }
开发者ID:alfabrad,项目名称:kidzania-coupon,代码行数:24,代码来源:Model.php

示例14: 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;
     }
     $this->connection->beginTransaction();
     $stat = $this->connection->prepare(sprintf("DELETE FROM `%s` WHERE token_hash = :hash;", PowerDnsConfig::DB_TOKEN_TABLE));
     if ($stat->execute(array(":hash" => $token->hash)) === false) {
         $this->connection->rollback();
         return false;
     } else {
         $this->connection->commit();
         return true;
     }
 }
开发者ID:vdchuyen,项目名称:TonicDNS,代码行数:24,代码来源:pdo_token_backend.php

示例15: checkQueue

 /**
  * Get unread items from the database and delivery then
  *
  * @param String $channel ToDo desc
  *
  * @return void
  */
 public function checkQueue($channel)
 {
     $items = $this->getUnreadItems($channel);
     if (empty($items)) {
         return;
     }
     foreach ($items as $i) {
         $outputFormat = "[%source%] %title% [ %link% ] by %author% at %updated%";
         $outputFormat = $this->getConfig('FeedTicker.format', $outputFormat);
         $outputTimeFormat = $this->getConfig('FeedTicker.timeFormat', "Y-m-d H:i");
         $updated = date($outputTimeFormat, $i['updated']);
         $txt = str_replace(array('%source%', '%title%', '%link%', '%author%', '%updated%'), array($i['source'], $i['title'], $i['link'], $i['author'], $updated), $outputFormat);
         $this->doPrivmsg($channel, $txt);
         // Mark item as read
         $q = $this->db->prepare('UPDATE ft_items SET read = 1 WHERE rowid = :rowid');
         $q->execute(array('rowid' => $i['rowid']));
     }
 }
开发者ID:hjr3,项目名称:phergie,代码行数:25,代码来源:FeedTicker.php


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