gcdb::get_var()
最后更新于:2021-11-26 09:01:06
gcdb::get_var( string|null$query=null, int$x, int$y)Retrieves one variable from the database.
参数
- $query
-
(string|null) (Optional) SQL query. Defaults to null, use the result from the previous query.
Default value: null
- $x
-
(int) (Optional) Column of value to return. Indexed from 0.
- $y
-
(int) (Optional) Row of value to return. Indexed from 0.
响应
(string|null) Database query result (as string), or null on failure.
源文件
文件: gc-includes/gc-db.php
public function get_var( $query = null, $x = 0, $y = 0 ) {
$this->func_call = "$db->get_var("$query", $x, $y)";
if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
$this->check_current_query = false;
}
if ( $query ) {
$this->query( $query );
}
// Extract var out of cached results based on x,y vals.
if ( ! empty( $this->last_result[ $y ] ) ) {
$values = array_values( get_object_vars( $this->last_result[ $y ] ) );
}
// If there is a value return it, else return null.
return ( isset( $values[ $x ] ) && '' !== $values[ $x ] ) ? $values[ $x ] : null;
}