PDA

View Full Version : حرفه ای: دریافت مقادیر بازگشتی این تابع



css-man
شنبه 29 شهریور 1393, 11:25 صبح
دوستان این یه متد هست برای select ولی true و false بر میگردونه
چطور میتونم به مقادیر بازگشتی از دیتابیسم تو این تابع دسترسی داشته باشم
آخه هیچ متغیری رو return می کنه
البته شایدم من بد فهمیدمش




// Function to SELECT from the database
public function select($table, $rows = '*', $join = null, $where = null, $order = null, $limit = null){
// Create query from the variables passed to the function
$q = 'SELECT '.$rows.' FROM '.$table;
if($join != null){
$q .= ' JOIN '.$join;
}
if($where != null){
$q .= ' WHERE '.$where;
}
if($order != null){
$q .= ' ORDER BY '.$order;
}
if($limit != null){
$q .= ' LIMIT '.$limit;
}
$this->myQuery = $q; // Pass back the SQL
// Check to see if the table exists
if($this->tableExists($table)){
// The table exists, run the query
$query = @mysql_query($q);
if($query){
// If the query returns >= 1 assign the number of rows to numResults
$this->numResults = mysql_num_rows($query);
// Loop through the query results by the number of rows returned
for($i = 0; $i < $this->numResults; $i++){
$r = mysql_fetch_array($query);
print_r($r);
$key = array_keys($r);
print_r($key);
for($x = 0; $x < count($key); $x++){
// Sanitizes keys so only alphavalues are allowed
if(!is_int($key[$x])){
if(mysql_num_rows($query) >= 1){
$this->result[$i][$key[$x]] = $r[$key[$x]];
}else{
$this->result = null;
}
}
}
}
return true; // Query was successful
}else{
array_push($this->result,mysql_error());
return false; // No rows where returned
}
}else{
return false; // Table does not exist
}
}

bagherok
یک شنبه 30 شهریور 1393, 00:24 صبح
با

$this->result