- 博客(0)
- 资源 (7)
- 收藏
- 关注
php pdo组件的用法
单条查询不需要启用事务处理,并且不需要使用PDO的预处理方式,但注意要使用$pdo->quote()方法来自动将字符型变量值的字符中首尾加上单引号,以防止SQL注入,并且免去特殊符号转义的过程。
Query('set names "utf8"'); //设置mysql字符集
$sql_str='select * from tb where var2='.intval($var2).' and var1='.$pdo->quote($var1); //sql语句
if (!$sql=$pdo->Query($sql_str)) { //如果查询出错
$sql_info=$pdo->errorInfo(); //取得错误信息数组(注意此处取的是$pdo的errorInfo而不是$sql的)
echo '错误:'.$sql_info[2]; //输出错误信息
}
else {
$row=$sql->fetchAll(); //取得所有记录
if(count($row)==0) { //记录记录结果
echo '没有符合条件的记录';
}
else {
/* 仅输出一条记录
$row=$sql->fetch();
echo 'id:'.$row['id'].'';
*/
foreach($row as $row) { //循环保存所有结果到数组变量$row
echo 'id:'.$row['id'].'';
}
}
}
unset($pdo); //注销pdo对象
}
catch (Exception $e) {
die('数据库连接失败');
}
?>
2011-07-05
Papervision3D中文帮助手册
第六章 :与服务端通信
6.1 通过Http Service与服务端通信
6.2 通过Web Service与服务端通信
6.3 通过Remoting与服务端通信
6.4 与Flash Media Server交互
2011-07-05
php+flexigrid 已全部配置好,可支持多表多数据
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Flexigrid</title>
<link rel="stylesheet" type="text/css" href="css/flexigrid.css" />
<script type="text/javascript" src="jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="flexigrid.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#flex1").flexigrid
(
{
url: 'post2.php?table=country&len=3',
dataType: 'json',
colModel : [
{display: 'ID', name : 'id', width : 40, sortable : true, align: 'center'},
{display: '邮箱可见', name : 'email_disable', width : 45, sortable : true, align: 'left',hide:'true'},
{display: '邮箱地址', name : 'email', width : 100, sortable : true, align: 'left'},
{display: '邮箱验证', name : 'email_verify', width : 45, sortable : true, align: 'left',hide:'true'},
{display: '密码', name : 'pwd', width : 140, sortable : true, align: 'center',hide:'true'},
{display: '真实密码', name : 'pwd', width : 140, sortable : true, align: 'center',hide:'true'},
{display: '密码保护问题', name : 'pwd_question', width : 140, sortable : true, align: 'center'},
{display: '密码保护答案', name : 'pwd_answer', width : 140, sortable : true, align: 'center'},
{display: '手机', name : 'mobile', width : 100, sortable : true, align: 'center'},
{display: '手机验证', name : 'mobile_verify', width : 45, sortable : true, align: 'center',hide:'true'},
{display: '真实姓名', name : 'realname', width : 45, sortable : true, align: 'center'},
{display: '性别', name : 'gender', width : 40, sortable : true, align: 'center'},
{display: '身份证号', name : 'idcard', width : 110, sortable : true, align: 'center'},
{display: '身份证图片', name : 'idcard_image', width : 100, sortable : true, align: 'center',hide:'true'},
{display: '是否成年', name : 'adult', width : 40, sortable : true, align: 'center',hide:'true'},
{display: 'point', name : 'point', width : 40, sortable : true, align: 'center',hide:'true'},
{display: '注册时间', name : 'reg_time', width : 100, sortable : true, align: 'center',hide:'true'},
{display: '注册地址', name : 'reg_ip', width : 100, sortable : true, align: 'center',hide:'true'},
],
searchitems : [
{display: 'ID', name : 'id'},
{display: 'email', name : 'email',isdefault: true},
{display: 'gender', name : 'gender'}
],
sortname: "id",
sortorder: "asc",
usepager: true,
title: '帐号信息',
useRp: true,
rp: 2,
showTableToggleBtn: true,
width: 811,
height: 500
}
);
});
function sortAlpha(com)
{
jQuery('#flex1').flexOptions({newp:1, params:[{name:'letter_pressed', value: com},{name:'qtype',value:$('select[name=qtype]').val()}]});
jQuery("#flex1").flexReload();
}
function test(com,grid)
{
if (com=='Delete')
{
if($('.trSelected',grid).length>0){
if(confirm('Delete ' + $('.trSelected',grid).length + ' items?')){
var items = $('.trSelected',grid);
var itemlist ='';
for(i=0;i<items.length;i++){
itemlist+= items[i].id.substr(3)+",";
}
$.ajax({
type: "POST",
dataType: "json",
url: "delete.php",
data: "items="+itemlist,
success: function(data){
alert("Query: "+data.query+" - Total affected rows: "+data.total);
$("#flex1").flexReload();
}
});
}
} else {
return false;
}
}
else if (com=='Add')
{
alert('Add New Item Action');
}
}
</script>
</head>
<body>
<table id="flex1" style="display:none"></table>
</body>
</html>
2011-06-27
AS3坦克大战源代码 教程
纯as3坦克大战源码
MVC框架
备注都写得很清楚,
适合学习
package {
import Controllers.BasicController;
import Controllers.MonsterController;
import flash.display.Sprite;
import flash.display.Stage;
import flash.geom.Point;
import flash.utils.Timer;
import Objects.Base;
import Objects.GameObject;
import Objects.GameSounds;
import Objects.Item;
import Objects.Monster;
import Objects.Player;
import Objects.Stone;
import Sence.Sence;
import Controllers.KeyController;
import Objects.ActionObject;
import flash.events.TimerEvent;
public class Main extends Sprite{
private var mapconfig:Array = [
[0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1],
[0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1],
[0, 1, 0, 0, 0, 1, 4, 0, 0, 0, 1, 0],
[0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0],
[0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
];
public function Main() {
// constructor code
var sence:Sence.MapSence = new Sence.MapSence(stage);
sence.setup(mapconfig);
addChild(sence);
new GameSounds("open.mp3");
var timer:Timer = new Timer(10000);
timer.addEventListener(TimerEvent.TIMER, createItem);
timer.start();
}
private function createItem(e:TimerEvent) {
for each(var obj:GameObject in Global.sence.objectArray) {
if (obj is Item) obj.die(obj);
}
//删除当前的物品
/**
* 新建物品
*/
var p:Point = getRandomPlace();
var item:Item = new Item(new Item_Speed());
item.x = item.width * p.x + Global.INTERVAL;
item.y = item.width * p.y + Global.INTERVAL;
Global.sence.addObject(item);
}
private function getRandomPlace():Point {
var ry:uint = int(Math.random() * mapconfig.length);
var rx:uint = int(Math.random() * mapconfig[0].length);
if (mapconfig[ry][rx] == 0) return new Point(rx, ry);
return getRandomPlace();
}
}
}
2011-05-12
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人