本文整理汇总了PHP中Zend_Db_Adapter_Pdo_Mysql::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Pdo_Mysql::exec方法的具体用法?PHP Zend_Db_Adapter_Pdo_Mysql::exec怎么用?PHP Zend_Db_Adapter_Pdo_Mysql::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Adapter_Pdo_Mysql
的用法示例。
在下文中一共展示了Zend_Db_Adapter_Pdo_Mysql::exec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: int
<?php
set_include_path(realpath(dirname(__FILE__) . '/../vendor/zendframework/zendframework1/library'));
require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
$db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => 'localhost', 'charset' => 'utf8', 'dbname' => 'hello_world', 'username' => 'benchmarkdbuser', 'password' => 'benchmarkdbpass'));
$db->exec('DROP TABLE IF EXISTS `World`;');
$db->exec('CREATE TABLE `World` (
`id` int(11) NOT NULL,
`randomNumber` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
for ($i = 1; $i <= 10000; $i++) {
$db->insert('World', array('id' => $i, 'randomNumber' => $i));
}
示例2: explode
$db->getConnection();
$db->getConnection()->exec("SET NAMES UTF8");
$db->getConnection()->exec("SET storage_engine=InnoDB;");
// insert db dump
//$db = Pimcore_Resource::get();
$mysqlInstallScript = file_get_contents(PIMCORE_PATH . "/modules/install/mysql/install.sql");
// remove comments in SQL script
$mysqlInstallScript = preg_replace("/\\s*(?!<\")\\/\\*[^\\*]+\\*\\/(?!\")\\s*/", "", $mysqlInstallScript);
// get every command as single part
$mysqlInstallScripts = explode(";", $mysqlInstallScript);
// execute every script with a separate call, otherwise this will end in a PDO_Exception "unbufferd queries, ..."
foreach ($mysqlInstallScripts as $m) {
$sql = trim($m);
if (strlen($sql) > 0) {
$sql .= ";";
$db->exec($m);
}
}
// insert data into database
$db->insert("assets", array("id" => 1, "parentId" => 0, "type" => "folder", "filename" => "", "path" => "/", "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
$db->insert("documents", array("id" => 1, "parentId" => 0, "type" => "page", "key" => "", "path" => "/", "index" => 999999, "published" => 1, "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
$db->insert("documents_page", array("id" => 1, "controller" => "", "action" => "", "template" => "", "title" => "", "description" => "", "keywords" => ""));
$db->insert("objects", array("o_id" => 1, "o_parentId" => 0, "o_type" => "folder", "o_key" => "", "o_path" => "/", "o_index" => 999999, "o_published" => 1, "o_creationDate" => time(), "o_modificationDate" => time(), "o_userOwner" => 1, "o_userModification" => 1));
$userPermissions = array(array("key" => "assets", "translation" => "permission_assets"), array("key" => "classes", "translation" => "permission_classes"), array("key" => "clear_cache", "translation" => "permission_clear_cache"), array("key" => "clear_temp_files", "translation" => "permission_clear_temp_files"), array("key" => "document_types", "translation" => "permission_document_types"), array("key" => "documents", "translation" => "permission_documents"), array("key" => "objects", "translation" => "permission_objects"), array("key" => "plugins", "translation" => "permission_plugins"), array("key" => "predefined_properties", "translation" => "permission_predefined_properties"), array("key" => "routes", "translation" => "permission_routes"), array("key" => "seemode", "translation" => "permission_seemode"), array("key" => "system_settings", "translation" => "permission_system_settings"), array("key" => "thumbnails", "translation" => "permission_thumbnails"), array("key" => "translations", "translation" => "permission_translations"), array("key" => "users", "translation" => "permission_users"), array("key" => "update", "translation" => "permissions_update"), array("key" => "redirects", "translation" => "permissions_redirects"), array("key" => "glossary", "translation" => "permissions_glossary"), array("key" => "reports", "translation" => "permissions_reports_marketing"));
foreach ($userPermissions as $up) {
$db->insert("users_permission_definitions", $up);
}
}
// complete the pimcore starup tasks (config, framework, modules, plugins ...)
Pimcore::initConfiguration();
sleep(4);