| << $pdf->Cellで1文字ずれてしまいます | 質問一覧 | ini_set() の影響範囲と有効期限を教... >> |
- キーワードが設定されていません
- 0P
Mysqlの実行コードが無限ループしてしまう。
- 0P
- class config{
- public function connection_to_mysql ($ret = true, $port = '3306') {
- $connection = mysql_connect($this->database['IP'] . ':' . $port, $this->database['HOST'], $this->database['PASSWORD']) or die (mysql_error());
- mysql_select_db($this->database['NAME'], $connection) or die (mysql_error());
- mysql_query('SET NAMES UTF8');
- if ($ret == true) {
- return $connection;
- }
- }
- public function mysql_attach_basic ($first, $table, $where, $set = '', $objecting = false, $limit = 1) {
- $self = '';
- $first = strtoupper($first);
- switch ($first) {
- case 'SELECT':
- case 'DELETE':
- $usewhere = '';
- $asterisk = '';
- if ( $where != '' ) {
- $usewhere = 'WHERE ';
- }
- if ( $first == 'SELECT' ) {
- $asterisk = ' * ';
- }
- $self = $first . $asterisk . ' FROM `' . $table . '` ' . $usewhere . $where;
- break;
- case 'INSERT':
- $self = $first . $asterisk . ' INTO `' . $table . '` (' . $where . ') VALUES (' . $set . ')';
- break;
- case 'UPDATE':
- $add = '';
- $usewhere = '';
- if ( $where != '' ) {
- $usewhere = 'WHERE ';
- }
- if ( $set != '' ) {
- $add = 'SET ' . $set;
- }
- $self = $first . ' ' . $add . '`' . $table . '` ' . $usewhere . $where;
- break;
- }
- $query = $this->mysql_attach_escape($self);
- $db = mysql_query($query, $this->connection_to_mysql());
- if ( $objecting == true ) {
- $db = mysql_fetch_object($db);
- }
- $this->mysql_attach_action($con = null, $query = null);
- return $db;
- }
- private function mysql_attach_escape($query) {
- $query = preg_replace('/"(.*?)"/', '"' . mysql_real_escape_string('$1', $this->connection_to_mysql()) . '"', $query);
- $query = preg_replace("/'(.*?)'/", '"' . mysql_real_escape_string('$1', $this->connection_to_mysql()) . '"', $query);
- return $query;
- }
- private function mysql_attach_action($con = null, $query = null) {
- if ($con != null) {
- if ($query != null) {
- @mysql_free_result($query);
- }
- @mysql_close($con);
- }
- }
- }
というコードで、使用方法は、
- $config = new config();
- $config->init();
- $a = $config->mysql_attach_basic('SELECT', 'accounts', '', '', true);
- while ($b = $a) {
- }
以前のプログラムもこんな感じに書いたのですが、それは実行できています。
相違点がまったくもって分かりません。
以前のプログラム
- class server_system {
- function attach_mysql() {
- $connect = mysql_connect($this->ip, $this->database_id, $this->database_password);
- mysql_select_db($this->database_name, $connect);
- mysql_query('SET NAMES UTF8');
- return $connect;
- }
- function attach_mysql_query_escape($query) {
- $query = preg_replace('/"(.*?)"/', '"' . mysql_real_escape_string('$1') . '"', $query);
- $query = preg_replace("/'(.*?)'/", '"' . mysql_real_escape_string('$1') . '"', $query);
- return $query;
- }
- function attach_mysql_query($query, $unreturn = false) {
- $connect = $this->attach_mysql();
- if ($unreturn == false) {
- $set = mysql_query($this->attach_mysql_query_escape($query), $connect) or die($this->debug(mysql_error(), 1));
- } else {
- mysql_query($this->attach_mysql_query_escape($query), $connect) or die($this->debug(mysql_error(), 1));
- }
- $this->attach_mysql_action($connect);
- if ($unreturn == false) {
- return $set;
- }
- }
- function attach_mysql_action($con = null, $query = null) {
- if ($con != null) {
- if ($query != null) {
- @mysql_free_result($query);
- }
- @mysql_close($con);
- }
- }
- }
Mysqlの実行コードが無限ループしてしまう。 memory [02月06日 01時18分] | $pdf->Cellで1文字ずれてしまいます | 質問一覧 | ini_set() の影響範囲と有効期限を教... |





