Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17681
| Path | csiph.com!feeder.erje.net!2.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.php |
| Subject | Re: Problem With PDO? or While? |
| Date | Thu, 01 Feb 2018 11:11:18 +0000 |
| Organization | A noiseless patient Spider |
| Lines | 46 |
| Message-ID | <87efm59d7t.fsf@bsb.me.uk> (permalink) |
| References | <l5557d906fjq8a5ek4clf8cv2v76227ell@4ax.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | reader02.eternal-september.org; posting-host="233c10074f162c540fc1e1a403ed9dc3"; logging-data="30741"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX198pCad/ZK/97skUSdJt6oTZ5Bf547A4iU=" |
| Cancel-Lock | sha1:0gGvHtKfKUjFlswWUgr7b7QWjog= sha1:1PtEk76djBMkygBvPefXTIt+Itc= |
| X-BSB-Auth | 1.28c3a5af2f29888c7a39.20180201111118GMT.87efm59d7t.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.php:17681 |
Show key headers only | View raw
Call Me Tom <noemail@noemail.com> writes:
> I chose this forum because my sql statements appear to be working.
But I don't think you have a PHP problem.
> The logged user has all privileges on the database.
> The $numin echo prints 2555 which is the number of rows in the table.
> The table test is unchanged after running the file.
> Here's the code.
>
> <?php
>
> require_once('./includes/mysql_connect.php');
>
> $query = "SELECT report_id,fsacars_rep_url
> FROM test";
>
> $result=$dbh->query($query);
> $numin=$result->rowCount();
rowCount is only guaranteed to tell you the number of rows affected by
queries that modify a table. It will work like this for some databases
but it's not guaranteed.
> echo "$numin";
> while($url_orig=$result->FETCH(PDO::FETCH_NUM)) {
> $report_id = $url_orig[0];
> $url_trim = substr($url_orig[1],34);
> $url_new = 'http://localhost/CAA' . $url_trim;
>
> $sql="UPDATE test
> SET fsacars_rep_url = $url_new
> WHERE report_id = $report_id";
> $dbh->exec($sql);
You are updating the table before recovering all the rows from a row
set. The exec will invalidate the internal "cursor" that is used to
fetch the rows one by one.
> }
>
> What am I missing?
--
Ben.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Problem With PDO? or While? Call Me Tom <noemail@noemail.com> - 2018-01-31 23:20 -0500
Re: Problem With PDO? or While? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-02-01 11:11 +0000
Re: Problem With PDO? or While? Call Me Tom <noemail@noemail.com> - 2018-02-01 15:54 -0500
Re: Problem With PDO? or While? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-02-01 23:27 +0000
Re: Problem With PDO? or While? Call Me Tom <noemail@noemail.com> - 2018-02-01 23:57 -0500
Re: Problem With PDO? or While? Jerry Stuckle <jstucklex@attglobal.net> - 2018-02-01 08:19 -0500
csiph-web