insert() публичный Метод

插入记录
public insert ( mixed $data, array $options = [] ) : false | integer
$data mixed 数据
$options array 参数表达式
Результат false | integer | integer
Пример #1
0
 public function save()
 {
     $query = "INSERT INTO miembros values (null,'" . $this->getNombre() . "',null,'" . $this->getEmail() . "')";
     $conn = new Db("localhost", "root", "benjamin13");
     $conn->connect();
     $conn->insert($query, "conquistadores");
 }
Пример #2
0
	/**
	 * 新增访客
	 *
	 * @param $param 添加信息数组
	 * @return 返回结果
	 */
	public function visitorAdd($param){
		if (empty($param)){
			return false;
		}
		$result = Db::insert('sns_visitor',$param);
		return $result;
	}
Пример #3
0
 public function createName()
 {
     $Verify = new Verify();
     $first = trim(strip_tags($_POST['first']));
     $middle = trim(strip_tags($_POST['middle']));
     $last = trim(strip_tags($_POST['last']));
     if (!$Verify->length($first, 255)) {
         $_SESSION['alert'] = 'Your first name is too long to store in the database.';
     } elseif (!$Verify->length($middle, 255)) {
         $_SESSION['alert'] = 'Your middle name is too long to store in the database.';
     } elseif (!$Verify->length($last, 255)) {
         $_SESSION['alert'] = 'Your last name is too long to store in the database.';
     } else {
         $Db = new Db();
         $query = $Db->query('user_name', array(array('user_id', '=', $_SESSION['user'], '')));
         $numrows = mysqli_num_rows($query);
         if ($numrows > 0) {
             $_SESSION['alert'] = 'Error, please try again.';
         } else {
             $insert = $Db->insert('user_name', array('', $_SESSION['user'], $first, $middle, $last));
             if (!$insert) {
                 $_SESSION['alert'] = 'The name could not be entered in the database.';
             } else {
                 $_SESSION['alert'] = 'Your name has successfully been entered.';
             }
         }
     }
 }
Пример #4
0
 /**
  * @return integer
  */
 public function put()
 {
     if (null === $this->identifier) {
         throw new Exception('Identifier not found.');
     }
     $fields = array();
     $update = $this->properties[$this->identifier]->has();
     $return = 0;
     foreach ($this->properties as $name => $instance) {
         if (!is_subclass_of($instance, 'Property')) {
             continue;
         }
         if ($instance instanceof PropertyIdentifier) {
             continue;
         }
         $fields[$name] = $instance->get();
     }
     if ($update) {
         $return = $affected = $this->db->update($this->table, $fields, array($this->identifier => $this->properties[$this->identifier]->get()));
     } else {
         $return = $inserted = $this->db->insert($this->table, $fields);
         if ($inserted) {
             $this->properties[$this->identifier]->set($inserted);
         }
     }
     $this->hash = Model::hash($this->properties);
     return $return;
 }
Пример #5
0
 public function insertNews($url, $find_elm, $date)
 {
     $db = new Db();
     $content = file_get_html($url);
     foreach ($content->find($find_elm) as $news) {
         if (!empty($news)) {
             $db->insert('news', array('title' => $news->plaintext, 'date' => $date, 'last_update' => date('Y-m-d'), 'news_type' => static::$newsType));
         }
     }
     $settings = $db->query('SELECT * FROM settings WHERE news_type="' . static::$newsType . '"');
     if (!is_array($settings)) {
         $db->insert('settings', array('news_type' => static::$newsType, 'last_update' => date('Y-m-d')));
     } else {
         $db->update('settings', array('last_update' => date('Y-m-d')), array('news_type' => static::$newsType));
     }
 }
Пример #6
0
 public function add_coupon($param)
 {
     if (!empty($param)) {
         return Db::insert('coupon', $param);
     }
     return false;
 }
Пример #7
0
 /**
  * Example of an Endpoint
  */
 protected function games($_args)
 {
     // var_dump($this->method);
     // var_dump($this->endpoint);
     // var_dump($this->verb);
     // var_dump($this->args);
     // var_dump($this->file);
     // var_dump($this->request);
     $db = new Db();
     if ($this->method == 'GET') {
         // /games/id
         if (count($this->args)) {
             return $this->_response($db->select($this->endpoint, $this->args[0]));
             // /games/search?name=value
         } elseif ($this->verb === "search") {
             return $this->_response($db->search($this->endpoint, $this->request));
             // /games/
         } else {
             return $this->_response($db->select($this->endpoint));
         }
         // /games/?name=value1&description=value2
     } elseif ($this->method == 'POST') {
         return $this->_response($db->insert($this->endpoint, $this->request));
     } elseif ($this->method == 'PUT') {
         return $this->_response("UPDATE method not found", 404);
     } elseif ($this->method == 'DELETE') {
         return $this->_response("DELETE method not found", 404);
     } else {
         return $this->_response("Request error ", 500);
     }
 }
Пример #8
0
 public static function add($post_id)
 {
     $post = Input::post(array('name', 'email', 'text'));
     $errors = array();
     if (empty($post['name'])) {
         $errors[] = 'Please enter your name';
     }
     if (filter_var($post['email'], FILTER_VALIDATE_EMAIL) === false) {
         $errors[] = 'Please enter a valid email address';
     }
     if (empty($post['text'])) {
         $errors[] = 'Please enter your comments';
     }
     if (count($errors)) {
         Notifications::set('error', $errors);
         return false;
     }
     $post['date'] = time();
     $post['status'] = Config::get('metadata.auto_published_comments', 0) ? 'published' : 'pending';
     $post['post'] = $post_id;
     // encode any html
     $post['text'] = Html::encode($post['text']);
     Db::insert('comments', $post);
     Notifications::set('success', 'Your comment has been sent');
     return true;
 }
Пример #9
0
 /**
  * 商品保存
  *
  * @param	array $param 商品资料
  */
 public function saveGoods($param)
 {
     if (empty($param)) {
         return false;
     }
     $goods_array = array();
     $goods_array['goods_name'] = $param['goods_name'];
     $goods_array['gc_id'] = $param['gc_id'];
     $goods_array['gc_name'] = $param['gc_name'];
     $goods_array['member_id'] = $_SESSION['member_id'];
     $goods_array['member_name'] = $_SESSION['member_name'];
     $goods_array['goods_image'] = $param['goods_image'];
     $goods_array['flea_quality'] = $param['flea_quality'];
     $goods_array['flea_area_id'] = $param['flea_area_id'];
     $goods_array['flea_area_name'] = $param['flea_area_name'];
     $goods_array['flea_pname'] = $param['flea_pname'];
     $goods_array['flea_pphone'] = $param['flea_pphone'];
     $goods_array['goods_tag'] = $param['goods_tag'];
     $goods_array['goods_price'] = $param['goods_price'];
     $goods_array['goods_store_price'] = $param['goods_store_price'];
     $goods_array['goods_show'] = $param['goods_show'];
     $goods_array['goods_commend'] = $param['goods_commend'];
     $goods_array['goods_add_time'] = time();
     $goods_array['goods_body'] = $param['goods_body'];
     $goods_array['goods_keywords'] = $param['goods_keywords'];
     $goods_array['goods_description'] = $param['goods_description'];
     $result = Db::insert('flea', $goods_array);
     return $result;
 }
Пример #10
0
 public function insert()
 {
     if (isset($this->values['id'])) {
         return false;
     }
     return Db::insert($this->table, $this->values);
 }
Пример #11
0
 /**
  * 新增评论
  *
  * @param $param 添加信息数组
  * @return 返回结果
  */
 public function commentAdd($param)
 {
     if (empty($param)) {
         return false;
     }
     //处理文本中@信息
     if ($param['comment_content']) {
         preg_match_all("/@(.+?)([\\s|:]|\$)/is", $param['comment_content'], $matches);
         if (!empty($matches[1])) {
             //查询会员信息
             $member_model = Model('member');
             $member_list = $member_model->getMemberList(array('member_name' => array('in' => $matches[1])));
             foreach ($member_list as $k => $v) {
                 $param['comment_content'] = preg_replace("/@(" . $v['member_name'] . ")([\\s|:]|\$)/is", '<a href=\\"index.php?act=member_snsindex\\">@${1}</a>${2}', $param['comment_content']);
             }
         }
         unset($matches);
     }
     if (is_array($param)) {
         $result = Db::insert('sns_comment', $param);
         return $result;
     } else {
         return false;
     }
 }
Пример #12
0
function upload()
{
    global $root;
    if ($_FILES['sub']['size'] == 0 && $_FILES['sub']['error'] > 0) {
        return 'Error al subir el subtítulo.';
    }
    $file = $_FILES['sub']['name'];
    $frame = Request::getPost('frame');
    $comment = Request::getPost('comment');
    $credits = Request::getPost('credits');
    if (empty($frame)) {
        return 'Falta el frame.';
    }
    $format = substr($file, -3);
    $formatName = Formats::get($format);
    if (empty($formatName)) {
        return 'El archivo no es de un formato válido.';
    }
    $filename = substr($file, 0, strlen($file) - 4);
    $id = Db::insert('subs', array('filename' => $filename, 'ext' => $format, 'frame' => $frame, 'comment' => $comment, 'credits' => $credits, 'time' => time()));
    $fullpath = "{$root}/upload/{$id}";
    # $fullpath = "/var/www/subs/$id";
    if (!@move_uploaded_file($_FILES['sub']['tmp_name'], $fullpath)) {
        if ($id) {
            Db::delete('subs', "id = '{$id}'");
        }
        return 'No se logró subir el archivo, intente nuevamente en unos minutos.';
    }
    header("Location: /{$id}.html");
}
Пример #13
0
 /**
  * 商品保存
  *
  * @param	array $param 商品资料
  */
 public function saveGoods($param)
 {
     if (empty($param)) {
         return false;
     }
     $goods_array = array();
     $goods_array['goods_name'] = $param['goods_name'];
     $goods_array['gc_id'] = $param['gc_id'];
     $goods_array['gc_name'] = $param['gc_name'];
     $goods_array['member_id'] = $_SESSION['member_id'];
     $goods_array['member_name'] = $_SESSION['member_name'];
     $goods_array['goods_image'] = $param['goods_image'];
     $goods_array['flea_Technical_types'] = $param['flea_Technical_types'];
     $goods_array['flea_area_id'] = $param['flea_area_id'];
     $goods_array['flea_area_name'] = $param['flea_area_name'];
     $goods_array['flea_pname'] = $param['flea_pname'];
     $goods_array['flea_pphone'] = $param['flea_pphone'];
     $goods_array['flea_trade_way'] = $param['flea_trade_way'];
     $goods_array['flea_maturity'] = $param['flea_maturity'];
     $goods_array['goods_store_price'] = $param['goods_store_price'];
     $goods_array['goods_show'] = $param['goods_show'];
     $goods_array['goods_commend'] = $param['goods_commend'];
     $goods_array['goods_status'] = $param['goods_status'];
     $goods_array['goods_add_time'] = time();
     $goods_array['goods_body'] = $param['goods_body'];
     $goods_array['goods_description'] = $param['goods_description'];
     $goods_array['goods_leixing'] = $param['goods_leixing'];
     $result = Db::insert('flea', $goods_array);
     return $result;
 }
Пример #14
0
 /**
  * 新增收藏
  *
  * @param array $param 参数内容
  * @return bool 布尔类型的返回结果
  */
 public function addFavorites($param)
 {
     if (empty($param)) {
         return false;
     }
     return Db::insert('favorites', $param);
 }
Пример #15
0
 /**
  * 注册商城会员
  *
  * @param	array $param 会员信息
  * @return	array 数组格式的返回结果
  */
 public function addMember($param)
 {
     if (empty($param)) {
         return false;
     }
     $member_info = array();
     $member_info['member_id'] = $param['member_id'];
     $member_info['member_name'] = trim($param['member_name']);
     $member_info['member_passwd'] = md5(trim($param['member_passwd']));
     $member_info['member_email'] = trim($param['member_email']);
     $member_info['member_mobile'] = trim($param['member_mobile']);
     $member_info['member_time'] = time();
     $member_info['member_login_time'] = $member_info['member_time'];
     $member_info['member_old_login_time'] = $member_info['member_time'];
     $member_info['member_login_ip'] = getIp();
     $member_info['member_old_login_ip'] = $member_info['member_login_ip'];
     $member_info['member_truename'] = $param['member_truename'];
     $member_info['member_qq'] = $param['member_qq'];
     $member_info['member_sex'] = $param['member_sex'];
     $member_info['member_avatar'] = $param['member_avatar'];
     $member_info['member_qqopenid'] = $param['member_qqopenid'];
     $member_info['member_qqinfo'] = $param['member_qqinfo'];
     $member_info['member_sinaopenid'] = $param['member_sinaopenid'];
     $member_info['member_sinainfo'] = $param['member_sinainfo'];
     $result = Db::insert('member', $member_info);
     if ($result) {
         return Db::getLastId();
     } else {
         return false;
     }
 }
Пример #16
0
 /**
  * 添加直通车申请信息
  *
  * @param array $param 添加信息数组
  */
 public function addZtcGoods($param)
 {
     if (empty($param)) {
         return false;
     }
     $result = Db::insert('ztc_goods', $param);
     return $result;
 }
Пример #17
0
 /**
  * 添加直通车申请信息
  *
  * @param array $param 添加信息数组
  */
 public function addlog($param)
 {
     if (empty($param)) {
         return false;
     }
     $result = Db::insert('ztc_glodlog', $param);
     return $result;
 }
Пример #18
0
 public function submit()
 {
     list($this->validationFlag, $this->validation) = Validation::check(array('nombre' => 'required'));
     if ($this->validationFlag) {
         $nombre = Request::getPost('nombre');
         Db::insert('empresas', array('nombre' => $nombre, 'fecha_creacion' => time()));
         Response::setRedirect('/personas');
     }
 }
Пример #19
0
 protected function assignAclResource($id, $acl_resource_id)
 {
     $existing = Db::getFirst("SELECT * FROM [prefix]user_groups_to_acl_resources WHERE `user-group-id`=:userGroupId AND `acl-resource-id`=:aclResourceId", array(':userGroupId' => $id, ':aclResourceId' => $acl_resource_id));
     if ($existing === false) {
         return Db::insert("user_groups_to_acl_resources", array('user-group-id' => $id, 'acl-resource-id' => $acl_resource_id));
     } else {
         return $existing["id"];
     }
 }
Пример #20
0
 public static function save()
 {
     if (self::$settings !== null) {
         // Da nicht gewährleistet ist, dass überhaupt ein Eintrag existiert, oder dass es wirklich nur einer ist,
         // einfach die Settings-Tabelle komplett platt machen und den Eintrag neu erzeugen.
         Db::delete('settings', '1', array());
         Db::insert('settings', array('json' => json_encode(self::$settings)));
     }
 }
Пример #21
0
 /**
  * 新增地址
  *
  * @param array $param 参数内容
  * @return bool 布尔类型的返回结果
  */
 public function addAddress($param)
 {
     if (!empty($param) && is_array($param)) {
         $tmp = array('member_id' => $_SESSION['member_id'], 'true_name' => $param['true_name'], 'area_id' => $param['area_id'], 'city_id' => $param['city_id'], 'area_info' => $param['area_info'], 'address' => $param['address'], 'zip_code' => $param['zip_code'], 'tel_phone' => $param['tel_phone'], 'mob_phone' => $param['mob_phone']);
         $result = Db::insert('address', $tmp);
         return $result;
     } else {
         return false;
     }
 }
Пример #22
0
 public static function insert($vars)
 {
     if (is_array($vars)) {
         $ins = array('table' => 'options', 'name' => $vars['name'], 'value' => $vars['value']);
         $opt = Db::insert($ins);
     } else {
         Control::error('unknown', 'Format not Found, please in array');
     }
     return $opt;
 }
Пример #23
0
	/**
	 * 新增SNS商品
	 *
	 * @param $param 添加信息数组
	 * @return 返回结果
	 */
	public function goodsAdd($param){
		if (empty($param)){
			return false;
		}
		if (is_array($param)){
			$result = Db::insert('sns_goods',$param);
			return $result;
		}else {
			return false;
		}
	}
Пример #24
0
	/**
	 * 新增分享店铺
	 *
	 * @param $param 添加信息数组
	 * @return 返回结果
	 */
	public function sharestoreAdd($param){
		if (empty($param)){
			return false;
		}
		if (is_array($param)){
			$result = Db::insert('sns_sharestore',$param);
			return $result;
		}else {
			return false;
		}
	}
Пример #25
0
	/**
	 * 好友添加
	 *
	 * @param	array $param 添加信息数组
	 */
	public function addFriend($param) {
		if (empty($param)){
			return false;
		}
		if (is_array($param)){
			$result = Db::insert('sns_friend',$param);
			return $result;
		}else {
			return false;
		}
	}
Пример #26
0
 public function insert($tableName, array &$data)
 {
     foreach ($data as &$value) {
         if ($value === false) {
             // Convert false to 0 because PDO doesn't do it
             // automatically for us.
             $value = '0';
         }
     }
     return parent::insert($tableName, $data);
 }
Пример #27
0
 /**
  * 新增充值卡
  *
  */
 public function addCard($param)
 {
     if (empty($param)) {
         return false;
     }
     $result = Db::insert('pd_gift_card', $param);
     if ($result) {
         return $result;
     } else {
         return false;
     }
 }
Пример #28
0
 public function submit()
 {
     list($this->validationFlag, $this->validation) = Validation::check(array('nombre' => 'required', 'apellido' => 'required'));
     if ($this->validationFlag) {
         $nombre = Request::getPost('nombre');
         $apellido = Request::getPost('apellido');
         $correo = Request::getPost('correo');
         $cargo = Request::getPost('cargo');
         Db::insert('personas', array('id_empresas' => $this->idEmpresas, 'nombre' => $nombre, 'apellido' => $apellido, 'correo' => $correo, 'cargo' => $cargo, 'fecha_creacion' => time()));
         Response::setRedirect("/empresas/{$this->idEmpresas}/personas");
     }
 }
Пример #29
0
 /**
  * 新增
  *
  * @param 
  * @return bool 布尔类型的返回结果
  */
 public function add($param)
 {
     if (empty($param)) {
         return false;
     }
     if (is_array($param)) {
         $result = Db::insert('gold_buy', $param);
         return $result;
     } else {
         return false;
     }
 }
Пример #30
0
 /**
  * 礼品购物车保存
  *
  * @param	array $param 资料
  */
 public function addPointCart($param)
 {
     if (empty($param)) {
         return false;
     }
     $result = Db::insert('points_cart', $param);
     if ($result) {
         return $result;
     } else {
         return false;
     }
 }