Re: mysql question #2

From: Date: Sun, 10 Feb 2008 18:18:50 +0000
Subject: Re: mysql question #2
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-269050@lists.php.net to get a copy of this message
On Feb 10, 2008 1:12 PM, nihilism machine <nihilismmachine@gmail.com> wrote: > Ok, I read the php.net info. so with this function though: > > public function select_one($sql) { > $this->last_query = $sql; > $r = mysql_query($sql); > if (!$r) { > $this->last_error = mysql_error(); > return false; > } > if (mysql_num_rows($r) != 1) { > return false; > } > $ret = mysql_result($r, 0); > mysql_free_result($r); > if ($this->auto_slashes) { > return stripslashes($ret); > } else { > return $ret; > } > } as the function stands you wont be able to. you can alter it though: public function select_one($sql, $columnName) { $this->last_query = $sql; $r = mysql_query($sql); $ret = false; /// default return value is false if (!$r) { $this->last_error = mysql_error(); return false; } if (mysql_num_rows($r) != 1) { return false; } $result = mysql_fetch_assoc($r); if(isset($result[$columnName])) { $ret = $result[$columnName]); } mysql_free_result($r); if ($this->auto_slashes) { return stripslashes($ret); } else { return $ret; } } note: i just hacked that together in my mail client :) -nathan

« previous php.general (#269050) next »