本文整理汇总了PHP中Address::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::setId方法的具体用法?PHP Address::setId怎么用?PHP Address::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::setId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAddress
public function createAddress(Address $address)
{
$address->setId(null);
$sql = '
INSERT INTO addresses_tb(id,street_no,street,suburb,city,post_code)
VALUES (:id,:street_no,:street,:suburb,:city,:post_code)';
return $this->execute($sql, $address);
}
示例2: add
protected function add(Address $address)
{
$q = $this->dao->prepare('INSERT INTO ' . $this->table() . ' SET TITLE = :title, ADDRESS_1 = :address1, ADDRESS_2 = :address2, ZIP_CODE = :zipCode, CITY = :city, COUNTRY = :country, USER_ID = :userId');
$q->bindValue(':title', $address->getTitle());
$q->bindValue(':address1', $address->getAddress1());
$q->bindValue(':address2', $address->getAddress2());
$q->bindValue(':zipCode', $address->getZipCode());
$q->bindValue(':city', $address->getCity());
$q->bindValue(':country', $address->getCountry());
$q->bindValue(':userId', $address->getUserId(), PDO::PARAM_INT);
$q->execute();
$address->setId($this->dao->lastInsertId());
}
示例3: edit
public function edit()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$entity = new Address();
$entity->setId($_GET['id'])->setName($_POST['name'])->setAddress($_POST['address'])->setDateAdded(date('Y-m-d H:i:s'));
if (isset($_FILES['image'])) {
$entity->saveImage($_FILES['image']);
}
$addressCollection = new AddressCollection();
$addressCollection->save($entity);
header('Location: index.php?c=address');
exit;
}
$addressCollection = new AddressCollection();
$data = array('address' => $addressCollection->one(array('id' => $_GET['id'])));
$this->loadView('address/edit', $data);
}
示例4: map
public static function map(Address $address, array $properties)
{
if (array_key_exists('id', $properties)) {
$address->setId($properties['id']);
}
if (array_key_exists('street', $properties)) {
$address->setStreet($properties['street']);
}
if (array_key_exists('suburb', $properties)) {
$address->setSuburb($properties['suburb']);
}
if (array_key_exists('city', $properties)) {
$address->setCity($properties['city']);
}
if (array_key_exists('post_code', $properties)) {
$address->setPostCode($properties['post_code']);
}
if (array_key_exists('street_no', $properties)) {
$address->setstreetNo($properties['street_no']);
}
}
示例5: getAddresses
public static function getAddresses($where = null)
{
$dados = Database::ReadAll("address a, city c, state s", "a.*, c.*, s.*", "WHERE a.id_city = c.id_city AND s.id_state = c.id_state " . $where);
if (!$dados) {
return '';
}
foreach ($dados as $dado) {
$address = new Address();
$address->setId($dado['ID_ADDRESS']);
$address->setStreet($dado['NAME_ADDRESS']);
$address->setNumber($dado['NUMBER']);
$address->setComplement($dado['COMPLEMENT']);
$address->setDistrict($dado['DISTRICT']);
$address->setLatitude($dados['LATITUDE']);
$address->setLongitude($dados['LONGITUDE']);
$address->setCity($dado['NAME_CITY']);
$address->setState($dado['INITIALS']);
$address->setPs($dado['PS']);
$addresses[] = $address;
}
return $addresses;
}
示例6: contactParser
function contactParser($data)
{
$contact = new Contact();
if (isset($data['id'])) {
$contact->setId($data['id']);
}
if (isset($data['firstName'])) {
$contact->setFirstName($data['firstName']);
}
if (isset($data['name'])) {
$contact->setName($data['name']);
}
if (isset($data['mail'])) {
$contact->setMail($data['mail']);
}
if (isset($data['phone'])) {
$contact->setPhone($data['phone']);
}
if (isset($data['phone2'])) {
$contact->setPhone2($data['phone2']);
}
if (isset($data['phone3'])) {
$contact->setPhone3($data['phone3']);
}
if (isset($data['company'])) {
$contact->setCompany($data['company']);
}
if (isset($data['address'])) {
$dataAddress = $data['address'];
$address = new Address();
if (isset($dataAddress['id'])) {
$address->setId($dataAddress['id']);
}
if (isset($dataAddress['line1'])) {
$address->setLine1($dataAddress['line1']);
}
if (isset($dataAddress['line2'])) {
$address->setLine2($dataAddress['line2']);
}
if (isset($dataAddress['zipCode'])) {
$address->setZipCode($dataAddress['zipCode']);
}
if (isset($dataAddress['city'])) {
$address->setCity($dataAddress['city']);
}
if (isset($dataAddress['latitude']) && isset($dataAddress['longitude'])) {
$address->setLatitude($dataAddress['latitude']);
$address->setLongitude($dataAddress['longitude']);
} else {
$mapService = new GoogleMapService();
$latlng = $mapService->getLatLong($address);
if ($latlng != [] && sizeof($latlng) == 2) {
$address->setLatitude($latlng[0]);
$address->setLongitude($latlng[1]);
}
}
$contact->setAddress($address);
}
if (isset($data['type'])) {
if (isset($data['type']['id']) && isset($data['type']['name'])) {
$type = new Type($data['type']['id'], $data['type']['name']);
} elseif (isset($data['type']['name'])) {
$type = new Type(null, $data['type']['name']);
} else {
$type = null;
}
$contact->setType($type);
}
if (isset($data['exchangeId'])) {
$contact->setExchangeId($data['exchangeId']);
}
return $contact;
}
示例7: getAddressesByRayon
public function getAddressesByRayon($address, $rayon)
{
$list = [];
try {
if (!parent::getBdd()->inTransaction()) {
parent::getBdd()->beginTransaction();
}
$query = "SELECT *, ( 6371 * acos( cos( radians(:latitude) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:longitude) )\n + sin( radians(:latitude) ) * sin( radians( latitude ) ) ) ) AS distance FROM address HAVING distance < :rayon ORDER BY distance LIMIT 0 , 150;";
$request = parent::getBdd()->prepare($query);
$request->bindParam(':latitude', $address->getLatitude());
$request->bindParam(':longitude', $address->getLongitude());
$request->bindParam(':rayon', $rayon);
$request->execute();
while ($data = $request->fetch()) {
$address = new Address();
$address->setId($data['id']);
$address->setLine1($data['line1']);
$address->setLine2($data['line2']);
$address->setZipCode($data['zipcode']);
$address->setCity($data['city']);
$address->setLatitude($data['latitude']);
$address->setLongitude($data['longitude']);
array_push($list, $address);
}
if ($list == []) {
return null;
}
return $list;
} catch (Exception $e) {
error_log($e->getMessage());
}
return null;
}