note 97432 rejected from pdo.prepared-statements by danbrown

From: Date: Mon, 19 Apr 2010 17:21:43 +0000
Subject: note 97432 rejected from pdo.prepared-statements by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-168425@lists.php.net to get a copy of this message
Note Submitter: tidelipop at gmail dot com ---- I'm running MS SQL Server 2008 and I get this error-msg when I call fullTextSearch("orange juice"), why? Query Error!: SQLSTATE[42000]: Syntax error or access violation: 7645 [Microsoft][SQL Server Native Client 10.0][SQL Server]Null or empty full-text predicate. (SQLExecute[7645] at ext\pdo_odbc\odbc_stmt.c:133) // This is a class member function function loadAll($query, $params = array(), $fetch_style = PDO::FETCH_ASSOC) { $db =& $this->dblink; try { $stmt = $db->prepare($query); foreach ($params as $key => $value) { $key = utf8_decode($key); $value = utf8_decode($value); if (preg_match ('/_id$/u', $key)) { $bind_result = $stmt->bindValue(":$key", $value, PDO::PARAM_INT); } else { $bind_result = $stmt->bindValue(":$key", $value, PDO::PARAM_STR); } } $error = $stmt->errorInfo(); $stmt->execute(); $result = $stmt->fetchAll($fetch_style); } catch (PDOException $e) { ob_end_clean(); die("Query Error!:<br/>\n" . $e->getMessage() . "<br/>"); } return $result; } // Also a class member function... function fullTextSearch($phrase) { $phrase_lenght = strlen($phrase); $query = "DECLARE @phrase nvarchar($phrase_lenght);\nSET @phrase=:phrase;\nSELECT tag, body, language FROM pages WHERE latest='Y' AND FREETEXT((body,tag), @phrase) ORDER BY tag;"; $query_params = array('phrase'=>$phrase); $result = $this->LoadAll($query, $query_params); return $result; }

« previous php.notes (#168425) next »