postgresqlとphpでアプリを作っているのですが、クラス内に定義した関数が
Fatal error: Uncaught Error: Call to undefined function
となってしまいます。
php
1<?php 2 2 class pgModel{ 3 3 4 4 public function select(){ 5 5 try { 6 6 // ローカルのデータベース「sample」に 7 7 // ユーザー名「pgadmin」、パスワード「password」で接続 8 8 $db = new PDO ('pgsql:dbname=hoge;host=localhost;port=5432', 'postgres', 'hogehogehoge'); 9 9 10 10 11 11 $sql = 'select * from testm'; 12 12 foreach ($db->query($sql) as $row) { 13 13 14 14 15 15 16 16 array_push($arr ,convert_enc($row['key'])); 17 17 array_push($arr ,convert_enc($row['animal'])); 18 18 19 19 return $arr; 20 20 21 21 } 22 22 23 23 // 切断 24 24 unset($db); 25 25 } catch (PDOException $e) { 26 26 echo $e->getMessage(); 27 27 } 28 28 29 29 30 30 } 31 31 public function convert_enc($str){ 32 32 $from_enc = 'EUC_JP'; 33 33 $to_enc = 'SJIS'; 34 34 35 35 return mb_convert_encoding($str, $to_enc, $from_enc); 36 36 } 37 37 }
convert_enc()をselect()から呼ぶにはどうすればよいでしょうか。
回答1件
あなたの回答
tips
プレビュー