Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //class Database
- class Database
- {
- private $username;
- private $pass;
- private $server;
- private $database;
- public function __construct(){
- $this->username='root';
- $this->pass='';
- $this->server='localhost';
- $this->database='op_db';
- $this->initial_db();
- }
- public function initial_db(){
- $con = mysql_connect($this->server, $this->username, $this->pass) or die( 'unable to connect to database');
- $db=mysql_select_db($this->database, $con);
- if(!$db)
- die('unable to selct db');
- }
- public function insert($row){
- for($i=0;$i<count($row);$i++){
- $status = 2;
- $remoteAddr = 0;
- $query = "INSERT INTO tbl_item_events SET publish_date = '".date("Y-m-d H:i:s")."', approved_date = '".date("Y-m-d H:i:s")."', user_id = '300'";
- $query.= ", creation_date='".date("Y-m-d H:i:s")."', status= '".$status."', ip_address ='".$remoteAddr."'";
- foreach($row[$i] as $key => $value)
- {
- $query.=", ".$key."='".$value."' ";
- }
- if($this->avoid_redundace($row[$i]['title'],$row[$i]['description'],$row[$i]['address'],$row[$i]['expire_date'],$row[$i]['item_birth_date']))
- $result= mysql_query($query);
- // $item_id = mysqli_insert_id($con);
- //$insertCatTable = "insert into item_categories_business(`item_id`,`category_id`,`p1`,`p2`,`p3`,`itemLat`,`itemLon`) values(".$item_id.",".$item_category.",".$p1.",".$p2.",".$p3.",".$item_lat.",".$item_lon." )";
- // mysqli_query($con, $insertCatTable);
- }
- }
- public function avoid_redundace($title,$des,$add,$exp,$birth){
- $query='SELECT title FROM tbl_item_events WHERE title="'.$title.'"'; //AND description="'.$des.'" AND address="'.$add.'" AND expire_date="'.$exp.'" AND item_birth_date="'.$birth.'"';
- $result= mysql_query($query);
- $count=mysql_fetch_array($result);
- if(mysql_num_rows($count)>0)
- return FALSE;
- return TRUE;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement