本文整理汇总了PHP中Mapper::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Mapper::delete方法的具体用法?PHP Mapper::delete怎么用?PHP Mapper::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapper
的用法示例。
在下文中一共展示了Mapper::delete方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validate a token. Returns the result and deletes the token if valid.
*
* @param string $token The token
* @return boolean
*/
public static function validate($token)
{
$tokenMapper = new Mapper('Token');
$tokenMapper->filter('value=(?)', $token);
$tokenResults = $tokenMapper->get();
if (count($tokenResults['Token']) == 0) {
return false;
}
// we found the token
Mapper::delete($tokenResults['Token'][0], $tokenResults['Token'][0]->id);
return true;
}
示例2: deletePicture
/**
*
* @return boolean
* @throws InvalidArgumentException
*/
public function deletePicture()
{
try {
if (isset($this->table) && is_null($this->table)) {
throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
}
if (isset($this->id) && !is_null($this->id)) {
$where = 'id = ' . $this->id;
}
//Init a object of picture to delete the picture in the folder.
//Needed to reconsitued the path.
$picture = $this->selectPicture();
$path = $picture->getPath();
$title = $picture->getTitle();
$ext = $picture->getExtension();
//Remove to the pictures folders
if (file_exists(UPLOAD_PATH . $path . $title . '.' . $ext)) {
unlink(UPLOAD_PATH . $path . $title . '.' . $ext);
}
return parent::delete($this->table, $where);
} catch (InvalidArgumentException $e) {
print $e->getMessage();
exit;
}
}
示例3: deleteIncoming
/**
*
* @return boolean
* @throws InvalidArgumentException
*/
public function deleteIncoming()
{
try {
if (is_null($this->table)) {
throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
}
if (isset($this->id) && !is_null($this->id)) {
$where = 'id = ' . $this->id;
}
return parent::delete($this->table, $where);
} catch (InvalidArgumentException $e) {
print $e->getMessage();
exit;
}
}
示例4: deleteMessage
/**
*
* @return boolean
* @throws InvalidArgumentException
*/
public function deleteMessage()
{
if (is_null($this->table)) {
throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
}
if (isset($this->id) && !is_null($this->id)) {
$where = 'id = ' . $this->id;
}
return parent::delete($this->table, $where);
}
示例5: tag
public static function tag($feedid, $tagid, $remove)
{
if ($remove == 'false') {
// is tag feed already?
$feedtagMapper = new Mapper('Feed_Tag');
$feedtagMapper->filter('feed_id=(?)', $feedid);
$feedtagMapper->filter('tag_id=(?)', $tagid);
$feedtadResults = $feedtagMapper->get();
if (count($feedtadResults['Feed_Tag']) >= 1) {
return -1;
}
$tagObject = new Feed_Tag();
$tagObject->feed_id = $feedid;
$tagObject->tag_id = $tagid;
return Mapper::add($tagObject);
} else {
// is tag feed already?
$feedtagMapper = new Mapper('Feed_Tag');
$feedtagMapper->filter('feed_id=(?)', $feedid);
$feedtagMapper->filter('tag_id=(?)', $tagid);
$feedtadResults = $feedtagMapper->get();
if (count($feedtadResults['Feed_Tag']) >= 1) {
Mapper::delete('Feed_Tag', $feedtadResults['Feed_Tag'][0]->id);
return 1;
}
return -1;
}
}
示例6: deleteAnnouncement
/**
* Triggered
* @return Boolean If True -> Success Query / False -> Fail Query
* @throws InvalidArgumentException
*/
public function deleteAnnouncement()
{
try {
if (is_null($this->table)) {
throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
}
if (isset($this->id) && !is_null($this->id)) {
$where = 'id = ' . $this->getId();
}
$pictureMapper = new PictureMapper($this);
$pictures = $pictureMapper->selectPicture(true, 'id_announcement = ' . $this->getId());
if (isset($pictures) && !empty($pictures)) {
foreach ($pictures as $key => $value) {
$idPicture = $value->getId();
$path = $value->getPath();
$title = $value->getTitle();
$ext = $value->getExtension();
//Remove to the pictures folders
if (file_exists(UPLOAD_PATH . $path . $title . '.' . $ext)) {
unlink(UPLOAD_PATH . $path . $title . '.' . $ext);
}
//Remove to database
$pictureMapper = new PictureMapper();
$pictureMapper->setId($idPicture);
if ($pictureMapper->deletePicture()) {
continue;
} else {
throw new Exception('Problem on the delete picture query !');
}
}
}
return parent::delete($this->table, $where);
} catch (InvalidArgumentException $e) {
print $e->getMessage();
exit;
} catch (Exception $e) {
print $e->getMessage();
exit;
}
}
示例7: testUpdate
public function testUpdate()
{
// get a patient by id
$patientObject = new Patient();
$patientObject->name = 'PLN2';
$patientObject->dob = '2002-01-01';
$patientObject->sex = 'F';
$patientObject->uid = 'PID2;';
$patientID = Mapper::add($patientObject);
// Modify one field
$patientObject->name = 'PLN3';
// Update database and get object
Mapper::update($patientObject, $patientID);
$patientResult = Mapper::getStatic('Patient', $patientID);
// compared object we just added with its "base" object
// we make sure id match
$patientObject->id = $patientID;
$this->assertTrue($patientResult['Patient'][0]->equals($patientObject) == True);
// update "silly" object to create one object which alread exists
$existingID = Mapper::update($patientObject, -1);
// should return the id of the object which already exists
$this->assertTrue($patientID == $existingID);
//update object that does not exist
$patientObject->name = 'PLN4';
$existingID = Mapper::update($patientObject, -1);
// update should return 0 if object does not exist
$this->assertTrue($existingID == 0);
// clean the DB
Mapper::delete('Patient', $patientID);
}
示例8: remove
/**
* Remove file in given feed
* @return bool
*/
public static function remove($userID, $tagId)
{
// delete same patient
return Mapper::delete('Tag', $tagId);
}