public static function updateAll($data) { $db = JO_Db::getDefaultAdapter(); if (is_array($data)) { $delete_pin_no_image = $delete_user_no_image = false; if (isset($data['images']['no_image']) && basename($data['images']['no_image']) != Helper_Config::get('no_image')) { $delete_pin_no_image = true; } if (isset($data['images']['no_avatar']) && basename($data['images']['no_avatar']) != Helper_Config::get('no_avatar')) { $delete_user_no_image = true; } foreach ($data as $group => $value) { $db->delete('system', array('`group` = ?' => $group)); if (is_array($value)) { foreach ($value as $key => $val) { $serialize = false; if (is_array($val)) { $serialize = true; $val = serialize($val); } $db->insert('system', array('group' => $group, 'key' => $key, 'value' => $val, 'system' => (int) ($group == 'config'), 'serialize' => $serialize)); } } } if ($delete_pin_no_image) { Helper_Db::query("TRUNCATE TABLE `pins_images`"); } if ($delete_user_no_image) { Helper_Db::query("TRUNCATE TABLE `users_avatars`"); } } }
public function stats() { $db = JO_Db::getDefaultAdapter(); Helper_Db::delete('statistics', array()); Helper_Db::query("INSERT INTO `statistics`(`id`, `total`, `type`) SELECT DATE_FORMAT(`date_added`, '%Y%m'),COUNT(pin_id),1 FROM pins GROUP BY DATE_FORMAT(`date_added`, '%Y%m');"); Helper_Db::query("INSERT INTO `statistics`(`id`, `total`, `type`) SELECT DATE_FORMAT(`date_added`, '%Y%m'),COUNT(user_id),2 FROM users GROUP BY DATE_FORMAT(`date_added`, '%Y%m');"); Helper_Db::query("INSERT INTO `statistics`(`id`, `total`, `type`) SELECT DATE_FORMAT(`date_added`, '%Y%m'),COUNT(board_id),3 FROM boards GROUP BY DATE_FORMAT(`date_added`, '%Y%m');"); }
public function installAction() { Model_Extensions_Install::install('facebook'); if (!Model_Extensions_Install::tableExists('oauth_facebook')) { Helper_Db::query("CREATE TABLE IF NOT EXISTS oauth_facebook (\r\n\t\t\t\tid BIGINT(20) AUTO_INCREMENT,\r\n\t\t\t\temail VARCHAR(120),\r\n\t\t\t\toauth_uid BIGINT(20),\r\n\t\t\t\tuser_id BIGINT(20),\r\n\t\t\t\taccess_token VARCHAR(200),\r\n\t\t\t\ttimeline TINYINT(1),\r\n\t\t\t\tPRIMARY KEY (`id`),\r\n\t\t\t\tKEY `oauth_uid` (`oauth_uid`),\r\n\t\t\t\tKEY `user_id` (`user_id`)\r\n\t\t\t\t) ENGINE=InnoDB;"); } if (!Model_Extensions_Install::tableExists('invate_facebook')) { Helper_Db::query("CREATE TABLE IF NOT EXISTS `invate_facebook` (\r\n\t\t\t `if_id` bigint(20) NOT NULL AUTO_INCREMENT,\r\n\t\t\t `user_id` bigint(20) NOT NULL,\r\n\t\t\t `code` varchar(32) COLLATE utf8_unicode_ci NOT NULL,\r\n\t\t\t `facebook_id` bigint(20) NOT NULL,\r\n\t\t\t PRIMARY KEY (`if_id`),\r\n\t\t\t KEY `user_id` (`user_id`,`code`)\r\n\t\t\t) ENGINE=InnoDB;"); } $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth_facebook'); }
public function installAction() { Model_Extensions_Install::install('twitter'); if (!Model_Extensions_Install::tableExists('oauth_twitter')) { Helper_Db::query("CREATE TABLE IF NOT EXISTS oauth_twitter (\r\n\t\t\t\tid BIGINT(20) AUTO_INCREMENT,\r\n\t\t\t\toauth_uid BIGINT(20),\r\n\t\t\t\tuser_id BIGINT(20),\r\n\t\t\t\tusername VARCHAR(100),\r\n\t\t\t\ttwitter_oauth_token VARCHAR(200),\r\n\t\t\t\ttwitter_oauth_token_secret VARCHAR(200),\r\n\t\t\t\ttwit TINYINT(1),\r\n\t\t\t\tPRIMARY KEY (`id`),\r\n\t\t\t\tKEY `oauth_uid` (`oauth_uid`),\r\n\t\t\t\tKEY `user_id` (`user_id`)\r\n\t\t\t\t) ENGINE=InnoDB;"); } $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth_twitter'); }
public static function select_email($uid) { $sql = 'select `email` from `libraryuser` where `uid`=? and `email` IS NOT NULL'; $ret = Helper_Db::query($sql, array($uid)); return isset($ret[0]['email']) ? $ret[0]['email'] : ''; }
public function installAction() { Model_Extensions_Install::install('instagram'); if (!Model_Extensions_Install::tableExists('oauth_instagram')) { Helper_Db::query("CREATE TABLE IF NOT EXISTS oauth_instagram (\r\n\t\t\t\tid BIGINT(20) AUTO_INCREMENT,\r\n\t\t\t\toauth_uid BIGINT(20),\r\n\t\t\t\tuser_id BIGINT(20),\r\n\t\t\t\tusername VARCHAR(100),\r\n\t\t\t\taccess_token VARCHAR(200),\r\n\t\t\t\tPRIMARY KEY (`id`),\r\n\t\t\t\tKEY `oauth_uid` (`oauth_uid`),\r\n\t\t\t\tKEY `user_id` (`user_id`)\r\n\t\t\t\t) ENGINE=InnoDB;"); } if (!Model_Extensions_Install::tableExists('instagram_media')) { Helper_Db::query("CREATE TABLE IF NOT EXISTS `instagram_media` (\r\n\t\t\t `media_id` bigint(20) NOT NULL AUTO_INCREMENT,\r\n\t\t\t `user_id` bigint(20) NOT NULL,\r\n\t\t\t `pin_id` bigint(20) NOT NULL,\r\n\t\t\t `instagram_media_id` bigint(20) NOT NULL,\r\n\t\t\t `width` bigint(20) NOT NULL,\r\n\t\t\t `height` bigint(20) NOT NULL,\r\n\t\t\t `media` varchar(1024) COLLATE utf8_unicode_ci NOT NULL,\r\n\t\t\t `instagram_profile_id` bigint(20) NOT NULL,\r\n\t\t\t `md5key` varchar(32) COLLATE utf8_unicode_ci NOT NULL,\r\n\t\t\t `title` varchar(500) COLLATE utf8_unicode_ci NOT NULL,\r\n\t\t\t `from` varchar(1024) COLLATE utf8_unicode_ci NOT NULL,\r\n\t\t\t PRIMARY KEY (`media_id`),\r\n\t\t\t KEY `user_id` (`user_id`),\r\n\t\t\t KEY `instagram_media_id` (`instagram_media_id`),\r\n\t\t\t KEY `md5key` (`md5key`),\r\n\t\t\t KEY `instagram_profile_id` (`instagram_profile_id`),\r\n\t\t\t KEY `pin_id` (`pin_id`)\r\n\t\t\t) ENGINE=InnoDB;"); } $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth_instagram'); }
private static function initDB() { Helper_Db::query("CREATE TABLE IF NOT EXISTS `language_keywords` (\n\t\t `language_keywords_id` int(11) NOT NULL auto_increment,\n\t\t `key` char(32) collate utf8_unicode_ci NOT NULL,\n\t\t `keyword` text character set utf8 collate utf8_bin NOT NULL,\n\t\t `translate` text character set utf8 collate utf8_bin NOT NULL,\n\t\t `module` varchar(128) collate utf8_unicode_ci NOT NULL,\n\t\t PRIMARY KEY (`language_keywords_id`),\n\t\t KEY `module` (`module`),\n\t\t KEY `key` (`key`),\n\t\t FULLTEXT KEY `keyword` (`keyword`)\n\t\t) ENGINE=MyISAM;"); }