Updating a row in sql using php

Another gripe I have about PDO is its inability to get the value of output parameters from stored procedures in some DBMSs, such as SQL Server. My SQL does not seem to return anything in row Count for a select statement, but you can easily and efficiently get the row count as follows:class db extends PDO $my Db = new db('mysql:host=myhost;dbname=mydb', 'login', 'password' ); Then, after running your query:if ( $my Db-My results:-------------------PDO_MSSQLrow Count() Standart: 0row Count() New: 0MSSQL throw PDO_ODBCrow Count() Standart: -1row Count() New: 53MS SQL driver 2.0row Count() Standart: -1row Count() New: 53-------------------With my PDO class you can use prepared queries like: every good work If you use "INSERT INTO ...

ON DUPLICATE KEY UPDATE" syntax, mysql_affected_rows() will return you 2 if the UPDATE was made (just as it does with the "REPLACE INTO" syntax) and 1 if the INSERT was.

When updating a Mysql table with identical values nothing's really affected so row Count will return 0. Perl below noted this is not always preferred behaviour and you can change it yourself since PHP 5.3.

However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.

ON DUPLICATE KEY UPDATE statement is not an INSERT statement, row Count won't return the number or rows inserted or updated for such a statement.

For My SQL, it will return 1 if the row is inserted, and 2 if it is updated, but that may not apply to other databases.fetch All()), which seems like a ridiculous waste of overhead and programming time.

If more than one row responds to the SELECT query, the query returns still only one row and you don't know which one exactly .

Maybe using a SORT BY, would make it a bit more predictible (as in: "if more than one users found, return the last user added in the table") but it's more a matter of good design of the program that fills in the table initially.

Search for updating a row in sql using php:

updating a row in sql using php-38

At 2560 rows inserted, the single query approach consumed ~800kb in memory, while the loop consumed just ~60kb.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “updating a row in sql using php”

  1. Error Banner.fade_out.modal_overlay.modal_overlay .modal_wrapper.modal_overlay [email protected](max-width:630px)@media(max-width:630px).modal_overlay .modal_fixed_close.modal_overlay .modal_fixed_close:before.modal_overlay .modal_fixed_close:before.modal_overlay .modal_fixed_close:before.modal_overlay .modal_fixed_close:hover:before.

  2. Until you've had a conversation about retiring your profiles, says Spira, assume that he is still dating other people. Spira employs a buddy system for initial meet-ups: Tell a friend where you're going and whom you're meeting. Be Patient If at first you don't succeed, don't give up!