我试图用我方言执行一份准备发言,但声明从未执行过结果,也没有犯错误。 但执行询问通常奏效。
准备的疑问是:
SELECT * FROM games WHERE YEARweek(game_date)=?
经常没有准备的问询就是这种情况。
SELECT * FROM games WHERE YEARweek(game_date)= YEARweek(current_DATE) +1
任何想法为什么?
执行询问的守则在不同地点,但从短文来看似乎如此:
$WHERE_CLAUSE= ;
$first=true;
if(isset($conditions[ conditions ])) {
foreach($conditions[ conditions ] as $key=>$condition){
if(is_array($condition)){
} else {
if($first)
$WHERE_CLAUSE.=$key. =? ;
else
$WHERE_CLAUSE.= AND .$key. =? ;
$input_data[$key]=$condition;
$first=false;
}
}//end foreach
if(!empty($WHERE_CLAUSE)){
$query.= WHERE .$WHERE_CLAUSE. ;
}
}
$result=PVDatabase::preparedSelect($query, $input_data);
public static function preparedQuery($query, $data, $formats = ) {
if (self::_hasAdapter(get_class(), __FUNCTION__))
return self::_callAdapter(get_class(), __FUNCTION__, $query, $data, $formats);
if (self::$dbtype == self::$mySQLConnection) {
self::$link -> prepare($query);
$count = 1;
foreach ($data as $key => $value) {
self::$link -> bindParam($count, $value);
$count++;
}//end foreach
return self::$link -> execute();
} else if (self::$dbtype == self::$postgreSQLConnection) {
$result = pg_prepare(self::$link, , $query);
$result = pg_execute(self::$link, , $data);
return $result;
} else if (self::$dbtype == self::$oracleConnection) {
} else if (self::$dbtype == self::$msSQLConnection) {
$stmt = sqlsrv_prepare(self::$link, $query, $data);
return sqlsrv_execute($stmt);
}
}//end preparedQuery