/** * @param string $sql * @return boolean */ private function _execute($sql) { if (method_exists($this->_db, 'execute')) { return $this->_db->execute($sql); } else { return $this->_db->query($sql); } }
function listAction() { $sql = "select o_id,cr_id,o_time,o_use_time,o_amount,o_free_amount,o_real_amount,o_state \n\t\t\t\tfrom " . Pft_Db::getTbName('orders'); $grid = new Pft_Util_Grid_Searchs(); $grid->addSearch("o_amount"); $grid->addSearch("cr_id", '客户ID', '=', null, null, true); $grid->setSql($sql); $this->grid = $grid->excuteAndReturnGrid(); }
/** * * @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); } }
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; }
/** * 结束使用只读数据库 * * @author bobit * Mon Sep 24 16:37:49 CST 200716:37:49 */ public static function endUseReadonlyDb() { self::$_need_use_readonly_db = 0; Pft_Debug::addInfoToDefault('', 'Unset use READONLY DB server'); }
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