I'm doing some social activity page on phalcon but there is a strange problem on get feeds. Im doing raw query on phalcon , but when i write code manually its working , but when set/get from jquery to php its not.
Manually code (its working):
$sql = "SELECT S.*,S.user_one as user_id,S.id,U.username,U.profile_photo
FROM users U, social S
WHERE
CASE
WHEN `user_one` = $user_id
THEN `user_two` = `user_id`
WHEN `user_two` = $user_id
THEN `user_one`= `user_id`
END
AND
(`user_one` = $user_id OR `user_two` =$user_id) Group by S.id ORDER BY S.id DESC LIMIT 20 OFFSET 0";
// Base model
$social = new Social();
// Execute the query
return new Resultset(null, $social, $social->getReadConnection()->query($sql));
But same query same code but only get from jquery (its crypting)
public static function runAjaxQuery($sql)
{
// Base model
$social = new Social();
// Execute the query
return new Resultset(null, $social, $social->getReadConnection()->query($sql));
}
On second i got that error : SELECT S.*,S.user_one as user_id,S.id,U.username,U.profile_photo
FROM users U, social S
WHERE
CASE
WHEN user_one = 6
THEN user_two = user_id
WHEN user_two = 6
THEN user_one= user_id
END
AND
(user_one = 6 OR user_two =6) Group by S.id ORDER BY S.id DESC LIMIT 20 OFFSET 20SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"SELECT S.*,S.user_one as user_id,S.id,U.username,U.profile_photo
FROM users U,' at line 1
Thanks for all