由于采用了ant, build前请下载JRE, 并设置好JAVA_HOME,CLASSPATH和PATH(或者放到jre目录), 然后点击install.bat,最后将build目录就是你要找的目录
<?php
defined('SS') or exit('Access Declined.');
class db_base
{
var $host = "";
var $database = "";
var $user = "";
var $password = "";
var $port = "";
var $socket = "";
var $record = array();
var $insert_id;
var $errno = 0;
var $error = "";
var $type = "mysql";
var $sql = "";
var $link = false;
var $result = false;
var $locked = false;
var $helper_db;
var $select = array();
var $from = '';
var $join = array() ;
var $on = array();
var $where = array();
var $orwhere = array();
var $order = array();
var $limit = '';
var $pconnect = false;
var $prepared_statement = false;
private static $Singleton;
public function __construct()
{
$this->set_config();
}
public static function GetInstance()
{
if(!(self::$Singleton instanceof db)){
self::$Singleton=new db();
}
return self::$Singleton;
}
public function set_config()
{
if (class_exists('db_config')){
$this->type = db_config::$db_type;
$this->host = db_config::$db_host;
$this->database = db_config::$db_name;
$this->user = db_config::$db_user;
$this->password = db_config::$db_pass;
$this->port = db_config::$db_port;
$this->socket = db_config::$db_socket;
}
}
public function set_parameters($type, $host, $database, $user, $pass, $port=3306, $socket='')
{
$this->type = $type;
$this->host = $host;
$this->database = $database;
$this->user = $user;
$this->password = $pass;
$this->port = $port;
$this->socket = $socket;
}
public function connect(){}
function free() {}
function clear()
{
$this->select = array();
$this->from = '';
$this->join = array();
$this->on = array();
$this->where = array();
$this->orwhere = array();
$this->order = array();
$this->limit = '';
}
public function selects($select=array())
{
if(!is_array($select)) $select=array($select);
if (count($select) > 0) $this->select = $select;
}
public function froms($from= '')
{
if ($from) $this->from = $from;
}
public function joins($join=array())
{
if(!is_array($join)) $join=array($join);
if (count($join) > 0) $this->join = $join;
}
public function ons($on=array())
{
if(!is_array($on)) $on=array($on);
if (count($on) > 0) $this->on = $on;
}
public function wheres($where=array())
{
if(!is_array($where)) $where=array($where);
if (count($where) > 0) $this->where = $where;
}
public function orwheres($orwhere=array())
{
if(!is_array($orwhere)) $orwhere=array($orwhere);
if (count($orwhere) > 0) $this->orwhere = $orwhere;
}
public function orders($order=array())
{
if(!is_array($order)) $order=array($order);
if (count($order) > 0) $this->order = $order;
}
public function limits($limit='')
{
if($limit) $this->limit= $limit . '';
}
public function getQuerySql()
{
$sql = '';
if(count($this->select) > 0){
$sql .= "SELECT " . implode(',', $this->select);
}
else{
$sql .= "SELECT * ";
}
if($this->from){
$sql .= " FROM ". $this->from ." ";
}
else{
return false;
}
if( count($this->on)> 0){
$ons = "";
$i = 0;
foreach ($this->on as $key => $value){
$sql .= " LEFT JOIN ".$this->join[$i]." ON " .$key. " = " .$value. " ";
$i++;
}
}
$isWhere = false;
if(count($this->where) > 0){
$isWhere = true;
$sql .= " WHERE ";
$ands = '';
foreach ($this->where as $key => $value){
if (!is_numeric($key)){
$ands .= " AND " .$key. " = '" .$value. "' ";
}
else{
$ands .= " AND " .$value. " ";
}
}
if (substr($ands,0,4) == ' AND') $ands = substr($ands,4);
$sql .= $ands;
}
使用javap分析return和finally的执行字节码
if(count($this->orwhere) > 0){
if(!$isWhere) $sql .= " WHERE ";
$ors = '';
foreach ($this->orwhere as $key => $value){
if (!is_numeric($key)){
$ors .= " OR " .$key. " = '" .$value. "' ";
}
else{
$ors .= " OR " .$value. " ";
}
}
if (substr($ors,0,3) == ' OR' && !$isWhere) $ors = substr($ors,3);
$sql .= $ors;
}
if(count($this->order) > 0){
$sql .= " ORDER BY " . implode(',', $this->order);
}
if($this->limit){
$sql .= ' LIMIT '.$this->limit .' ';
}
return $sql;
}
public function querySql($sql){}
public function query($sql = '')
{
$this->connect();
$this->free();
if ($sql){
$this->result = $this->querySql($sql);
if(!$this->result) $this->result = false;
$this->sql = $sql;
return $this->result;
}
else{
$sql = $this->getQuerySql();
$this->result = $this->querySql($sql);
if(!$this->result) $this->result = false;
$this->clear();
$this->sql = $sql;
return $this->result;
}
}
public function querys($sql = '')
{
return $this->query($sql);
}
public function next_record($type = MYSQL_ASSOC) {}
public function lock($table, $mode = "write")
{
$query = "lock tables ";
if(is_array($table)) {
while(list($key,$value) = each($table)) {
if(is_int($key)) $key = $mode;
if(strpos($value, ",")) {
$query .= str_replace(",", " $key, ", $value) . " $key, ";
} else {
$query .= "$value $key, ";
}
}
$query = substr($query, 0, -2);
} elseif(strpos($table, ",")) {
$query .= str_replace(",", " $mode, ", $table) . " $mode";
} else {
$query .= "$table $mode";
}
if(!$this->query($query)) {
$this->halt("lock() failed.");
return false;
}
$this->locked = true;
return true;
}
public function unlock()
{
$this->locked = false;
if(!$this->query("unlock tables")) {
$this->halt("unlock() failed.");
return false;
}
return true;
}
public function f($name)
{
if (isset($this->record[$name])) {
return $this->record[$name];
}
else{
return false;
}
}
public function p($name)
{
if (isset($this->record[$name])) {
print $this->record[$name];
}
}
public function nextid($table)
{
$sql = "select " .$table. "_id from " .$table. " order by " .$table. "_id desc";
if(!$this->query($sql)) {
$this->halt('query failed in nextid: '.$sql);
return 0;
}
if(!$this->next_record()) {
return 1;
}
else {
return $this->f($table. "_id") + 1;
}
}
public function insert_id() {}
public function num_rows() {}
public function affected_rows() {}
public function num_fields() {}
public function update_row($table, $index, $fields)
{
$this->connect();
if(!is_array($fields))
{
$this->halt('Invalid update row called');
return false;
}
if(!is_array($index))
{
$index = array($index);
}
$field_types='';
$index_types='';
$count=0;
$indexes=array();
foreach($fields as $key => $value)
{
if(!in_array($key, $index))
{
if (!is_numeric($key)){
$updates[] = "`$key`='".$this->escape($value)."'";
}
else{
$updates[] = $value;
}
}
}
if(isset($updates))
{
$sql = "UPDATE `$table` SET ".implode(',',$updates)." WHERE ";
$indexes=array();
foreach($index as $subindex)
{
$indexes[]="`$subindex`='".$this->escape($fields[$subindex])."'";
}
$sql .= implode(' AND ', $indexes);
$this->query($sql);
return $this->affected_rows();
}
return false;
}
public function insert_row($table, $fields,$replace='')
{
$this->connect();
if(!is_array($fields))
{
$this->halt('Invalid insert row called');
return false;
}
foreach($fields as $key => $value)
{
$field_names[] = $key;
if(is_numeric($value)){
$field_values[] = $value;
}
else{
$field_values[] = "'".$value."'";
}
//$field_values[] = $this->escape($value);
}
if(isset($field_names))
{
$sql = $replace ? 'REPLACE' : 'INSERT';
$sql .= " INTO `$table` (`".implode('`,`', $field_names)."`) VALUES ";
$sql .= "(".implode(",", $field_values).")";
//$sql .= "('".implode("','", $field_values)."')";
//tip($sql);
$this->query($sql);
return $this->affected_rows();
}else
{
$this->halt('Error insering row');
}
return false;
}
public function delete_row($table, $where = array())
{
$this->connect();
if(!is_array($where)) $where=array($where);
if(count($where) > 0){
$where_ = '';
foreach ($where as $key => $value){
if (!is_numeric($key)){
$where_ .= " AND " .$key. " = '" .$value. "' ";
}
else{
$where_ .= " AND " .$value. " ";
}
}
if (substr($where_,0,4) == ' AND') $where_ = substr($where_,4);
$where_ = ' WHERE '. $where_;
}
$sql = "DELETE FROM " .$table;
$sql .= $where_;
$this->query($sql);
return $this->affected_rows();
}
public function replace_row($table, $fields)
{
return $this->insert_row($table, $fields, 'REPLACE');
}
public function escape($value, $trim=true){}
protected function set_log($level, $message)
{
$messages = str_split($message, 500);
for ($i = 0; $i < count($messages); $i ++) {
syslog($level, $messages[$i]);
}
}
protected function halt($msg)
{
if ($this->locked) {
$this->unlock();
}
$this->set_log(LOG_DEBUG, sprintf("Database Error: [ %s ]\n\nMySQL Error: [ %s (%s) ]",
$msg,
$this->errno,
$this->error));
tip(sprintf("Database Error: [ %s ]\n\nMySQL Error: [ %s (%s) ]",
$msg,
$this->errno,
$this->error));
}
public function close(){}
public function found_rows()
{
if(!isset($this->helper_db)){
$this->helper_db = new db();
}
$this->helper_db->query("SELECT FOUND_ROWS() as found;");
$this->helper_db->next_record();
return $this->helper_db->f('found');
}
public function table_exists($table_name)
{
if(!isset($this->tables)){
$this->tables=array();
$this->query('SHOW TABLES');
while($r=$this->next_record(MYSQL_NUM)){
$this->tables[]=$r[0];
}
}
return in_array($table_name, $this->tables);
}
}
if (class_exists('db_config')){
if(db_config::$db_type == 'mysqli' && function_exists('mysqli_close')){
ss_sys('mysqli');
}
else{
ss_sys('mysql');
}
}