The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PDO newbie loop question
#1
Hi
i'm totally new with PDO but i'm thinking it might be good to reuse the userspice connection. so if anyone could give a hint in how i loop out the data i got with below query i would be grateful.

Code:
$clist = DB::getInstance()->query("SELECT * FROM company")
Code:
echo $clist->count()
works just fine but i cant figure out how get that to a foreach or while loop...
Code:
foreach ($clist as $row) {echo $row["xyz"];}
does not work...
  Reply
#2
update:
I found this so i'm up and running
Code:
$x = $query->results();
but i'm still having trouble with swedish umlauts like åäö, i think something like this need to go into db.php:
Code:
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")
on line 31.

I also could not find any way of editing my first post so i had to reply to my own post...
  Reply
#3
I will definitely tinker with that. That makes sense to me.
  Reply
#4
if i replace
Code:
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET SESSION sql_mode = ''"));
with
Code:
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")
you get UTF-8 to work, but i suppose the first one need to be there too Smile
  Reply
#5
Get all the classes from 3.2 or 4.1 and copy them into the models folder.

Then edit the config.php file in the models folder and after
require_once("funcs.php");

Add these lines...
require_once("classes/Config.php");
require_once("classes/Cookie.php");
require_once("classes/DB.php");
require_once("classes/Hash.php");
require_once("classes/Input.php");
require_once("classes/Redirect.php");
require_once("classes/Session.php");
require_once("classes/Token.php");
require_once("classes/Validate.php");

Primarily you'll want to use the db class and the input class. You may want to implement the token class.

Just to be sure...if you want to TRY to install 3.2 on your server to see if it works, you can go into the install/install.php file and delete lines 58-64 of the install file and see if it works. It's 50/50 if it will, but it might be worth a 5 minute test.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)