Bug #75110 [Opn->Nab]: Dont iterate foreach

From: Date: Wed, 23 Aug 2017 18:29:15 +0000
Subject: Bug #75110 [Opn->Nab]: Dont iterate foreach
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210785@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75110&edit=1

 ID:                 75110
 Updated by:         subjective@php.net
 Reported by:        porfi_miramontes at hotmail dot com
 Summary:            Dont iterate foreach
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   ubuntu16.04.1
 PHP Version:        7.0Git-2017-08-23 (snap)
 Block user comment: N
 Private report:     N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:
------------------------------------------------------------------------
[2017-08-23 18:14:03] subjective@php.net

You do not access the actual fields, but the record array/object. Here is no automatic conversion of
an array/object to CSV, look up fputcsv().

------------------------------------------------------------------------
[2017-08-23 18:05:46] porfi_miramontes at hotmail dot com

Description:
------------
Dont print values from array obtained from database use foreach loop

Test script:
---------------
<?php
try {
 	$base=new
PDO('mysql:host=localhost;dbname=mydatabase','root','12345678');
 	$base->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
 	$base->exec("SET CHARACTER SET UTF8");

 	$reg=$base->query("SELECT * FROM articles WHERE client='Myclient' ORDER BY
article_state desc limit 1,2")->fetchAll(PDO::FETCH_OBJ);
	foreach($reg as $articles=>$value)
        {

	 echo $value;
 
         }

     } 

 catch (Exception $e) 
 {
 	die ("Error ".$e->getMessage());
 	echo "Line error : ".$e->getLine();

 }








?>

Expected result:
----------------
Myarticle1,Desc1,Desc2
Myarticle2,Desc1,Desc2
Myarticle3,Desc1,Desc2
.
.
.
.
.
.




------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75110&edit=1


Thread (3 messages)

« previous php.bugs (#210785) next »