当前位置: 首页>>代码示例>>PHP>>正文


PHP Contact::insert方法代码示例

本文整理汇总了PHP中Contact::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::insert方法的具体用法?PHP Contact::insert怎么用?PHP Contact::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contact的用法示例。


在下文中一共展示了Contact::insert方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

    public function save(){
        $name = $this->f3->get('POST.name');
        $email = $this->f3->get('POST.email');
        $comments = $this->f3->get('POST.comments');

        $v = new Valitron\Validator(array('Name' => $name,'Email'=>$email,'Comments'=>$comments));
        $v->rule('required', ['Name','Email','Comments']);
        $v->rule('email',[Email]);

        if ($v->validate()) {
            $contact = new Contact($this->db);
            $data = array(
                'name' => $name,
                'email' => $email,
                'comments' => $comments,
                'contact_date' => date('Y-m-d H:i:s')
            );
            $contact->insert($data);
            $response = array(
                'status' => true,
                'message' => 'Your message saved!'
            );
        }else{
            $response = array(
                'status' => false,
                'errors' => $v->errors()
            );
        }
        echo json_encode($response);
    }
开发者ID:hendrosteven,项目名称:f3-template,代码行数:30,代码来源:ContactController.php

示例2: index

 public function index()
 {
     $vars = array('title' => 'Contact', 'description' => '...');
     $isPost = $this->request->isPost();
     $contact = new Contact();
     $errors = array();
     $success = false;
     if ($isPost) {
         foreach ($contact->getFields() as $key => $value) {
             try {
                 $contact->{$key} = $this->request->post($key, '');
             } catch (Exception $e) {
                 $errors[$key] = $e->getMessage();
             }
         }
         if (empty($errors)) {
             $success = $contact->insert();
         }
     }
     $form = $contact->getForm('insert', ROOT_HTTP . $this->lang->getUserLang() . '/contact/post', $this->request, $isPost, $errors);
     $vars['form'] = $form;
     $vars['isPost'] = $isPost;
     $vars['errors'] = $errors;
     $vars['success'] = $success;
     $this->render('contact', $vars);
 }
开发者ID:erichub,项目名称:-Dashboard-Process,代码行数:26,代码来源:ContactController.class.php

示例3: testInsertContact

 /**
  * @depends testInsertUser
  */
 public function testInsertContact($user)
 {
     $contact = new Contact();
     $contact->address = 'test';
     $contact->email = 'test@demo.com';
     $contact->user_id = $user->id;
     $contact->insert();
     $this->assertGreaterThan(0, $contact->id);
     return $contact;
 }
开发者ID:bephp,项目名称:activerecord,代码行数:13,代码来源:ActiveRecordTest.php

示例4: testLoginForm

 /**
  * @test
  */
 public function testLoginForm()
 {
     $contact = new Contact();
     // New AR
     // $contact = $this->contacts('simple_contact_1'); // Single row with AR
     // $contact = $this->contacts['simple_contact_1']; // Single row
     $data = $contact->findAll();
     $count_is_greater_than_zero = count($contact->findAll()) > 0;
     $this->assertTrue($count_is_greater_than_zero);
     // INSERT ONE NEW RECORD
     /* $contact->insert(array("c_name"=>"test1", "c_email"=>"test1@gmail.com", "c_subject"=>"test1 subject","c_body"=>"Hi, testing body 1."));
        $contact = new Contact(); // New AR
        $contact = new Contact(); // New AR
        $contact->unsetAttributes();
        $contact->setIsNewRecord(true);
        $contact->insert(array('attributes'=>array(
                                                  'c_name' => 'test3',
                                                  'c_email' => 'test3@gmail.com',
                                                  'c_subject' => 'test3',
                                                  'c_body' => 'test3'
                                                )));*/
     // $contact->c_id = NULL;
     $contact->c_name = 'test3';
     $contact->c_email = 'test3@gmail.com';
     $contact->c_subject = 'test3';
     $contact->c_body = 'test3';
     $contact->insert();
     $data = $contact->findAll();
     $this->assertEquals(count($data), 3);
     /*$entries = $contact->findAll();
              
             $count_is_greater_than_zero = (count($entries) > 0);
     
             echo count($entries).' - '. $count_is_greater_than_zero;
             	// Add new records first
             // $contact->add("test1", "test1@gmail.com", "test1 subject","Hi, testing body 1.");
             // $contact->add("Tom", "Hi, I'm Tom.");
             $entries = $contact->findAll();
              
             $count_is_greater_than_zero = (count($entries) > 0);
             $this->assertTrue($count_is_greater_than_zero);*/
     // $this->expectOutputString('two entries');
     // fwrite(STDERR, ' Contact login form '.count($entries).' - '. $count_is_greater_than_zero);
     /*$this->assertIsA($entries, 'array');
     
             // $contact = new Contact();     
             $contact->deleteAll(); // Delete all the entries first so we know it's an empty table
             $entries = $contact->viewAll();
             $this->assertEqual($entries, array());*/
 }
开发者ID:CGTAdal,项目名称:yii-testing-app,代码行数:53,代码来源:ContactTest.php

示例5: useradd_POST

/**
 * Handle User Edit form submission
 *
 * @param <type> $w
 */
function useradd_POST(Web &$w)
{
    $errors = $w->validate(array(array("login", ".+", "Login is mandatory"), array("password", ".+", "Password is mandatory"), array("password2", ".+", "Password2 is mandatory")));
    if ($_REQUEST['password2'] != $_REQUEST['password']) {
        $errors[] = "Passwords don't match";
    }
    if (sizeof($errors) != 0) {
        $w->error(implode("<br/>\n", $errors), "/admin/useradd");
    }
    // first saving basic contact info
    $contact = new Contact($w);
    $contact->fill($_REQUEST);
    $contact->dt_created = time();
    $contact->private_to_user_id = null;
    $contact->insert();
    // now saving the user
    $user = new User($w);
    $user->login = $_REQUEST['login'];
    $user->setPassword($_REQUEST['password']);
    $user->is_active = !empty($_REQUEST['is_active']) ? $_REQUEST['is_active'] : 0;
    $user->is_admin = !empty($_REQUEST['is_admin']) ? $_REQUEST['is_admin'] : 0;
    $user->is_group = 0;
    $user->dt_created = time();
    $user->contact_id = $contact->id;
    $user->insert();
    $w->ctx("user", $user);
    // now saving the roles
    $roles = $w->Auth->getAllRoles();
    foreach ($roles as $r) {
        if (!empty($_REQUEST["check_" . $r])) {
            if ($_REQUEST["check_" . $r] == 1) {
                $user->addRole($r);
            }
        }
    }
    $w->callHook("admin", "account_changed", $user);
    $w->msg("User " . $user->login . " added", "/admin/users");
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:43,代码来源:useradd.php

示例6: addContact

	public function addContact($mysql, $name, $email, $phone, $ownerid) {
		$con = new Contact();
		$con->read($ownerid, $name, $email, $phone);
			switch($con->insert($mysql)) {
				case Contact::DATABASE_ERROR :
				{
					echo "<p>A Database error has occured.</p>";
					return;
				}
				case Contact::INVALID_DATA :
				{
					echo "<p>Invalid operation requested.</p>";
					return;
				}
				case Contact::INSERT_SUCCESS : 
				{
					echo "<p>Contact added successfully.</p>";
					break;
				}
				default :
					break;
			}
	}
开发者ID:nimitz92,项目名称:lcm,代码行数:23,代码来源:ContactManager.class.php

示例7: user

try {
    ActiveRecord::execute("CREATE TABLE IF NOT EXISTS user (");
    ActiveRecord::execute("select * from aaa");
} catch (Exception $e) {
    var_export($e);
}
ActiveRecord::execute("CREATE TABLE IF NOT EXISTS user (\n\t\t\t\tid INTEGER PRIMARY KEY, \n\t\t\t\tname TEXT, \n\t\t\t\tpassword TEXT \n\t\t\t);");
ActiveRecord::execute("CREATE TABLE IF NOT EXISTS contact (\n\t\t\t\tid INTEGER PRIMARY KEY, \n\t\t\t\tuser_id INTEGER, \n\t\t\t\temail TEXT,\n\t\t\t\taddress TEXT\n\t\t\t);");
$user = new User();
$user->name = 'demo';
$user->password = md5('demo');
var_dump($user->insert());
$contact = new Contact();
$contact->address = 'test';
$contact->email = 'test1234456@domain.com';
$contact->user_id = $user->id;
var_dump($contact->insert());
/*
$contact = new Contact();
$contact->address = 'test';
$contact->email = 'test1234456@domain.com';
$contact->user_id = 2;
var_dump($contact->insert());
*/
$user = new User();
var_dump($user->notnull('id')->orderby('id desc')->find());
echo "\nContact of User # {$user->id}\n";
var_dump($user->contacts);
$contact = new Contact();
//var_dump($contact->find());
var_dump($contact->user);
开发者ID:cgslivre,项目名称:activerecord,代码行数:31,代码来源:test.php

示例8: json_encode

<?php

require_once __DIR__ . '/../autoload.php';
$name = $_POST['name'];
$mail = $_POST['mail'];
$text = $_POST['text'];
$data = date("Y-m-d H:i:s");
if (!empty($name) && !empty($text) && !empty($mail)) {
    $contact = new Contact();
    $contact->insert($data, $name, $text, $mail);
}
$response = ['name' => $name, 'mail' => $mail, 'text' => $text, 'data' => $data];
echo json_encode($response);
开发者ID:Alexandr1987,项目名称:PHP1,代码行数:13,代码来源:response.php

示例9: array

<?php

require_once 'config/config.conf.php';
$result = null;
$errors = array();
$contact = new Contact();
// On a appuyé sur le bouton Envoyer, le formulaire a été soumis
if (!empty($_POST)) {
    foreach ($_POST as $key => $value) {
        try {
            $contact->{$key} = $value;
        } catch (Exception $e) {
            $errors[$key] = $e->getMessage();
        }
    }
    if (empty($errors)) {
        $result = $contact->insert();
    }
}
$vars = array('contact' => $contact, 'errors' => $errors, 'result' => $result);
Model::displayTemplate('contact.tpl', $vars);
开发者ID:vincenthib,项目名称:cooking,代码行数:21,代码来源:contact.php

示例10: addContact

function addContact($photo, $name, $lastname, $cellphone, $phone, $email, $description)
{
    $status = Contact::insert($photo, $name, $lastname, $cellphone, $phone, $email, $description);
    return $status;
}
开发者ID:RickyCruz,项目名称:Curso-Datafit-Android,代码行数:5,代码来源:server.php

示例11: lang

 //Attempt to add the user to the database, carry out finishing  tasks like emailing the user (if required)
 if ($user->userCakeAddUser()) {
     if ($user->mail_failure) {
         array_push($warning_messages, lang("ACTIVATION_MAIL_NOT_SENT", array($_POST['username'], $_POST['email'])));
     }
     // Retrieve the User_ID from the database
     $userdetails = fetchUserDetails($user->clean_username);
     if (!empty($userdetails)) {
         $contact = new Contact(true, $userdetails['User_ID'], $_POST);
         $personal = new Personal(true, $userdetails['User_ID'], $_POST);
         $status = new Status(true, $userdetails['User_ID'], $_POST);
         if ($_POST['group_id'] == 1 || $_POST['group_id'] == 2) {
             $studies = new Studies_Undergr(true, $userdetails['User_ID'], $_POST);
         }
         $inserted = array();
         $inserted['contact'] = $contact->insert();
         $inserted['personal'] = $personal->insert();
         $inserted['status'] = $status->insert();
         if ($_POST['group_id'] == 1 || $_POST['group_id'] == 2) {
             $inserted['studies'] = $studies->insert();
         }
         // TODO Failure handling here is non-existent
         // Need to better handle the case when database insertion partially fails
         $success = true;
         foreach ($inserted as $key => $value) {
             if ($value == false) {
                 array_push($warning_messages, lang("COULD_NOT_SAVE_IN_DATABASE", array($key)));
             }
         }
     }
 }
开发者ID:skarabasakis,项目名称:alumniclub_usercake,代码行数:31,代码来源:register.php


注:本文中的Contact::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。