Re: [PHP-DB] Prepared Statements Rows Selected

2011-05-23 Thread Giff Hammar
$stmt->rows() should give you the number of rows returned.

Giff

On Mon, 2011-05-23 at 18:53 -0400, Ron Piggott wrote:
> What command will tell me the # of rows the SELECT query retrieved using 
> Prepared Statements.
> 
> 
> $dsh = 'mysql:host=localhost;dbname='.$database;
> $dbh = new PDO($dsh, $username, $password);
> 
> $stmt = $dbh->prepare($query);
> 
> $stmt->bindParam(':email', $email);
> $stmt->bindParam(':pass', $pass);
> 
> $stmt->execute();
> 
> 
> I am looking for the equivalent of mysql_numrows
> 
> mysql_connect('localhost',$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
> $result=mysql_query($query);
> $num=mysql_numrows($result);
> 
> 
> Ron
> 
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info  



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Prepared Statements Rows Selected

2011-05-23 Thread Ron Piggott

What command will tell me the # of rows the SELECT query retrieved using 
Prepared Statements.


$dsh = 'mysql:host=localhost;dbname='.$database;
$dbh = new PDO($dsh, $username, $password);

$stmt = $dbh->prepare($query);

$stmt->bindParam(':email', $email);
$stmt->bindParam(':pass', $pass);

$stmt->execute();


I am looking for the equivalent of mysql_numrows

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result=mysql_query($query);
$num=mysql_numrows($result);


Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info  


Re: [PHP-DB] Query Question

2011-05-23 Thread maarten
That's a very good point,

but since I use postgres that's one point that doesn't affect me and as
such didn't cross my mind at the time.

(Postgres uses schemas where mysql uses databases, a different database
on postgres usually means a different database machine.  And joining
tables from different database machines isn't really plausible.)

I read the question as 'schema names' in stead of 'database names'.


On Mon, 2011-05-23 at 06:47 -0500, Bret Hughes wrote:
> I like to set the dbname in a config file and use it only for making the 
> connection to the database.  That way I can test/develop against 
> different databases on the same server.  By locking yourself into 
> dbnames in the queries themselves I believe you loose a huge amount of 
> environmental flexibility.
> 
> Using tablenames and or aliases is something I do a fair amount of but 
> only when joining or with complicated queries where clarity is an issue.
> 
> On 05/23/2011 02:20 AM, maarten wrote:
> > I would keep the db names and/or schema names in your queries.
> >
> > It clarifies what you are doing with the query making it easier for
> > someone else to debug, improve, ...  Certainly for those not familiar
> > with your db structure.
> >
> > I am not aware of any drawbacks that can result from this.  (Ok, maybe
> > your program is a few bytes longer?)
> >
> > regards,
> > Maarten
> >
> > On Sun, 2011-05-22 at 05:27 -0400, ad...@buskirkgraphics.com wrote:
> >> I have been working on a class methods for some time now.
> >>
> >>
> >>
> >> I have reached a cross road when it comes to common practice of developing
> >> query structure.
> >>
> >>
> >>
> >> Long ago I wrote queries where I  just called the field I wanted on a
> >> particular table unless I was joining them.
> >>
> >>
> >>
> >> Example:
> >>
> >> $query = " SELECT id FROM Table WHERE Clause";
> >>
> >>
> >>
> >> Through time I developed a habit of queering as such.
> >>
> >> Example:
> >>
> >> $query = "SELECT tablename.id FROM db.table WHERE clause";
> >>
> >>
> >>
> >>
> >>
> >> I have felt that, because my server contains multiple databases and I 
> >> needed
> >> to jump between databases and tables without changing the connector this
> >> always has been best practice for me.
> >>
> >>
> >>
> >> Someone recently told me,
> >>
> >>  Rich,
> >>
> >> I do not agree with your design of the queries.
> >>
> >> There is no need to include the DB and table name in the query if you are
> >> not joining tables.
> >>
> >>
> >>
> >>
> >>
> >> While I have a very hard time understanding this response as being valid. I
> >> will propose the question.
> >>
> >>
> >>
> >>
> >>
> >> Is it bad practice to write queries with the database and table name in the
> >> queries even if I am NOT joining tables?
> >>
> >> Is there an impact from PHP or MySQL that is caused by doing so?
> >>
> >>
> >>
> >> I know this more a MySQL question but as PHP developers we all deal with
> >> queries on a day to day bases,
> >>
> >> and when developing more flexible class methods I build the queries in the
> >> method.
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> Richard L. Buskirk
> >>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: Where to put submit button with multiple _GET or _POST??

2011-05-23 Thread Geoff Lane
On Monday, May 23, 2011, Fahim Mohammad wrote;

> How to reset  all the options by pressing the reset button once???.
---

Unless I've read your question incorrectly, HTML provides the means
for this with a standard reset button:



or



HTH,

-- 
Geoff


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Query Question

2011-05-23 Thread maarten
I would keep the db names and/or schema names in your queries.

It clarifies what you are doing with the query making it easier for
someone else to debug, improve, ...  Certainly for those not familiar
with your db structure.

I am not aware of any drawbacks that can result from this.  (Ok, maybe
your program is a few bytes longer?)

regards,
Maarten

On Sun, 2011-05-22 at 05:27 -0400, ad...@buskirkgraphics.com wrote:
> I have been working on a class methods for some time now.
> 
>  
> 
> I have reached a cross road when it comes to common practice of developing
> query structure.
> 
>  
> 
> Long ago I wrote queries where I  just called the field I wanted on a
> particular table unless I was joining them.
> 
>  
> 
> Example:
> 
> $query = " SELECT id FROM Table WHERE Clause";   
> 
>  
> 
> Through time I developed a habit of queering as such.
> 
> Example:
> 
> $query = "SELECT tablename.id FROM db.table WHERE clause";
> 
>  
> 
> 
> 
> I have felt that, because my server contains multiple databases and I needed
> to jump between databases and tables without changing the connector this
> always has been best practice for me.
> 
>  
> 
> Someone recently told me,
> 
> Rich, 
> 
> I do not agree with your design of the queries.
> 
> There is no need to include the DB and table name in the query if you are
> not joining tables.
> 
>  
> 
> 
> 
> While I have a very hard time understanding this response as being valid. I
> will propose the question. 
> 
>  
> 
> 
> 
> Is it bad practice to write queries with the database and table name in the
> queries even if I am NOT joining tables?
> 
> Is there an impact from PHP or MySQL that is caused by doing so?
> 
>  
> 
> I know this more a MySQL question but as PHP developers we all deal with
> queries on a day to day bases, 
> 
> and when developing more flexible class methods I build the queries in the
> method.
> 
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Richard L. Buskirk
> 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php