Posts

java - JPA Join Column -

i have 3 tables in database. first one(categories) includes: id, category, isactive second one(menu) includes: parentid , childid. third one(items) includes: id, name , price. first table has relationship second. want relationship between second , third now. second table has these values in database: 7(id), book1(name), 120(price) 7(id), book2(name), 100(price) 8(id), car1(name), 1620(price) 8(id), car2(name), 520(price) 8(id), car3(name), 5520(price) 9(id), house1(name), 10000(price) 9(id), house2(name), 11000(price) 9(id), house3(name), 15000(price) at moment have joined column childid column id. menu.java @embeddedid menuid id; @column(name="parentid") private integer parentid; @column(name="childid") private integer childid; @onetoone @joincolumn(name="childid",referencedcolumnname="id") private categories subcategories; public categories getsubcategories() { return this.subcategories; } public void se...

php - Insert image into sql server db with pdo -

$stmt=$con->query("insert tbl(data) values(0x".$data1['hex'].")"); this sql statement , works fine. value 0xffd8ffe000104a46494600010101006000600000ffdb00430... gets stored on database , have checked, image gets stored. trying using pdo , stored value different , not show image. here code $datastring = file_get_contents("image.jpg"); $data1 = unpack("h*hex", $datastring); $data = '0x'.$data1['hex']; $stmt=$conp->prepare("insert tbl(data) values(:data)"); $stmt->bindparam(':data', $data); $stmt->execute(); the value in database 0x30786666643866666530303031303461343634393436303... what making difference? doing wrong it? using sql server 2008r2 microsoft pdo_odbc driver on php 5.6. first google hit mssql varbinary pdo : https://social.msdn.microsoft.com/forums/sqlserver/en-us/221dcea2-438d-4a3a-b438-b98bff8f3d57/using-pdostatementbindvalue-to-update-varbinary-fields ...

Differences between scanf and getchar in C -

i trying explain friend c coding , asked me why code (with "scanf") didn't work. #include int main() { char x=scanf("%c",&x); printf("%c\n",x); return 0; } and 1 yes #include <stdio.h> int main() { int k; char x=getchar printf("%c\n",x); return 0; } when scanf completes, x contains character read. however, value overwritten when x assigned return value of scanf , number of items matched or eof in event of error. if call scanf without assigning return value x should expected result. for example, should work. char x; scanf("%c",&x);

python - Cannot resole keyword 'carmodel' into field. Choices are: exterior_color, id, interior_color -

as want filter on foreign key, used carmodel __ in method dropdownlistsearch() of views.py . when run code, tells must field. don't understand part. why error. , using django 1.6.5. models.py from django.db import models class carinfo(models.model):0 vin_number = models.charfield(max_length = 17) model = models.foreignkey(carmodel) timestamp = models.datetimefield(auto_now_add = true, auto_now = false) updated = models.datetimefield(auto_now_add = false, auto_now = true) def __unicode__(self): return self.vin_number class carmodel(models.model): model = models.charfield(max_length = 60) def __unicode__(self): return self.model views.py def dropdownsearch(request): try: q = request.get.get('q') except: q = none if q: cars = carinfo.objects.filter(carmodel__model__contains=q) template ='productions/resultstwo.html' else: template = '...

jquery - How can I get an input text to expand its digits to two if the user only enters one? -

i want display values in text inputs in "dollar format"; iow, instead of "10.5" want "10.50" i able in grand total box (last line of code): $(document).on("blur", '.amountbox', function (e) { var amount1 = $('[id$=boxamount1]').val() != '' ? parsefloat($('[id$=boxamount1]').val()) : 0; var amount2 = $('[id$=boxamount2]').val() != '' ? parsefloat($('[id$=boxamount2]').val()) : 0; var amount3 = $('[id$=boxamount3]').val() != '' ? parsefloat($('[id$=boxamount3]').val()) : 0; var amount4 = $('[id$=boxamount4]').val() != '' ? parsefloat($('[id$=boxamount4]').val()) : 0; var amount5 = $('[id$=boxamount5]').val() != '' ? parsefloat($('[id$=boxamount5]').val()) : 0; var grandtotal = amount1 + amount2 + amount3 + amount4 + amount5; $('[id$=boxgrandtotal]').val(parsefloat(grandtotal).tof...

javascript - Creating a new collection inside existing collection -

i trying put backbone model inside existing model. wondering if possible. var rf = this.collection.create(attrs, options); model.set(table, rf); thanks what trying "nested models & collections". backbone has preferable approach . common idea consist in storing of nested model directly in instance of model instead attributes. so, create child model first , pass parent model through options following: var rf = this.collection.create(attrs, options); var model = backbone.model.extend({ initialize: function(attributes, options) { _.isobject(options) || (options = {}); if (options.child) { this.child = new options.child; } } }); var model = new model({}, {child: rf}); if want supported tree-like backbone models try use 1 of following plugins . hope helps!

drupal - Extending Context List module to show names of blocks/nodes -

i did search on this, found nothing , custom module. called context list named , extends context list module blocks show titles instead of node or block number. project maintainer created 2 hooks me, have not been able figure out how working. here function: function context_list_named_context_list_reaction_block_name(&$block_name, &$details) { if(preg_match('/^nodeblock:(\d+)$/', $block_name)) { $block = block_load('nodeblock',$details->delta); $block_name = $block->subject; //$block_name = ; } elseif(preg_match('/^block:(\d+)$/', $block_name)) { $block = block_load('block',$details->delta); $block_name = $block->subject; //return $block_name; } $block_name = 'test'; } so can see trying set $block_name = 'test'; started, not seeing change on context list page . (context block info module offers same type of list node/block numbers well.)