本文整理匯總了PHP中Images::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::find方法的具體用法?PHP Images::find怎麽用?PHP Images::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::find方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: DeleteImage
public function DeleteImage()
{
$input = Input::all();
$img = Images::find($input['image_id']);
if (isset($img)) {
unlink($img->url);
$img->delete();
}
}
示例2: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$images = Images::find($id);
$images->delete();
// redirect
Session::flash('message', 'Successfully deleted the Image!');
return Redirect::to('images');
}
示例3: function
$rowcount = ImagesTags::count(['distinct' => 'image_id', 'conditions' => 'confidence is null']);
$imagesCount = Images::count();
$tags = ImagesTags::count(['distinct' => 'tag_id', 'conditions' => 'confidence is null']);
$users = Users::count();
// $latestTag = ImagesTags::findFirst(['orderBy' => 'created DESC', 'conditions' => 'confidence is null', 'limit' => 1])->getTags();
$response->setJsonContent(['imagesWithTags' => $rowcount, 'images' => $imagesCount, 'tags' => $tags, 'userTags' => $userTags, 'latestTag' => 0, 'users' => $users]);
$response->send();
});
/**
* Present image list by offset and limit
*/
$app->get('/images/{offset:[0-9]+}/{limit:[0-9]+}', function ($offset, $limit) use($response) {
if ($limit > 10000) {
die('maximum limit is 10000');
}
echo json_encode(Images::find(['offset' => $offset, 'limit' => $limit])->toArray(), JSON_NUMERIC_CHECK);
});
/**
* Searching images for tags
*/
$app->get('/images/search', function () use($app, $response) {
$request = new Phalcon\Http\Request();
$terms = explode(' ', $request->getQuery('term', null, false));
if (count($terms) == 0) {
die("no term!");
}
//Create a query based on the terms
$termNew = "";
foreach ($terms as $term) {
$termNew = $termNew . 'tags.name LIKE \'%' . $term . '%\' AND ';
}
示例4: destroy
/**
* Delete specified image from database.
*
* @param int $id
* @return object Redirect
*/
public function destroy($id)
{
Images::find($id)->delete();
return Redirect::route('images_user')->with('status', 'alert-success')->with('message', 'Image removed properly.');
}
示例5: foreach
$data = [];
$i = 0;
foreach ($images as $image) {
foreach ($image->getImagesTags() as $tag) {
foreach ($tag->getTags() as $tag2) {
$data[$i]['id'] = $image;
$data[$i]['tag'] = $tag2;
$data[$i]['imageTagId'] = $tag;
$i++;
}
}
}
$response->setJsonContent($data);
});
$app->get('/images/{offset:[0-9]+}/{limit:[0-9]+}', function ($offset, $limit) use($response) {
$robots = Images::find(['offset' => $offset, 'limit' => $limit]);
$data = [];
foreach ($robots as $robot) {
$data[] = $robot;
}
$response->setJsonContent($data);
});
$app->get('/img_resize/{id:[0-9]+}', function ($id) use($app, $response) {
$image = Images::findFirstById($id);
if (count($image) > 0) {
$resized_file = str_replace('http://hack4dk.dr.dk/', '/home/ubuntu/workspace/resized_images/', $image->url);
$percent = 0.2;
if (!file_exists($resized_file)) {
//Lets create folder structure if it doesn't exist
if (!file_exists(dirname($resized_file))) {
mkdir('./' . dirname($resized_file), '0777', true);
示例6: postChangePost
public function postChangePost()
{
$id = Input::get('ids');
$i = 0;
foreach ($id as $k) {
$img = Images::find($id[$i]);
$img->order = $i + 1;
$img->save();
$i++;
}
$x = 0;
return Response::json(array('type' => 'success', 'msg' => 'Imagenes cambiadas de posición satisfactoriamente.'));
}
示例7: testGridFS
public function testGridFS()
{
$image = new Images();
$image->name = 'Phalcon';
$success = $image->save('unit-tests/assets/logo.png');
$this->assertTrue($success);
$this->assertInstanceOf('MongoId', $image->_id);
$firstImageId = $image->_id;
$images = Images::find();
$this->assertTrue(is_object($images));
$this->assertEquals(count($images), 1);
$this->assertEquals($images[0]->name, 'Phalcon');
$this->assertInstanceOf('MongoGridFSFile', $images[0]->getFile());
}