本文整理匯總了PHP中Connection::execute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::execute方法的具體用法?PHP Connection::execute怎麽用?PHP Connection::execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Connection
的用法示例。
在下文中一共展示了Connection::execute方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testExecute
/**
* @param Connection $db
* @depends testConnect
*/
public function testExecute(Connection $db)
{
$table = uniqid('table_');
$db->execute("CREATE TABLE {$table} (id int, display varchar(100));");
for ($i = 1; $i < 5; $i++) {
$value = md5($i);
$db->execute("INSERT INTO {$table} VALUES (:id, :value);", array($i, $value));
}
return array($table, $db);
}
示例2: execute
public function execute($params = null)
{
if (is_null($params)) {
$params = $this->params;
}
$sql = $this->connection->execute($this->sql, $params);
$data = new Data($this->fetchAllAssoc($sql));
$meta = $this->parseMeta($this->connection->execute('SHOW META'));
return new Result($data, $meta, $sql);
}
示例3: remcat
function remcat()
{
global $_REQUEST, $login, $pass, $server, $db, $nb;
$cat = trim(strip_tags($_REQUEST['cat']));
$cat = strtr($cat, ' ', '');
if (strlen($cat) == 0) {
echo '<p class="error"><strong>Error:</strong> You must provide a category name.</p>';
} else {
$con = new Connection($login, $pass, $server, $db);
$con->execute("DELETE FROM sptbl_spam_categories WHERE category_id='" . $con->escapeStr($cat) . "'");
$con->execute("DELETE FROM sptbl_spam_references WHERE category_id='" . $con->escapeStr($cat) . "'");
$con->execute("DELETE FROM sptbl_spam_wordfreqs WHERE category_id='" . $con->escapeStr($cat) . "'");
$nb->updateProbabilities();
echo "<p class='success'>The category has been just removed.</p>";
}
}
示例4: remcat
function remcat()
{
global $_REQUEST, $login, $pass, $server, $db, $nb;
$cat = trim(strip_tags($_REQUEST['cat']));
$cat = strtr($cat, ' ', '');
if (strlen($cat) == 0) {
echo '<p class="erreur"><strong>Erreur:</strong> Vous devez donner un nom de catégorie.</p>';
} else {
$con = new Connection($login, $pass, $server, $db);
$con->execute("DELETE FROM nb_categories WHERE category_id='" . $con->escapeStr($cat) . "'");
$con->execute("DELETE FROM nb_references WHERE category_id='" . $con->escapeStr($cat) . "'");
$con->execute("DELETE FROM nb_wordfreqs WHERE category_id='" . $con->escapeStr($cat) . "'");
$nb->updateProbabilities();
echo "<p class='succes'>La catégorie vient d'être supprimée.</p>";
}
}
示例5: execute
/**
* Execute the query and return the number of rows affected
*
* @return int
*/
public function execute()
{
return $this->connection->execute($this->getQuery());
}
示例6: Connection
DISCLAIMED. IN NO EVENT SHALL ADRIAN KOSMACZEWSKI BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// The binary plist and the SOAP formatters require huge amounts of memory!
ini_set('memory_limit', '128M');
require_once 'data/database.php';
require_once 'formatters/formatterfactory.php';
// Get all the data from the database
$limit = $_GET["limit"];
if (!$limit) {
$limit = "50";
}
// Before calling mysql_real_escape_string() you have to connect to the DB...!
$conn = new Connection();
$conn->open();
$query = "SELECT * FROM data ORDER BY RAND() LIMIT " . mysql_real_escape_string($limit);
$data = $conn->execute($query);
$conn->close();
// Depending the "format" parameter in the query string,
// output the data in different formats
$format = mysql_real_escape_string($_GET["format"]);
$formatter = FormatterFactory::createFormatter($format);
$formatter->setData($data);
header('Content-type: ' . $formatter->getContentType());
$output = $formatter->formatData();
echo $output;
示例7: prepareEmptyDatabaseTable
private function prepareEmptyDatabaseTable()
{
$this->connection->execute('CREATE TABLE IF NOT EXISTS test_table (id INTEGER PRIMARY KEY);)');
}
示例8: _createTables
/**
* Creates tables for testing listTables/describe()
*
* @param Connection $connection
* @return void
*/
protected function _createTables($connection)
{
$this->_needsConnection();
$schema = new SchemaCollection($connection);
$result = $schema->listTables();
if (in_array('schema_articles', $result) && in_array('schema_authors', $result)) {
return;
}
$table = <<<SQL
CREATE TABLE schema_authors (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(50),
bio TEXT,
created DATETIME
)
SQL;
$connection->execute($table);
$table = <<<SQL
CREATE TABLE schema_articles (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(20) DEFAULT 'testing',
body TEXT,
author_id INT(11) NOT NULL,
published BOOLEAN DEFAULT 0,
created DATETIME,
CONSTRAINT "title_idx" UNIQUE ("title", "body")
CONSTRAINT "author_idx" FOREIGN KEY ("author_id") REFERENCES "schema_authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT
);
SQL;
$connection->execute($table);
$connection->execute('CREATE INDEX "created_idx" ON "schema_articles" ("created")');
}
示例9: fireSql
/**
* @param $sql
*
* @return bool|DBResultSet
*/
private function fireSql($sql)
{
$sql .= ';';
if (!is_null($this->decodeFunction)) {
$sql = call_user_func($this->decodeFunction, $sql);
}
return $this->_conn->execute($sql);
}
示例10: execute
function execute($query)
{
$conn = new Connection();
$conn->open();
$recordset = $conn->execute($query);
$conn->close();
return $recordset;
}