/** * Inserts a table row with specified data. * * @param mixed $table The table to insert data into. * @param array $bind Column-value pairs. * @return int The number of affected rows. */ public function insert($table = null, array $bind = null) { if (is_null($table) && is_null($bind)) { return new Harmoni_Db_Insert($this); } else { return parent::insert($table, $bind); } }
/** * Faz o upload da imagem * * @return array */ public function saveImage($array) { $db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => 'localhost', 'username' => 'root', 'password' => '', 'dbname' => 'painelpadrao_imagem')); $form = array("nm_avatar" => $array["file"]["name"], "tp_avatar" => $array["file"]["type"], "sz_avatar" => $array["file"]["size"], "arquivo" => file_get_contents($array["file"]["tmp_name"])); $result = $db->insert("imagem", $form); //$sql = "SELECT * FROM imagem WHERE id_avatar = ".$id; return $result; }
/** * sets all given contexts for a given tag * * @param array $_contexts array of application ids (0 or 'any' for all apps) * @param string $_tagId * @throws Tinebase_Exception_InvalidArgument */ public function setContexts(array $_contexts, $_tagId) { if (!$_tagId) { throw new Tinebase_Exception_InvalidArgument('A $_tagId is mandentory.'); } if (in_array('any', $_contexts, true) || in_array(0, $_contexts, true)) { $_contexts = array(0); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting tag contexts: ' . print_r($_contexts, true)); } foreach ($_contexts as $context) { $this->_db->insert(SQL_TABLE_PREFIX . 'tags_context', array('tag_id' => $_tagId instanceof Tinebase_Model_Tag ? $_tagId->getId() : $_tagId, 'application_id' => $context)); } }
<?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)); }
//$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); Pimcore::setupFramework(); Pimcore::initLogger(); Pimcore::initModules(); Pimcore::initPlugins();