本文整理汇总了PHP中Contacts::findFirst方法的典型用法代码示例。如果您正苦于以下问题:PHP Contacts::findFirst方法的具体用法?PHP Contacts::findFirst怎么用?PHP Contacts::findFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contacts
的用法示例。
在下文中一共展示了Contacts::findFirst方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quicksmsAction
public function quicksmsAction()
{
if ($this->request->isPost() == true) {
$this->response->setContentType('application/json');
$contact_number = $this->request->getPost('contact_number');
$contact_number = explode(',', $contact_number);
$message = $this->request->getPost('message');
$user_id = $this->request->getPost('user_id');
$contact_ids = array();
foreach ($contact_number as $number) {
$con_data = Contacts::findFirst("number LIKE '%{$number}%' AND user_id={$user_id} AND deleted=0");
if ($con_data) {
$contact_ids[] = $con_data->id;
$type = "CONTACTID";
} else {
$contact_ids[] = $number;
$type = "NUMBER";
}
}
$data = $this->sendSmsProcessData(array('message' => $message, 'user_id' => $user_id, 'ids' => $contact_ids, 'type' => $type, 'contacts' => $contact_ids));
$this->response->setContent(json_encode($data));
$this->response->send();
}
}
示例2: updateContact
private function updateContact($contact_data)
{
$number = $contact_data['number'];
$user_id = $contact_data['user_id'];
$contact = Contacts::findFirst("user_id={$user_id} AND number LIKE '%{$number}%'");
if ($contact->deleted == 1) {
$contact->name = $contact_data['contact_name'];
$contact->address = $contact_data['address'];
$contact->email = $contact_data['email'];
$contact->deleted = 0;
$contact->save();
$data = array('status' => 'success', 'msg' => $contact_data['msg'], 'code' => 2);
} else {
$data = array('status' => 'error', 'msg' => 'Already Exist', 'code' => 1);
}
return $data;
}
示例3: getNumbers
public static function getNumbers($contact_ids)
{
$numbers = array();
foreach ($contact_ids as $contact_id) {
$result = Contacts::findFirst("id= '{$contact_id}'");
$numbers[] = $result->number;
}
return implode(',', $numbers);
}