/** * * @author y31 * Tue Dec 11 22:40:45 CST 2007 */ function provideAction() { $dbName = $this->getInputParameter('db_name'); $param = $this->getInputParameter('param'); $method = $this->getInputParameter('method'); if ($dbName) { $sql = "select * from {$dbName}"; $this->{$dbName} = Pft_Db::getDb()->getAll($sql); } }
public function __construct($db = null) { if ($db) { $this->_db = $db; } elseif (is_object(self::$_common_db)) { $this->_db = self::$_common_db; } else { $this->_db = Pft_Db::getDb(); } //初始化数据存储数组 foreach ($this->_fields as $field) { $this->_data[$field] = null; } }
function listAction() { //找出产品 $sql = "select * from kinds where is_del<1 order by k_id asc"; $datas = Pft_Db::getDb()->getAll($sql); $this->list = $list = $datas; //得到默认的产品 (分类中的第一个) $k_id = null; foreach ($list as $row) { $k_id = $row["k_id"]; break; } $this->products = null; if ($k_id) { $sql = "select * from products where k_id='" . $k_id . "'"; $products = Pft_Db::getDb()->getAll($sql); } $this->products = $products; }
function addTermsAction() { $returnData = array(); $biaoqian = $this->getInputParameter("biaoqian"); if ($biaoqian) { $biaoqians = explode(',', $biaoqian); $i = 0; foreach ($biaoqians as $bq) { $sql = "select * from terms where term_name='" . addslashes($bq) . "'"; $data = Pft_Db::getDb()->getOne($sql); if (!$data) { $terms = new Yd_Terms(); $terms->term_name = $bq; if ($terms->save()) { $returnData[$i]["term_id"] = $terms->term_id; $returnData[$i]["term_name"] = $terms->term_name; $i++; } } } } echo json_encode($returnData); exit; }
/** * 连接读写服务器 * @return Pft_Db * @author terry * @version 0.1.0 * Fri Aug 10 20:55:06 CST 2007 */ public static function connectReadwriteDb() { $db = Pft_Db::getDb('readwrite'); Pft_Debug::addInfoToDefault('', "Connected to Db [" . 'readwrite' . "]"); return $db; }
private function _getCountWithSql() { return Pft_Db::getDb()->getOne($this->_getCountSql()); }
/** * 通过角色 Id 获得用户菜单 * 这个应该放到 角色的属性里 * * @param int $roleId * @return array|null */ public static function getRoleMenus($roleId) { $sql = "select menu_id,menu_parent_id,menu_name,menu_path,privilege_do \n from tpm_menu\n left join tpm_privilege using (privilege_id) \n left join tpm_role_privilege_rel using (privilege_id) \n where role_id = {$roleId} \n or tpm_menu.privilege_id = 0\n order by menu_path"; // $sql = "select * from tpm_test"; $arr_menu = Pft_Db::getDb()->getAll($sql); // var_dump( $arr_menu ); return $arr_menu; }
private function __construct($managerName = null) { $this->_managerName = $managerName; $this->_db = Pft_Db::getDb(); // 原为getDbx() 导致 Pft_db->_connection 访问出错,因此更改为getDb() }
/** * 说明 * */ function GetAll($sql) { $jgsz = Pft_Db::getDb()->getAll($sql); //$jgsz = $this->db->GetAll($sql); /*$qusql = mysql_query($sql); if (!$qusql) { $this -> error .= '无法连接数据库<hr>'; return false; } else { while($jigu = @mysql_fetch_assoc($qusql)) { $jgsz[] = $jigu; } }*/ return $jgsz; }
/*$config_data=include_once(dirname(__FILE__)."/../../config/default/propel.conf.php"); $cg_data=$config_data["datasources"]["propel"]["connection"]; $db_cfg['hostspec'] = $cg_data["hostspec"]; $db_cfg['port'] = '3306'; $db_cfg['username'] = $cg_data["username"]; $db_cfg['password'] = $cg_data["password"]; $db_cfg['database'] = $cg_data["database"]; */ $db_cfg['hostspec'] = 'localhost'; $db_cfg['port'] = '3306'; $db_cfg['username'] = '******'; $db_cfg['password'] = '******'; $db_cfg['database'] = 'DEV_tpm_watt'; $db_cfg['charset'] = 'utf8'; $db = Pft_Db::getDb($db_cfg); $default_tables = ""; //------------------------------ $cmd = @$_REQUEST['cmd']; if ('backup' == $cmd) { $tables = @$_REQUEST['tables']; $tableArr = explode("\n", $tables); $theWriter = new SqlWriter(); foreach ($tableArr as $table) { $table = trim($table); if (!$table) { continue; } //Drop $theWriter->writeln("\nDROP TABLE IF EXISTS {$table};"); //Create New