[PHP-DB] mysql_fetch_object
I'm using $row = mysql_fetch_object and I can reference column names by $row-name but how do I reference a pseudo column (that I make, like substring( name from 1 ))? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_object
I'm using $row = mysql_fetch_object and I can reference column names by $row-name but how do I reference a pseudo column (that I make, like substring( name from 1 ))? Use an alias in your query: SELECT column, DATE_FORMAT('%m', date_column) AS d FROM table ... $row-d Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_object
On 06/28/2004 12:07 PM Larry E.Ullman spoke: I'm using $row = mysql_fetch_object and I can reference column names by $row-name but how do I reference a pseudo column (that I make, like substring( name from 1 ))? Use an alias in your query: SELECT column, DATE_FORMAT('%m', date_column) AS d FROM table ... $row-d Larry Great, thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_object
On 06/28/2004 12:07 PM Larry E.Ullman spoke: I'm using $row = mysql_fetch_object and I can reference column names by $row-name but how do I reference a pseudo column (that I make, like substring( name from 1 ))? Use an alias in your query: SELECT column, DATE_FORMAT('%m', date_column) AS d FROM table ... $row-d Larry How does it handle fully qualified conflicting columns, like 'select a.name, b.name from a, b'? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_object
Bob Lockie wrote: On 06/28/2004 12:07 PM Larry E.Ullman spoke: I'm using $row = mysql_fetch_object and I can reference column names by $row-name but how do I reference a pseudo column (that I make, like substring( name from 1 ))? Use an alias in your query: SELECT column, DATE_FORMAT('%m', date_column) AS d FROM table ... $row-d Larry How does it handle fully qualified conflicting columns, like 'select a.name, b.name from a, b'? It won't handle that properly; in your example $row-name would be b.name (it'd overwrite a.name). You have to alias same-named columns. Hans -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_object
How does it handle fully qualified conflicting columns, like 'select a.name, b.name from a, b'? It won't handle that properly; in your example $row-name would be b.name (it'd overwrite a.name). You have to alias same-named columns. Hans Ok, I don't have that case but I was curious. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql_fetch_object() with MYSQL_NUM or MYSQL_BOTH
hello ! mysql_fetch_object() is like mysql_fetch_array() but it returns an object and not an array. so you can access field through this syntax : $obj-fieldname (i.e $obj-amount) you can provide a second parameter to this function : MYSQL_ASSOC, MYSQL_NUM or MYSQL_BOTH. if you use MYSQL_NUM or MYSQL_BOTH, you should be able to access fields through the column number... but how since in an PHP object a variable could not begin by a numerical character (i.e $obj-0, $obj-1... is forbidden) ? if you use get_object_vars($obj) and print the object's properties, you could see this for example (MYSQL_BOTH used) : 0 = 'titi' columnName1 = 'titi' 1 = 2 columnName2 = 2 so here $obj-columnName1 returns 'titi' and $obj-columnName2 returns 2 but if i want to use numerical entries how to keep the object access behavior like $obj-... ? is it possible ? if not we should use a loop with get_object_vars($obj) ? nothing more simple and beautiful ? thanks for your feeebacks. regards, rashkatsa -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]