note 97432 added to pdo.prepared-statements
| From: | tidelipop at gmail dot com | Date: | Mon, 19 Apr 2010 17:15:52 +0000 |
| Subject: | note 97432 added to pdo.prepared-statements | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-168424@lists.php.net to get a copy of this message | ||
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;
}
----
Server IP: 69.147.83.197
Probable Submitter: 213.188.12.132
----
Manual Page -- http://www.php.net/manual/en/pdo.prepared-statements.php
Edit -- https://master.php.net/note/edit/97432
Del: integrated -- https://master.php.net/note/delete/97432/integrated
Del: useless -- https://master.php.net/note/delete/97432/useless
Del: bad code -- https://master.php.net/note/delete/97432/bad+code
Del: spam -- https://master.php.net/note/delete/97432/spam
Del: non-english -- https://master.php.net/note/delete/97432/non-english
Del: in docs -- https://master.php.net/note/delete/97432/in+docs
Del: other reasons-- https://master.php.net/note/delete/97432
Reject -- https://master.php.net/note/reject/97432
Search -- https://master.php.net/manage/user-notes.php