What does this mistake mean?

Fatal error: Trying to get string form class Mainclass in /data/home/htdocs/system/class/mainclass.php on line 46

Tell me, please, I cannot find anything in the internet (This is a class that Mainclass.php uses

 <?php class Order extends BaseClass { public $order_id, $order=array(), $items=array(), $itemFromPage = 99999, $page = 1, $allResult = 0, $debug = false, $child = array(), $childItems = array(), $childItemsCount = 0, $dStatus = 0; private $session = false, $updateItemId=array(), $ot = "orders", $it = "items"; public function __construct($order_id='',$orderType = "order") { $this->setType($orderType); $this->getOrderId($order_id); if(!empty($_SESSION['current_order']['items']) and empty($_SESSION['current_order']['order_id'])) { $this->sessionItemToBase(); unset($_SESSION['current_order']); } $this->getOrder(); } private function getOrderId($order_id) { if(!empty($order_id)) { $this->order_id = $order_id; } elseif(empty($order_id) and !empty($_SESSION['user']['login'])) { $result_db = $this->Mainclass->Db->get_('SELECT `order_id` FROM `'.$this->ot.'` WHERE `user_login` = "' . Func::code($_SESSION['user']['login']) . '" ORDER BY order_date DESC'); echo mysql_error(); if(!empty($result_db)) { if(!empty($result_db) and !empty($result_db['order_id'])) { $this->order_id = $result_db['order_id']; } else $this->getNewOrder(); } } elseif(empty($order_id) and empty($_SESSION['user']['login'])) { $this->session = true; } } public function reCount() { $this->order['summ_0'] = 0; $this->order['items_count'] = 0; if(!empty($this->order) and !empty($this->items)) { foreach($this->items as $d) { if($d['is_warehouse']!=3 and $d['back']!=1) { $this->order['summ_0']+=$d['price'] * $d['count'] + $d['post_price']; $this->order['items_count']+=$d['count']; } } } return array('sum'=>$this->order['summ_0'],'count'=>$this->order['items_count']); } public function setItemCat($item) { if($this->session==false) { $userId = $_SESSION['user']['id']; $data = $this->Mainclass->Db->get_('SELECT * FROM `cart_items` WHERE `user_id`='.$userId.' AND `num_iid`='.Func::code($item['num_iid']).' AND `sku_id`='.Func::code($item['sku_id']),1); if(count($data)>0) $query = $this->Mainclass->Db->update_('UPDATE `cart_items` SET `count`=`count`+'.((int)$item['count']).',`value`=0 WHERE `user_id`='.$userId.' AND `num_iid`='.Func::code($item['num_iid']).' AND `sku_id`='.Func::code($item['sku_id'])); else $query = $this->Mainclass->Db->insert_('INSERT INTO cart_items (user_id,item_id,title,title_ch,num_iid,nick,price,sel_props_val,count,value,sku_id,user_desc,detail_url,order_id,post_price,post_type,img,params_rus,params_ch,city,state) VALUES ("'.$userId.'","' . Func::code($item['item_id']) . '","'.Func::code($item['title']).'","'.Func::code($item['title_ch']).'","' . Func::code($item['num_iid']) . '","' .Func::code($item['nick']) . '","' . Func::code($item['price']) . '","' .Func::code($item['sel_props_val']) . '","' .Func::code($item['count']) . '","' .(!empty($item['value']) ? Func::code($item['value']) : '' ). '","' .Func::code($item['sku_id']) . '","' .(!empty($item['user_desc']) ? Func::code($item['user_desc']) : '' ). '","' .Func::code($item['detail_url']) . '","' . $this->order_id . '","' .Func::code($item['post_price']) . '","' .(!empty($item['post_type']) ? Func::code($item['post_type']) : ''). '","' .Func::code($item['img']) . '","' .Func::code($item['params_rus']) . '","' .Func::code($item['params_ch']) . '","' .Func::code($item['city']) . '","' .Func::code($item['state']) . '")'); if($query) $this->items[] = $item; return $item; } else { $_SESSION['current_order']['items'][] = $item; $this->items[] = $item; } } public function setItemTiImem($item) { if($this->session==false) { $query = $this->Mainclass->Db->insert_('INSERT INTO `items` (item_id,title,title_ch,num_iid,nick,price,sel_props_val,count,value,sku_id,user_desc,detail_url,order_id,post_price,post_type,img,params_rus,params_ch,city,state) VALUES ("' .Func::code($item['item_id']) . '","'.Func::code($item['title']).'","'.Func::code($item['title_ch']).'","' .Func::code($item['num_iid']) . '","' .Func::code($item['nick']) . '","' .Func::code($item['price']) . '","' .Func::code($item['sel_props_val']) . '","' .Func::code($item['count']) . '","' .(!empty($item['value']) ? Func::code($item['value']) : '' ). '","' .Func::code($item['sku_id']) . '","' .(!empty($item['user_desc']) ? Func::code($item['user_desc']) : '' ). '","' .Func::code($item['detail_url']) . '","' . $this->order_id . '","' .v($item['post_price']) . '","' .(!empty($item['post_type']) ? Func::code($item['post_type']) : ''). '","' .Func::code($item['img']) . '","' .Func::code($item['params_rus']) . '","' .Func::code($item['params_ch']) . '","' .Func::code($item['city']) . '","' .Func::code($item['state']) . '")'); if($query) $this->items[] = $item; } else { $_SESSION['current_order']['items'][] = $item; $this->items[] = $item; } } public function getOrder() { if($this->session==true) { if(!empty($_SESSION['current_order'])) $this->order = $_SESSION['current_order']; else $this->order = array(); return; } if(!empty($this->order_id)) { $result = $this->Mainclass->Db->get_("select * from `".$this->ot."` WHERE `order_id`='".$this->order_id."'"); if($result) { //$this->order = mysql_fetch_object($result); $this->order = $result; } } } public function getPageLimit($posts) { $this->allResult = $posts; $total = intval(($posts - 1) / $this->itemFromPage) + 1; $page = intval($this->page); if(empty($this->page) or $this->page < 0) $this->page = 1; if($this->page > $total) $this->page = $total; $start = $this->page * $this->itemFromPage - $this->itemFromPage; return 'LIMIT '.$start.', '.$this->itemFromPage; } public function getOrdeItem() { if($this->session==true) { if(!empty($_SESSION['current_order']['items'])) $this->items=$_SESSION['current_order']['items']; else $this->items = array(); return; } else { $lResult = $this->Mainclass->Db->get_("SELECT `id` FROM `".$this->it."` WHERE `order_id`='".$this->order_id."'"); $sql = $this->Mainclass->Db->get_("SELECT * FROM `".$this->it."` WHERE `order_id`='".$this->order_id."' ORDER BY `id` DESC ".$this->getPageLimit(count($lResult)),1); if($sql) { $this->items[$sql['item_id']]=$sql; } } } public function updateOrder($conv = true) { if($conv) $this->conversion(); if(!empty($this->order)) { if($this->session==true) { $_SESSION['current_order'] = $this->order; $_SESSION['current_order']['items'] = $this->items; } $upd = array(); foreach($this->order as $k=>$d) $upd[]="`".$k."`='".$d."'"; $sql = $this->Mainclass->Db->insert_("UPDATE `".$this->ot."` SET ".implode(",",$upd)." WHERE `order_id`='".$this->order_id."'"); //echo mysql_error(); } } /*Пересчет стоимости веса и количества*/ public function conversion() { if(!empty($this->items) and is_array($this->items)) { $this->order['summ_0']=0; $this->order['weight']=0; $this->order['items_count']=0; foreach ($this->items as $item) { $this->order['weight'] += (empty($item['value']) ? 0 : $item['value']) * $item['count']; if($item['is_warehouse']!=3 and $item['back']!=1) { $this->order['summ_0'] += $item['price']*$item['count']+$item['post_price']; $this->order['items_count'] += $item['count']; } } } } private function generate_rand() { $temp = mt_rand(10000, 999999); $query = $this->Mainclass->Db->get_('SELECT `order_id` FROM `orders` WHERE `order_id`="'.$temp.'"',1); $queryCart = $this->Mainclass->Db->get_('SELECT `order_id` FROM `cart` WHERE `order_id`="'.$temp.'"',1); if(count($query)>0 or count($queryCart)>0) return $this->generate_rand(); else return $temp; } public function getNewOrder() { $user = $_SESSION['user']; if ($user['user_type']==2) return; $this->order_id = $this->generate_rand(); $this->order['order_id'] = $this->order_id; $this->order['order_date'] = date('Ymd [H:i:s]'); $this->order['order_state'] = 10; $this->order['post'] = $user['post']; $this->order['post_deposit'] = $user['post_deposit']; $this->order['moderator_posent'] = $user['moderator_posent']; $this->order['mediator'] = $user['mediator']; $this->order['summ_0'] = 0; $this->order['summ_rate'] = 0; $this->order['summ_1'] = 0; $this->order['summ_all'] = 0; $this->order['summ_fact'] = 0; $this->order['user_login'] = $user['login']; $this->order['address_id'] = ''; $this->order['pay_type'] = ''; $result_db = $this->Mainclass->Db->get_("SELECT `user_login` FROM `mediators` ORDER BY rating DESC",1); if ($result_db!=false) { $this->order['mediator'] = $result_db['user_login']; } $sql = $this->Mainclass->Db->insert_("INSERT INTO `".$this->ot."` (`".implode("`,`",array_keys($this->order))."`) VALUES ('".implode("','",array_values($this->order))."')"); echo mysql_error(); } public function toTempCart($idArr) { if(empty($idArr) or !is_array($idArr) or $this->session==true) return false; $idStr = implode(",",$idArr); $this->Mainclass->Db->insert_("INSERT INTO `cart_tmp` (`user`,`num_iid`,`title`,`title_ch`,`nick`,`price`,`sel_props_val`,`count`,`value`,`sku_id`,`user_desc`,`detail_url`,`order_id`,`item_id`,`post_price`,`post_type`,`img`,`params_rus`,`params_ch`,`city`,`state`, `ordered_time`) SELECT `ord`.`user_login`,`it`.`num_iid`,`it`.`title`,`it`.`title_ch`,`it`.`nick`,`it`.`price`,`it`.`sel_props_val`,`it`.`count`,`it`.`value`,`it`.`sku_id`,`it`.`user_desc`,`it`.`detail_url`,`it`.`order_id`,`it`.`item_id`,`it`.`post_price`,`it`.`post_type`,`it`.`img`,`it`.`params_rus`,`it`.`params_ch`,`it`.`city`,`it`.`state`,`it`.`ordered_time` FROM `cart_items` as `it`,`cart` as `ord` WHERE `ord`.`order_id`='".$this->order_id."' AND `it`.`order_id`=`ord`.`order_id` AND `it`.`item_id` NOT IN (".$idStr.")"); $this->Mainclass->Db->delete_("DELETE FROM `cart_items` WHERE `cart_items`.`order_id`='".$this->order_id."' AND `cart_items`.`item_id` NOT IN (".$idStr.")"); $this->updateOrder(); } public function toItemsTable() { $order = $this->Mainclass->Db->get_("SELECT `user_login` FROM `cart` WHERE `order_id`=".$this->order_id); if(empty($order)) return false; $this->Mainclass->Db->update_("UPDATE `cart_tmp` SET `order_id`='".$this->order_id."' WHERE `user`='".$order['user_login']."'"); $record = $this->Mainclass->Db->insert_("INSERT INTO `cart_items` (`num_iid`,`title`,`title_ch`,`nick`,`price`,`sel_props_val`,`count`,`value`,`sku_id`,`user_desc`,`detail_url`,`order_id`,`item_id`,`post_price`,`post_type`,`img`,`params_rus`,`params_ch`,`city`,`state`,`ordered_time`) SELECT `num_iid`,`title`,`title_ch`,`nick`,`price`,`sel_props_val`,`count`,`value`,`sku_id`,`user_desc`,`detail_url`,`order_id`,`item_id`,`post_price`,`post_type`,`img`,`params_rus`,`params_ch`,`city`,`state`,`ordered_time` FROM `cart_tmp` WHERE `user`='".$order['user_login']."'"); $this->Mainclass->Db->delete_("DELETE FROM `cart_tmp` WHERE `user`='".$order['user_login']."'"); $this->updateOrder(); return $record; } public function deleteItemsFromArr($idArr) { if(is_array($_SESSION['user'])) { foreach($idArr as $itd) unset($this->items[$itd]); $idStr = implode(",",$idArr); $this->Mainclass->Db->delete_("DELETE FROM `cart_items` WHERE `order_id`='".$this->order_id."' AND `item_id` IN (".$idStr.")"); $this->order['items_count'] = count($this->items); $this->updateOrder(); } else foreach($_SESSION['current_order']['items'] as $k=>$d) if (in_array($d['item_id'], $idArr)) unset($_SESSION['current_order']['items'][$k]); } private function sessionItemToBase() { if($_SESSION['user']['user_type']>1) return false; if(!empty($this->order_id)) { foreach($_SESSION['current_order']['items'] as $d) { $this->setItemCat($d); } unset($_SESSION['current_order']['items']); } } public function updateItemParam($id,$param) { if(!empty($this->items[$id]) and !empty($param) and is_array($param)) { foreach($param as $k=>$d) { if(isset($this->items[$id][$k])) { $this->items[$id][$k] = $d; if(!in_array($id,$this->updateItemId)) $this->updateItemId[] = $id; } } } } public function updateItems() { if(!empty($this->items) and !empty($this->updateItemId)) { foreach($this->updateItemId as $kid=>$itId) { if(!empty($this->items[$itId])) { $upd = array(); foreach($this->items[$itId] as $k=>$d) { if($k!="id") $upd[]="`".$k."`='".Func::code($d)."'"; } // print_r($upd); $sql = $this->Mainclass->Db->update_("UPDATE `".$this->it."` SET ".implode(",",$upd)." WHERE `item_id`='".$itId."'"); echo mysql_error(); unset($upd); unset($this->updateItemId[$kid]); } } } } /* Array ( [checkbox] => 1 //Двойная коробка [checkbox2] => 0 //Полная обмотка коробки скотчем [checkbox3] => 1 //Пластиковые стяжки [checkbox5] => 1 //Обмотка каждого товара пузырчатой плёнкой [checkbox4] => 5000 //Страховка посылки ) */ public function parseUslugi($usl = array()) { $tempUsl = !empty($usl) ? $usl : $this->order['uslugi']; $tUslArr = array(); if(!empty($tempUsl)) { $uslArr = explode("|",$tempUsl); $tUslArr['summ'] = 0; foreach($uslArr as $d) { list($key,$dat) = explode(":",$d); switch($key) { case "checkbox": $sum = 320; break; case "checkbox2": $sum = 320; break; case "checkbox3": $sum = 150; break; case "checkbox4": $sum = (int)$dat; break; case "checkbox5": $sum = $this->countPl($dat,20); break; case "checkbox6": $sum = 120; break; case "checkbox7": $sum = $this->countPl($dat,100); break; } if(!empty($dat)) { $tUslArr[$key] = $sum; $tUslArr['summ']+=$sum; } } } return $tUslArr; } public function countPl($data,$stoim) { $datAyy = explode(";",$data); $dataResult = $this->Mainclass->Db->get_("SELECT SUM(`count`) as `cou` FROM `".$this->it."` WHERE ".($this->it=='items' ? "`back`=0 and " : "" )." `item_id` IN (".implode(",",$datAyy).")",1); $sum_pl = 0; if($dataResult) { $sum_pl=$dataResult['cou']*$stoim; } return $sum_pl; } public function setType($type) { if(!empty($type)) { switch($type) { case "order": { $this->ot="orders"; $this->it="items"; break; } case "cart": { $this->ot="cart"; $this->it="cart_items"; break; } } } } public function cartToOrder() { $this->Mainclass->Db->insert_("INSERT INTO `items` (`num_iid`,`title`,`title_ch`,`nick`,`price`,`sel_props_val`,`count`,`value`,`sku_id`,`user_desc`,`detail_url`,`order_id`,`item_id`,`post_price`,`post_type`,`img`,`params_rus`,`params_ch`,`city`,`state`,`ordered_time`) SELECT `num_iid`,`title`,`title_ch`,`nick`,`price`,`sel_props_val`,`count`,`value`,`sku_id`,`user_desc`,`detail_url`,`order_id`,`item_id`,`post_price`,`post_type`,`img`,`params_rus`,`params_ch`,`city`,`state`,`ordered_time` FROM `cart_items` WHERE `order_id`='".$this->order_id."'"); $this->Mainclass->Db->insert_("INSERT INTO `orders` (`order_id`,`to_order`,`parent_order`,`order_state`,`order_date`,`puti_date`,`user_login`,`post_deposit`,`moderator_posent`,`mediator`,`post`,`state`,`sum_cur`,`summ_0`,`summ_1`,`summ_rate`,`summ_all`,`summ_fact`,`weight`,`items_count`,`post_price`,`post_price_rate`,`mediator_price`,`address_id`,`pay_type`,`order_comments`,`type_fact`,`reorder`,`uslugi`) SELECT `order_id`,`to_order`,`parent_order`,`order_state`,`order_date`,`puti_date`,`user_login`,`post_deposit`,`moderator_posent`,`mediator`,`post`,`state`,`sum_cur`,`summ_0`,`summ_1`,`summ_rate`,`summ_all`,`summ_fact`,`weight`,`items_count`,`post_price`,`post_price_rate`,`mediator_price`,`address_id`,`pay_type`,`order_comments`,`type_fact`,`reorder`,`uslugi` FROM `cart` WHERE `order_id`='".$this->order_id."'"); $this->Mainclass->Db->delete_("DELETE FROM `cart` WHERE `order_id` = '".$this->order_id."'"); $this->Mainclass->Db->delete_("DELETE FROM `cart_items` WHERE `order_id` = '".$this->order_id."'"); echo mysql_error(); $this->setType("order"); } public function getOrderStatus() { if(!empty($this->order['order_id'])) { if(empty($this->items)) { $result = $this->Mainclass->Db->get_('SELECT `is_warehouse` as `status`,COUNT(*) as `count` FROM `items` WHERE `order_id`='.$this->order['order_id'].' GROUP BY `is_warehouse`',1); $status = $result; $dopl = $this->Mainclass->Db->get_('SELECT COUNT(*) as `count` FROM `items` WHERE `order_id`='.$this->order['order_id'].' and `back`=0 and `new_price`>0 and `is_pay`=0 GROUP BY `is_warehouse`'); } else { $status_temp = array('0'=>0,'1'=>0,'2'=>0,'3'=>0); $status = array(); $dopl = array('count'=>0); foreach($this->items as $d) { $status_temp[$d['is_warehouse']]+=1; if($d['back']!=1 and $d['new_price']>0 and $d['is_pay']==0) $dopl['count']+=1; } foreach($status_temp as $k=>$d) { $status[] = array( 'status'=>$k, 'count'=>$d, ); } } if(!empty($status)) { $data = array( '0'=>0, '1'=>0, '2'=>0, '3'=>0, 'is_pay3'=>(int)$this->order['is_pay3'], 'is_pay1'=>(int)$this->order['is_pay1'], 'post_price_fact'=>(int)$this->order['post_price_fact'], 'doplata'=>(int)$dopl['count'], 'post_code'=>!empty($this->order['post_code']) ? 1 : 0, ); foreach($status as $k=>$d) { $data[$d['status']] = (int)$d['count']; } return $this->parseStatus($data); } } } private function parseStatus($data) { /*if($this->debug) { echo "<pre>".print_r($data,1)."</pre>"; }*/ $secssus = 0; $status = array( '1'=> array( '0'=>'>', '1'=>'x', '2'=>'x', '3'=>'x', 'is_pay1'=>'1', 'is_pay3'=>'0', 'post_price_fact'=>'0', 'doplata'=>'0', 'post_code'=>'0' ),//В обработке '2'=> array( '0'=>'0', '1'=>'>', '2'=>'x', '3'=>'x', 'is_pay1'=>'1', 'is_pay3'=>'0', 'post_price_fact'=>'0', 'doplata'=>'0', 'post_code'=>'0' ),//На склад '3'=> array( '0'=>'0', '1'=>'0', '2'=>'>', '3'=>'x', 'is_pay1'=>'1', 'is_pay3'=>'x', 'post_price_fact'=>'>|0', 'doplata'=>'0', 'post_code'=>'0' ),//Нужно взвешать '-1'=> array( '0'=>'0', '1'=>'0', '2'=>'0', '3'=>'>', 'is_pay1'=>'1', 'is_pay3'=>'x', 'post_price_fact'=>'x', 'doplata'=>'x', 'post_code'=>'0' ),//Нет в наличии '4'=> array( '0'=>'x', '1'=>'x', '2'=>'x', '3'=>'x', 'is_pay1'=>'1', 'is_pay3'=>'x', 'post_price_fact'=>'x', 'doplata'=>'x', 'post_code'=>'1' ), '5'=> array( '0'=>'0', '1'=>'0', '2'=>'x', '3'=>'x', 'is_pay1'=>'1', 'is_pay3'=>'0', 'post_price_fact'=>'>', 'doplata'=>'0', 'post_code'=>'0' ), '6'=> array( '0'=>'x', '1'=>'x', '2'=>'x', '3'=>'x', 'is_pay1'=>'1', 'is_pay3'=>'0', 'post_price_fact'=>'x', 'doplata'=>'>', 'post_code'=>'0' ), //Доплата за товар ); foreach($status as $k=>$d) { $statusS = true; foreach($d as $sk=>$sd) { switch($sd) { case '>|0': { $ts1 = true; $ts2 = true; if(empty($data[$sk]) or $data[$sk]<0) $ts1=false; if(!empty($data[$sk])) $ts2=false; if(empty($ts1) and empty($ts2)) $statusS=false; break; } case '0': { if(!empty($data[$sk])) $statusS=false; break; } case '1': { if(empty($data[$sk])) $statusS=false; break; } case '>': { if(empty($data[$sk]) or $data[$sk]<0) $statusS=false; break; } } } /*if($this->debug) { echo $k." ".($statusS ? 1 : 0)."<bR>"; }*/ if($statusS == true) { $secssus = $k; //break; } } return $secssus; } public function getChild($state = 60) { if(empty($this->order['order_id'])) return false; $sql = $this->Mainclass->Db->get_("SELECT * FROM `orders` WHERE `to_order`=".$this->order['order_id']." AND `order_state`='".$state."'",1); $this->child = $sql; } public function getChildItem() { $order_id = array(); if(!empty($this->child)) { foreach($this->child as $d) $order_id[] = $d['order_id']; $sql = $this->Mainclass->Db->get_('SELECT * FROM `items` WHERE `order_id` IN ('.implode(',',$order_id).') ORDER BY nick',1); foreach($sql as $k=>$d) { $this->childItems[$sql['order_id']][] = $d; $this->childItemsCount++; } } else return false; } public function detectStatus() { $new_status = true; $this->dStatus = $this->order['admin_status']; if(!empty($this->child)) { foreach($this->child as $childData) { if(!$new_status) continue; if($this->dStatus!=4 AND $this->dStatus!=5 AND $this->dStatus!=2) switch($childData['admin_status']) { case "0": case "1": case "2": case "3": case "5": case "6": { $this->dStatus=$childData['admin_status']; $new_status = false; break; } } } } } } ?> 
  • The problem is in mainclass.php, discard line 46 from there. - Shevsky
  • No, the problem is not in mainclass.php, but in its use in another class, it does not work out because a fatal error of this kind, I just do not understand what it means. - ikirab1
  • > Fatal error: Trying to get a string form class Mainclass in // exactly form or from ??? Error themselves wrote or skopipasti? The code in the studio! Line 46, and better lay out the whole class somewhere. - Artem
  • in general, line 46 looks like this: function __toString () {trigger_error ('Trying to get string form form'. get_class ($ this), E_USER_ERROR); return ''; } - ikirab1
  • The class in which the error is posted in the question - ikirab1

1 answer 1

Thank you for responding, I found an error, it was a standard class error, it says that I am trying to use the class as a string)