It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am able to successfully read the data from my form and using println show them in console,
I need to add them to the database, currently I am using the predefine database for my authorisation stuffs, please help me to add the form values to the database. So far I have created the following class.
object Form extends Form with LongKeyedMetaMapper[Form] {
override def fieldOrder = List(name,age)
}
class Form extends LongKeyedMapper[Form] with IdPK {
def getSingleton = Form
object name extends MappedString(this,10)
object age extends MappedString(this,5)
}
There exists an example for setting up Lift Mapper at the Lift wiki-site. See https://www.assembla.com/spaces/liftweb/wiki/Mapper
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to extract a bunch of urls from a db (the db contains a large set of urls), when a user searches for a particular keyword, for example "seattle dentist". I understand that the basic approach is to look for the page title, meta description, keywords and body text.
How can I do this with more accuracy that returns relevant result?
For example, I have two websites in question:
seattledentist.com (which is a dentist website and has the title
"seattle dentist")
abcxyz.com/dentist-seattle (a wordpress blog
page that has the word "seattle dentist" in its title)
For me, the first website is relevant and I want to show this site to a user when he searches for "seattle dentist".
The second website is just a blog post that describes the dentistry profession in seattle and is not relevant for the user.
So my question is, what would be a better strategy(algorithm) for filtering out this type of non-relevant urls from a whole bunch of urls?
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I use Backbone & Marionette for my webapp,
I Have a collection of tracks, when a track is added and when the player don't read any track, I want put "played" style to itemView, or "paused" to the track added on the cue.
So I want to add a class for each new Backbone model.
When I add a model, the class is added to the previous element, but not on the newest.
This is my CompositeView :
var trackListYTView = Marionette.CompositeView.extend({
template: "#playlist",
id: "trackList",
itemView: trackView,
itemViewContainer: "tbody",
initialize: function(){
this.bindTo(this.collection, "add", this.modelAdded);
},
modelAdded: function(model){
if(status) this.$('#status').addClass('icon-pause');
else this.$('#status').addClass('icon-play');
}
I think "this" is not the good selector for the new itemView.
Thanks for helps, Luca
I think your problem is the selector - #status. The element id should be unique. You should not have multiple elements with same id. Use a class selector, for example '.statusClass', instead of '#status'.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Is it possible to set values in $this->data which is received in controller from the view.
We can use if($this->data['id']) but why we cant set values in it?
Will this work$this->data['id']=$userid;
You have a couple of options
The first is to just create your own variable and modify that:
$myData = $this->data;
$myData['id'] = $userid;
$this->Post->save($myData);
The second is to use $this->request->data. It contains the same info as $this->data but can be modified.
$this->request->data['id'] = $userid;
$this->Post->save($this->request->data);
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm using CakePHP, and trying to pull data from a table outside my current controller. The only thing I can find online is about using associations and belongsTo and such, however these two items shouldn't be related. I simply want to pull data from another table at will.
You could also use the loadModel inside your functions.
$this->loadModel('User', 2);
$user = $this->User->read();
Well if you want to access different model (not the related to the controller) you can use
class SomeController extends AppController {
var $uses = array('Model1', 'Model2');
// and then later in the code you can use them like this
function index() {
$this->Model1->doStuff;
$this->Model2->doStuff;
}
}
you can use
$user=App::Model('User');
$user->find('all');
either
//only controller
$this->loadModel('MyModel');
$res = $this->MyModel->find(...)
or
//everywhere
$this->MyModel = ClassRegistry::init('MyModel');
$res = $this->MyModel->find(...)
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have 3 tables: users, images (foreign key to user_id), comments (foreign keys: user_id and image_id)
Can somebody explain me or send me link to good tutorial how to work with database?
I mean e.g.:
1. I wants to take all Images which have any comment in Comments table. In SQL: select i from Images i, Commets c where i.id=c.image_id???
Can You explain me how can I access from one controller to another Model?
I was trying in Images controller:
$data = $this->Image->query('Select * from Images i, Comments c where i.id=c.image_id');
And in view: $image['id'] but I have error:Undefined index: id [APP\views\images\commented.ctp,
SO it does not work:/
How can I delete Image and all its comments? I used Zend and I get used to it and I have no idea how to do the same thinks in cakePHP :/
Can somebody explain me how to work with database in this cakePHP I know there are find, findAll etc functions but all of them are from a controller level ex. $this->Image->find() etc...
I need better tutorial than the basic cakePHP cookbook :/. I am open for any sugestions.
Regards,
You reference models in the controller in one of many ways. The two common ways are with the uses variable at the top of the controller:
var $uses = array('User','Image');
Or you can put it inline in your functions:
$this->loadModel('Image');
$this->Image->find('all'); ...
In addition, if you have the models linked by a foriegn key, you can even call it like:
$this->User->Image->find('all');
Once you get the hang of how CakePHP structures things, it makes it very clear.
So for your sql statement in the question, you could do something like the following from the users controller:
class UsersController extends AppController {
var $name = 'Users';
var $uses = array('User','Image','Comments');
function {my_function_name}() {
$this->Images->recursive = 1;
$images = $this->Image->find('all');
}
}
Now, as long as your relationships are correct in the model, the recursive function will build the images array with all of the comments attached to it.
array(
[Image] => array(
image data,
[comments] => array(
[0] comment data,
[1] comment data,
[2] ...
)
)
)
I hope that at least pushes you in the right direction. Happy coding!