NogDog;1288785 wrote:This would generally be my recommendation, too, with the caveat that if a possibility exists that the query could return a very large number of rows (for some undefined value of "very large"), you could end up using a lot of memory in your PHP app, made worse by the fact that PHP arrays are not very memory-efficient -- but that's more a question of whether or not you want/need to create one result array, versus whether or not to use the above technique to do so.
mysql will never return more than 10 rows because of the limit clause i think.
by the way:
my $sql is changed now and it is:
$sql = "SELECT Data_notizia, Readed, :wich_title AS Title FROM system_news, teams, users, prepared_news WHERE system_news.Template_news = prepared_news.id AND system_news.Id_team = teams.id AND teams.Id_user = users.id AND users.id = :Id ORDER BY Data_notizia DESC LIMIT :start_with, 10";
$s = $connection->prepare($sql);
$s->bindValue(':wich_title', $_POST['type_news']);
$s->bindValue(':Id', $_SESSION['Currentuserid']);
$s->bindValue(':start_with', $_POST['from'], PDO::PARAM_INT);
$s->execute();
foreach ($s AS $row)
{
$news_title_array[] = array(
'Data_notizia' => $row['Data_notizia'],
'Readed' => $row['Readed'],
'Title' => $row['Title']
);
the mysql send to me this error: Error1exception 'PDOException' with message 'SQLSTATE[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 ''0', 10' at line 1' in C:\xampp\htdocs\volleyballmanager\login\extract_news_title.php:91
i think this is because the bindvalue function puts quotes araund :start_with.
how can i avoid that problem?
THX GUYS! 