问:
Conceptual modelling scenario
I am very new to Database Design and I have been practising with as many questions as I can. I happened to come across the below question (No, this is not my assignment!) and from what I could understand, I have created the attached conceptual model. There is some information missing in the model because from the requirements, it wasn't clear to me where should they be added. I have highlighted the lines that I have a doubt in.

You have been assigned the task to design a database schema that captures the information needed for a facility reviewing service for tourists, for facilities such as accommodations, eateries and planned trips.
    With regards to the accommodations, the service keeps information about the name, the address, the kind of accommodation. The accommodation type could be hotel, hostel or bed & breakfast. We need also the name and address. There is also an optional set of facilities (which should be listed, separately) such as the kind of rooms (single, double or for more persons), the presence of TV in rooms, bathroom, etc. More than one facility could be applicable to the same place. There is also the cost per night which could be specified either per person (in hostels) or per room (in hotels, bed and breakfasts; therefore, depending on the accommodation type).

    For the places to eat we have the name and the address (unique and always available). They could be restaurants, bars, pubs, taverns and self-services. It should be specified the kind of cuisine, the average cost per meal (divided into 4 possible cost levels), the daily time table (composed by the open and close times) and optionally the stop days during the week (one or more days).
    With regards to the trip, we want to specify the list of the names of the attractions (and corresponding address, if present). For each trip attraction, we have the interval of dates in which the tourists visit them.
    Each customer can leave a review in free text for each place (accommodation or place to eat but not for tourist trips), specifying his/her nickname (which is unique for all the customers), the date of visit (or alternatively a calendar interval specified by two dates) and a integer score (from 0 to 5). Each customer could visit and leave a review more than once for the same place.
    Draw the ER diagram for the conceptual design of the database.

This is what I came up with:
Conceptual Model

The image has the model that I could think of. My doubts are:

1) Is my approach correct to use so many generalizations? Is there any other way?

2) In the description above, the first sentence that is in italics and bold says that there are certain 'optional set of facilities'. Should these attributes be added to Hotel, Hostel and B&B entity or to the generalised Accommodation entity?

3) In the second sentence that is highlighted, should the cost be added to Hotel,Hostel and B&B like I have done? Otherwise, how should I proceed in modelling this?

4) In the third highlighted sentence, should the specified attributes be listed under each type of eatery or should they be added to the generalised entity Eatery?

Thanks much for the help in advance!

答:
Is my approach correct to use so many generalizations? Is there any other way?

There certainly are other ways. There's nothing wrong with generalization, though its rare to see so much of it in one model. That doesn't mean its wrong, right and wrong in this case depends on how well your model represents the business requirements.

In the description above, the first sentence that is in italics and bold says that there are certain 'optional set of facilities'. Should these attributes be added to Hotel, Hostel and B&B entity or to the generalised Accommodation entity?

It sounds like a general requirement, I would associate it with Accommodation.

Note that there are two usages of "Facility" in the given scenario - for places that can be visited/reviewed, and for features of rooms. I would recommend renaming one of the terms to avoid confusion.

In the second sentence that is highlighted, should the cost be added to Hotel,Hostel and B&B like I have done? Otherwise, how should I proceed in modelling this?

You could do it the way you've done, or add a cost attribute (and per person/room indicator) to Accommodation.

You should try to avoid mixing domains in an attribute. By this I mean that all possible values should be of the same type and logically interchangeable. A common situation is mixing values of different currencies in one attribute, or the value column in EAV tables. Such designs tend to increase complexity.

Adding a cost attribute to Accommodation has a similar smell, combining cost per room and cost per person in a single attribute. Nevertheless, I would consider it if it could eliminate a set of subtypes - if we have no subtype-specific attributes, relationships or constraints, type can be indicated by an attribute, reducing the need to explicitly model each subtype.

In the third highlighted sentence, should the specified attributes be listed under each type of eatery or should they be added to the generalised entity Eatery?

I see no reason to list it separately for each eatery. Attributes, relationships and constraints that are common to all subtypes should be associated with the supertype.

For comparison, here's my model. I did it before looking at yours, so it takes a very different approach.

Some notes:

I renamed room facilities to features

Accommodation and Eatery are optional disjoint subtypes of Facility. This means we can have facilities which don't belong to either subtype, allowing me to handle reviews for other kinds of trip attractions using the same structure.

Visit is a ternary relationship, determined by User, Trip and Facility. Thus every Visit must belong to a Trip, even if it's just a one-visit Trip. On the plus side, multiple Users can partake in the same Trip.

Users can Visit a Facility more than once in different Trips, but not more than once per Trip. We could convert Visit from a relationship to an entity with a surrogate key to overcome this.

I hope this helps, let me know if I should clarify anything.

Title: Conceptual modelling scenario


来源: stackexchange

问:
Create swift closure and pass it to objective-c class as completion block
Now I'm adding Swift code on objective-C based iOS application.

But I have a problem in calling the objective-C method from Swift side.

I'd like to get and draw image on UIImageView in View or ViewController which is written with Swift.
On the other hand my wrapper class of Photos Library is written with objective-C.

My wrapper class of Photos Library is below.

・MyPhotoLibraryMgr.h

```<code>typedef void (^AppPhotoLibraryGetImageCompletion)(UIImage *image, NSError *error);

- (void)getImageWithTarget:(NSInteger)index
                targetSize:(CGSize)targetSize
                completion:(AppPhotoLibraryGetImageCompletion)completion;
</code>```

・MyPhotoLibraryMgr.m

```<code>- (void)getImageWithTarget:(NSInteger)index
                targetSize:(CGSize)targetSize
                completion:
(AppPhotoLibraryGetImageCompletion)completion
{
    PHAsset *asset = _myAsetsList[index];

    PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
    options.resizeMode = PHImageRequestOptionsResizeModeFast;
    options.deliveryMode = PHImageRequestOptionsDeliveryModeOpportunistic;

    [[PHImageManager defaultManager] requestImageForAsset:asset
                                               targetSize:targetSize
                                              contentMode:PHImageContentModeAspectFill
                                                  options:options
                                            resultHandler:^(UIImage *result, NSDictionary *info) {
                                                NSError *error = [info objectForKey:PHImageErrorKey];
                                                if (error) {
                                                    NSLog(@"error=%@", error);
                                                }
                                                completion(result, error);
                                            }];
}
</code>```

I can get and draw image in View or ViewController written by objective-C like below,

・MyViewController.m

```<code>AppPhotoLibraryMgr *photoLibMgr = [AppPhotoLibraryMgr sharedInstance];
AppPhotoLibraryGetImageCompletion completion = ^(UIImage *image, NSError *error) {
                imageView.image = image;
};

[[AppPhotoLibraryMgr sharedInstance] getImageWithTarget:index
                                             targetSize:imageView.frame.size
                                             completion:completion];
</code>```

But I can't get image in View or ViewController written in Swift.

・MySwiftViewController.swift

```<code>let completion = {(image: UIImage, error: NSError) -> AppPhotoLibraryGetImageCompletion in
    let imageView = UIImageView(image: image)
}

photoLibMgr?.getImageWithTarget(index, targetSize: size, completion: completion)
</code>```

Error message from Xcode is

Cannot convert value of type 'UIImage, NSError ->
  AppPhotoLibraryGetImageCompletion" to expected argument type
  'AppPhotoLibraryGetImageCompletion'

答:
The block typedef void (^AppPhotoLibraryGetImageCompletion)(UIImage *image, NSError *error); in objective-c has return type void.

But the counter part in your Swift has return type other than Void. The completion block should be like:

```<code>let completion = {(image: UIImage, error: NSError) -> Void in
    ...
    ...
}
</code>```

Use typealias for making your closure reusable.

Example:

```<code>typealias AppPhotoLibraryGetImageCompletion = (UIImage, NSError) -> Void

let completion: AppPhotoLibraryGetImageCompletion = { (image, error) in
    ...
    ...
}
</code>```

Edit: Different way

```<code>photoLibMgr?.getImageWithTarget(index, targetSize: size, completion: { (image, error) in
    ...
    ...
})
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Now I'm adding Swift code on objective-C based iOS application.

But I have a problem in calling the objective-C method from Swift side.

I'd like to get and draw image on UIImageView in View or ViewController which is written with Swift.
On the other hand my wrapper class of Photos Library is written with objective-C.

My wrapper class of Photos Library is below.

・MyPhotoLibraryMgr.h

typedef void (^AppPhotoLibraryGetImageCompletion)(UIImage *image, NSError *error);

- (void)getImageWithTarget:(NSInteger)index
                targetSize:(CGSize)targetSize
                completion:(AppPhotoLibraryGetImageCompletion)completion;

・MyPhotoLibraryMgr.m

- (void)getImageWithTarget:(NSInteger)index
                targetSize:(CGSize)targetSize
                completion:
(AppPhotoLibraryGetImageCompletion)completion
{
    PHAsset *asset = _myAsetsList[index];

    PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
    options.resizeMode = PHImageRequestOptionsResizeModeFast;
    options.deliveryMode = PHImageRequestOptionsDeliveryModeOpportunistic;

    [[PHImageManager defaultManager] requestImageForAsset:asset
                                               targetSize:targetSize
                                              contentMode:PHImageContentModeAspectFill
                                                  options:options
                                            resultHandler:^(UIImage *result, NSDictionary *info) {
                                                NSError *error = [info objectForKey:PHImageErrorKey];
                                                if (error) {
                                                    NSLog(@"error=%@", error);
                                                }
                                                completion(result, error);
                                            }];
}

I can get and draw image in View or ViewController written by objective-C like below,

・MyViewController.m

AppPhotoLibraryMgr *photoLibMgr = [AppPhotoLibraryMgr sharedInstance];
AppPhotoLibraryGetImageCompletion completion = ^(UIImage *image, NSError *error) {
                imageView.image = image;
};

[[AppPhotoLibraryMgr sharedInstance] getImageWithTarget:index
                                             targetSize:imageView.frame.size
                                             completion:completion];

But I can't get image in View or ViewController written in Swift.

・MySwiftViewController.swift

let completion = {(image: UIImage, error: NSError) -> AppPhotoLibraryGetImageCompletion in
    let imageView = UIImageView(image: image)
}

photoLibMgr?.getImageWithTarget(index, targetSize: size, completion: completion)

Error message from Xcode is

Cannot convert value of type 'UIImage, NSError ->
  AppPhotoLibraryGetImageCompletion" to expected argument type
  'AppPhotoLibraryGetImageCompletion'

Body:
The block typedef void (^AppPhotoLibraryGetImageCompletion)(UIImage *image, NSError *error); in objective-c has return type void.

But the counter part in your Swift has return type other than Void. The completion block should be like:

let completion = {(image: UIImage, error: NSError) -> Void in
    ...
    ...
}

Use typealias for making your closure reusable.

Example:

typealias AppPhotoLibraryGetImageCompletion = (UIImage, NSError) -> Void

let completion: AppPhotoLibraryGetImageCompletion = { (image, error) in
    ...
    ...
}

Edit: Different way

photoLibMgr?.getImageWithTarget(index, targetSize: size, completion: { (image, error) in
    ...
    ...
})


问:
Selenium returns unknownProtocolFound error
I'm trying to download an APK file from [this GooglePlay direct link generator][1] using Firefox Webdriver, Selenium and Python.

The problem is that, when Selenium is trying to get the home page, it crashes with the following error message:

```<code>/usr/bin/python2.7 /home/ghasemi/PycharmProjects/phorcys_watcher/main.py
http://apps.evozi.com/apk-downloader/?id=com.instagram.android
Traceback (most recent call last):
  File "/home/ghasemi/PycharmProjects/phorcys_watcher/main.py", line 7, in <module>
    content = google_play_download("com.instagram.android")
  File "/home/ghasemi/PycharmProjects/phorcys_watcher/collector.py", line 20, in google_play_download
    browser.get("https://apps.evozi.com/apk-downloader/?id=" + app_page_id)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 268, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=unknownProtocolFound&u=httpss%3A//www.adnetworkperformance.com/script/java.php%3Foption%3Drotateur%26r%3D411313%26treqn%3D1025813717%26runauction%3D1%26crr%3D168ce9d76b1a6695b12e%2CwcwHrNzGnshFns2PnM3bbcwGW8xLz-mNycwuvZjurZja3MzJfMxG_9xMX4wYns7a2YxHvshBL9xe3shbjN2J7umN6umNm-mNuN2czNw723956800778f24b2db6%26rtid%3D595b6ecb8ac19%26cbrandom%3D0.7519066097934798%26cbtitle%3DAPK%2520Downloader%2520%255BLatest%255D%2520Download%2520Directly%2520%257C%2520Chrome%2520Extension%2520v3%2520%28Evozi%2520Official%29%26cbiframe%3D0%26cbWidth%3D1280%26cbHeight%3D717%26cbdescription%3DDownload%2520APKs%2520Directly%2520From%2520Google%2520Play%2520To%2520Your%2520Computer%2520With%2520APK%2520Downloader%2520Extension%2520For%2520Google%2520Chrome%26cbkeywords%3D%26cbref%3D&c=&f=regular&d=Firefox%20doesn%E2%80%99t%20know%20how%20to%20open%20this%20address%2C%20because%20one%20of%20the%20following%20protocols%20%28httpss%29%20isn%E2%80%99t%20associated%20with%20any%20program%20or%20is%20not%20allowed%20in%20this%20context.
</code>```

The exception throws on this line:
    browser.get("https://apps.evozi.com/apk-downloader/?id=com.instagram.android")

As you see above, the origin of this error is a wrong link in the page that selenium is trying to download it. I found the frame that cause this error:

```<code><iframe width="468" height="60" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" allowfullscreen="true" style="border: medium none; padding: 0; margin: 0;" sandbox="allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-pointer-lock allow-same-origin" id="595b6e88086f8" frameborder="0" src="httpss://www.adnetworkperformance.com/script/java.php?option=rotateur&r=411313&treqn=501505383&runauction=1&crr=fc25086f39dc3c58bbdbGJTJyVGZh9Gbud3bk1yawFmRyUSbvNmLpp3b2VmLzBHchZkMlYkMlE0MlMHc0RHa2dfe473f7c304fd8fb65&rtid=595b6e88086f8&cbrandom=0.6676681852413189&cbtitle=APK%20Downloader%20%5BLatest%5D%20Download%20Directly%20%7C%20Chrome%20Extension%20v3%20(Evozi%20Official)&cbiframe=0&cbWidth=1522&cbHeight=741&cbdescription=Download%20APKs%20Directly%20From%20Google%20Play%20To%20Your%20Computer%20With%20APK%20Downloader%20Extension%20For%20Google%20Chrome&cbkeywords=&cbref=" scrolling="no"></iframe>
</code>```

As you can see, the webpage developer put httpss instead of https wrongly (twice!).

How can I handle this problem?

Update:

My scraper:

```<code>import requests
from lxml import html
from pyvirtualdisplay import Display
from selenium import webdriver

def google_play_download(app_page_id):
    browser = webdriver.Firefox()
    browser.get("https://apps.evozi.com/apk-downloader/?id=" + app_page_id)
    browser.find_element_by_css_selector(".btn.btn-primary.btn-lg.btn-block").click()
    apk_link = browser.find_element_by_css_selector(".btn.btn-success.btn-block").get_attribute('href')
    browser.quit()
    for rnd in range(5):
        resp = requests.get(apk_link)
        if resp.headers['Content-Length'] == str(len(resp.content)):
            return resp.content

if __name__ == "__main__":
    content = google_play_download("com.instagram.android")
    f = open('./file', 'wb')
    f.write(content)
    f.close()

  [1]: https://apps.evozi.com/apk-downloader/
</code>```

答:
The parser is not able to extract the proper url in this line apk_link = browser.find_element_by_css_selector(".btn.btn-success.btn-block").get_attribute('href')

As when you print the url its showing https://apps.evozi.com/apk-downloader/?id=com.instagram.android

Just change the line to

```<code>apk_link = browser.find_element_by_css_selector(".btn.btn-success.btn-block")
ele=apk_link.get_attribute('href')

for rnd in range(5):
      resp = requests.get(ele)
      if resp.headers['Content-Length'] == str(len(resp.content)):
            return resp.content
</code>```

The code will work without error

Body:
I'm trying to download an APK file from [this GooglePlay direct link generator][1] using Firefox Webdriver, Selenium and Python.

The problem is that, when Selenium is trying to get the home page, it crashes with the following error message:

/usr/bin/python2.7 /home/ghasemi/PycharmProjects/phorcys_watcher/main.py
http://apps.evozi.com/apk-downloader/?id=com.instagram.android
Traceback (most recent call last):
  File "/home/ghasemi/PycharmProjects/phorcys_watcher/main.py", line 7, in <module>
    content = google_play_download("com.instagram.android")
  File "/home/ghasemi/PycharmProjects/phorcys_watcher/collector.py", line 20, in google_play_download
    browser.get("https://apps.evozi.com/apk-downloader/?id=" + app_page_id)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 268, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=unknownProtocolFound&u=httpss%3A//www.adnetworkperformance.com/script/java.php%3Foption%3Drotateur%26r%3D411313%26treqn%3D1025813717%26runauction%3D1%26crr%3D168ce9d76b1a6695b12e%2CwcwHrNzGnshFns2PnM3bbcwGW8xLz-mNycwuvZjurZja3MzJfMxG_9xMX4wYns7a2YxHvshBL9xe3shbjN2J7umN6umNm-mNuN2czNw723956800778f24b2db6%26rtid%3D595b6ecb8ac19%26cbrandom%3D0.7519066097934798%26cbtitle%3DAPK%2520Downloader%2520%255BLatest%255D%2520Download%2520Directly%2520%257C%2520Chrome%2520Extension%2520v3%2520%28Evozi%2520Official%29%26cbiframe%3D0%26cbWidth%3D1280%26cbHeight%3D717%26cbdescription%3DDownload%2520APKs%2520Directly%2520From%2520Google%2520Play%2520To%2520Your%2520Computer%2520With%2520APK%2520Downloader%2520Extension%2520For%2520Google%2520Chrome%26cbkeywords%3D%26cbref%3D&c=&f=regular&d=Firefox%20doesn%E2%80%99t%20know%20how%20to%20open%20this%20address%2C%20because%20one%20of%20the%20following%20protocols%20%28httpss%29%20isn%E2%80%99t%20associated%20with%20any%20program%20or%20is%20not%20allowed%20in%20this%20context.

The exception throws on this line:
    browser.get("https://apps.evozi.com/apk-downloader/?id=com.instagram.android")

As you see above, the origin of this error is a wrong link in the page that selenium is trying to download it. I found the frame that cause this error:

<iframe width="468" height="60" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" allowfullscreen="true" style="border: medium none; padding: 0; margin: 0;" sandbox="allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-pointer-lock allow-same-origin" id="595b6e88086f8" frameborder="0" src="httpss://www.adnetworkperformance.com/script/java.php?option=rotateur&r=411313&treqn=501505383&runauction=1&crr=fc25086f39dc3c58bbdbGJTJyVGZh9Gbud3bk1yawFmRyUSbvNmLpp3b2VmLzBHchZkMlYkMlE0MlMHc0RHa2dfe473f7c304fd8fb65&rtid=595b6e88086f8&cbrandom=0.6676681852413189&cbtitle=APK%20Downloader%20%5BLatest%5D%20Download%20Directly%20%7C%20Chrome%20Extension%20v3%20(Evozi%20Official)&cbiframe=0&cbWidth=1522&cbHeight=741&cbdescription=Download%20APKs%20Directly%20From%20Google%20Play%20To%20Your%20Computer%20With%20APK%20Downloader%20Extension%20For%20Google%20Chrome&cbkeywords=&cbref=" scrolling="no">

As you can see, the webpage developer put httpss instead of https wrongly (twice!).

How can I handle this problem?

Update:

My scraper:

import requests
from lxml import html
from pyvirtualdisplay import Display
from selenium import webdriver

def google_play_download(app_page_id):
    browser = webdriver.Firefox()
    browser.get("https://apps.evozi.com/apk-downloader/?id=" + app_page_id)
    browser.find_element_by_css_selector(".btn.btn-primary.btn-lg.btn-block").click()
    apk_link = browser.find_element_by_css_selector(".btn.btn-success.btn-block").get_attribute('href')
    browser.quit()
    for rnd in range(5):
        resp = requests.get(apk_link)
        if resp.headers['Content-Length'] == str(len(resp.content)):
            return resp.content

if __name__ == "__main__":
    content = google_play_download("com.instagram.android")
    f = open('./file', 'wb')
    f.write(content)
    f.close()

  [1]: https://apps.evozi.com/apk-downloader/

Body:
The parser is not able to extract the proper url in this line apk_link = browser.find_element_by_css_selector(".btn.btn-success.btn-block").get_attribute('href')

As when you print the url its showing https://apps.evozi.com/apk-downloader/?id=com.instagram.android

Just change the line to

apk_link = browser.find_element_by_css_selector(".btn.btn-success.btn-block")
ele=apk_link.get_attribute('href')

for rnd in range(5):
      resp = requests.get(ele)
      if resp.headers['Content-Length'] == str(len(resp.content)):
            return resp.content

The code will work without error


问:
How to make a 'struct' Nullable by definition?
```<code>struct AccountInfo
{
   String Username;
   String Password;
}
</code>```

now if I want to have a Nullable instance I should write:

```<code>Nullable<AccountInfo> myAccount = null;
</code>```

But I want make the struct Nullable by nature and it can be used like this (without use of Nullable<T>):

```<code>AccountInfo myAccount = null;
</code>```

答:
The short answer: Make it a class.

The long answer: This structure is mutable which structs should never be, doesn't represent a single value which structs always should, and has no sensible 'zero' value which structs also always should, so it probably shouldn't be a value type. Making it a class (reference type) means that it is always possible for it to be null.

Note: Use of words such as "never" and "always" should be taken with an implied "almost".

ContentLicense: CC BY-SA 2.5

Body:
struct AccountInfo
{
   String Username;
   String Password;
}

now if I want to have a Nullable instance I should write:

Nullable<AccountInfo> myAccount = null;

But I want make the struct Nullable by nature and it can be used like this (without use of Nullable<T>):

AccountInfo myAccount = null;


问:
combining two php variables
```<code>    $current_month  = date('M');
    for($m=1; $m<=$current_month; ++$m)
    {
        $monthNamelower=strtolower(date('M', mktime(0, 0, 0, $m, 1))).'';

            if ($jandata!='')
            {
              echo $jandata;
            }

        echo $data2jan;
    }
</code>```

can i replace the month jan with the variable $monthNamelower?

I tried something like this but not working

```<code>    if ('$'.$monthNamelower.'data'!='')
    {
            echo '$'.$monthNamelower.'data';

    }
    echo '$data2'.$monthNamelower;
</code>```

答:
You can do this by making your variable name as dynamic
Just like this

```<code>$monthNamelower.='data';
if ($$t!='')
    {
echo $$t;

}
</code>```

For Example:-

```<code>$t='jan';
$jandate='good';
$t.='date';
echo $$t;
</code>```

It will produce output like

I thing it will help you.

Title: combining two php variables

Body:
    $current_month  = date('M');
    for($m=1; $m<=$current_month; ++$m)
    {
        $monthNamelower=strtolower(date('M', mktime(0, 0, 0, $m, 1))).'';

            if ($jandata!='')
            {
              echo $jandata;
            }

        echo $data2jan;
    }

can i replace the month jan with the variable $monthNamelower?

I tried something like this but not working

    if ('$'.$monthNamelower.'data'!='')
    {
            echo '$'.$monthNamelower.'data';

    }
    echo '$data2'.$monthNamelower;

Body:
You can do this by making your variable name as dynamic
Just like this

$monthNamelower.='data';
if ($$t!='')
    {
echo $$t;

}

For Example:-

$t='jan';
$jandate='good';
$t.='date';
echo $$t;

It will produce output like

I thing it will help you.


问:
SpriteKit - get absolute size of SKNode
I'm programming a small game in Swift and SpriteKit, which is made of a boxes (4 * 8).

```<code>Scene (1024 * 768)
    boxes (964 * 452)
        row1 (932 * 25)
            col1 (24 * 116)
            col2 (24 * 116)
            col3 (24 * 116)
            ...
        row2...
</code>```

I want to give them a texture, but I don't know how big the image file should be. And the box node's size seems to be relative to its parent node. How can I get the absolute size of an SKNode, the size the node takes on the screen?

答:
Any texture will be scaled to fill the Node. Just make sure the aspect ratio of the texture and the node are the same (e.g. make them both square).

The "size" property of a Node works! For example:

```<code>let test = SKSpriteNode(color: .clear, size: CGSize(width: 100.0, height: 100.0))
print(test.size)
test.setScale(2.0)
print(test.size)
</code>```

correctly prints:

```<code>(100.0, 100.0)
(200.0, 200.0)
</code>```

Title: SpriteKit - get absolute size of SKNode

Body:
I'm programming a small game in Swift and SpriteKit, which is made of a boxes (4 * 8).

Scene (1024 * 768)
    boxes (964 * 452)
        row1 (932 * 25)
            col1 (24 * 116)
            col2 (24 * 116)
            col3 (24 * 116)
            ...
        row2...

I want to give them a texture, but I don't know how big the image file should be. And the box node's size seems to be relative to its parent node. How can I get the absolute size of an SKNode, the size the node takes on the screen?

Body:
Any texture will be scaled to fill the Node. Just make sure the aspect ratio of the texture and the node are the same (e.g. make them both square).

The "size" property of a Node works! For example:

let test = SKSpriteNode(color: .clear, size: CGSize(width: 100.0, height: 100.0))
print(test.size)
test.setScale(2.0)
print(test.size)

correctly prints:

(100.0, 100.0)
(200.0, 200.0)


问:
Extracting common chunks amongst multiple compiler configurations in webpack?
I'm trying out the multi-compiler option in webpack and am following the example at their github. However, I can't seem to understand how I can split out the common code amongst the multiple configurations.

For example, I may have same vendor libraries used in the different set of configurations. I would like to have these shared codes to be bundled to one single common file.

I tried the following but it ended up creating an individual bundles of the vendors entry for each compile configuration.

```<code>var path = require("path");
var webpack = require("webpack");
module.exports = [
    {
        name: "app-mod1",
        entry: {
            vendors: ['jquery', 'react', 'react-dom'],
            pageA: ['./mod1/pageA'],
            pageB: ['./mod1/pageB']
        },
        output: {
            path: path.join(__dirname, "/mod1/js"),
            filename: "[name].bundle.js"
        },
        plugins: [
            new webpack.optimize.CommonsChunkPlugin({
                names: ['vendors'],
                minChunks: Infinity
            })
        ]
    },
    {
        name: "app-mod2",
        entry: {
            vendors: ['lodash', 'react', 'react-dom'],
            pageA: ['./mod2/pageA'],
            pageB: ['./mod2/pageB']
        },
        output: {
            path: path.join(__dirname, "/mod2/js"),
            filename: "[name].bundle.js"
        },
        plugins: [
            new webpack.optimize.CommonsChunkPlugin({
                names: ['vendors'],
                minChunks: Infinity
            })
        ]
    }
];
</code>```

Since react, react-dom are shared between the 2 compilations, my intention is for them to be bundled as a single file which can be shared instead of creating a same bundle for each compilation.

How can I extract the common chunks out of multiple compiler configurations?

答:
I learned about it now, and this topic seems quite hard to understand in webpack docs. I managed to create something that works, as it created 2 separate files and extracted the common dependencies to another file.

Here is my webpack config:

```<code>{
    entry: {

        pageA: "./first/first",
        pageB: "./second/second"
    },
    output: {
        path: path.join(__dirname, "js"),
        filename: "[name].js"
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            names: ["vendor", "common"],
        })
    ]
};
</code>```

the output of this will be:

```<code>./js/
    common.js
    vendor.js
    pageA.js
    pageB.js
</code>```

I created a repo with the example I worked on: https://github.com/tzookb/webpack-common-vendor-chunks

when I open a new html file I load these files:

```<code> first page:
     common.js
     vendor.js
     pageA.js

 sec page:
     common.js
     vendor.js
     pageB.js
</code>```

Body:
I'm trying out the multi-compiler option in webpack and am following the example at their github. However, I can't seem to understand how I can split out the common code amongst the multiple configurations.

For example, I may have same vendor libraries used in the different set of configurations. I would like to have these shared codes to be bundled to one single common file.

I tried the following but it ended up creating an individual bundles of the vendors entry for each compile configuration.

var path = require("path");
var webpack = require("webpack");
module.exports = [
    {
        name: "app-mod1",
        entry: {
            vendors: ['jquery', 'react', 'react-dom'],
            pageA: ['./mod1/pageA'],
            pageB: ['./mod1/pageB']
        },
        output: {
            path: path.join(__dirname, "/mod1/js"),
            filename: "[name].bundle.js"
        },
        plugins: [
            new webpack.optimize.CommonsChunkPlugin({
                names: ['vendors'],
                minChunks: Infinity
            })
        ]
    },
    {
        name: "app-mod2",
        entry: {
            vendors: ['lodash', 'react', 'react-dom'],
            pageA: ['./mod2/pageA'],
            pageB: ['./mod2/pageB']
        },
        output: {
            path: path.join(__dirname, "/mod2/js"),
            filename: "[name].bundle.js"
        },
        plugins: [
            new webpack.optimize.CommonsChunkPlugin({
                names: ['vendors'],
                minChunks: Infinity
            })
        ]
    }
];

Since react, react-dom are shared between the 2 compilations, my intention is for them to be bundled as a single file which can be shared instead of creating a same bundle for each compilation.

How can I extract the common chunks out of multiple compiler configurations?

Body:
I learned about it now, and this topic seems quite hard to understand in webpack docs. I managed to create something that works, as it created 2 separate files and extracted the common dependencies to another file.

Here is my webpack config:

{
    entry: {

        pageA: "./first/first",
        pageB: "./second/second"
    },
    output: {
        path: path.join(__dirname, "js"),
        filename: "[name].js"
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            names: ["vendor", "common"],
        })
    ]
};

the output of this will be:

./js/
    common.js
    vendor.js
    pageA.js
    pageB.js

I created a repo with the example I worked on: https://github.com/tzookb/webpack-common-vendor-chunks

when I open a new html file I load these files:

 first page:
     common.js
     vendor.js
     pageA.js

 sec page:
     common.js
     vendor.js
     pageB.js


问:
How to get the current day and last day of the current month
I'm just a beginner !! I need a html number input, with today's day of the month as the minimum value and number of day's of the current month as the maximum value.

In PHP I declare $today = date ('Y-m-d,time()); to read the date today  and i don't know how to declare the value of the day of the month in <Input type="number" min="" max="" /> as a minimum number?

答:
```<code><Input type="number" min="<?= date('d') ?>" max="<?= date('t') ?>" />
</code>```

I think this one help you...

Body:
<Input type="number" min="<?= date('d') ?>" max="<?= date('t') ?>" />

I think this one help you...


问:
How to instantiate the result of a function that returns an extended class?
How in Jasmine test this code, method getNumber

```<code>const PageFactory = SuperClass => class extends SuperClass {

getNumber() {
.......
 }
</code>```

I tried through new PageFactory(null) and PageFactory.getNumber, write

```<code>TypeError is not a constructor(evaluating 'PageFactory.getNumber()) or  _pageFactory["default"].getNumber()
</code>```

答:
PageFactory is a factory function that creates constructor.

```<code>class TestClass { // stub class

}

const Paged = PageFactory(TestClass) // create new class using stub

const pagedInstance = new Paged() // create an instance

pagedInstance.getNumber() // <-- test getNumber method
</code>```

Body:
How in Jasmine test this code, method getNumber

const PageFactory = SuperClass => class extends SuperClass {

getNumber() {
.......
 }

I tried through new PageFactory(null) and PageFactory.getNumber, write

TypeError is not a constructor(evaluating 'PageFactory.getNumber()) or  _pageFactory["default"].getNumber()

Body:
PageFactory is a factory function that creates constructor.

class TestClass { // stub class

}

const Paged = PageFactory(TestClass) // create new class using stub

const pagedInstance = new Paged() // create an instance

pagedInstance.getNumber() // <-- test getNumber method


问:
Detect if stdout is redirected to a pipe (not to a file, character device, terminal, or socket)?
Ideally, this would be scriptable in shell, but Perl or Python would be fine.
C code could be helpful, but probably fails cost/benefit.

I recognize that redirection to a FIFO (named pipe) may be indistinguishable from a real pipe,
and that is enough of an edge case that I don't really care.

Strict POSIX solutions are best, UNIX/Linux variant-independent are next best, but at least something that works on Darwin (MacOS X) is what I need right now.

Before you write your answer - I already know about test -t - that will tell me whether stdout is a terminal (in which case it is definitely not a pipe - but it will not tell me whether stdout has been redirected to a file, non-terminal character device, or UNIX-domain socket rather than a pipe.

Intended use case: I have a command that should be run within backquotes in the shell,
so that it can output commands that set environment variables.
I would like the command to abort with an error if stdout is not redirected to a pipe,
as in that case it definitely wasn't invoked by eval `mycommand`;.

If there's some special environment variable that a shell will set when running a command within backquotes that would be helpful, but as it is likely to be specific to bash or zsh or something, pipe-detection is more important.

答:
In Python:

```<code>import sys
print sys.stdout.isatty()
</code>```

Examples:

```<code>$ ./a
True
$ ./a | less
False
</code>```

ContentLicense: CC BY-SA 4.0

Body:
In Python:

import sys
print sys.stdout.isatty()

Examples:

$ ./a
True
$ ./a | less
False


问:
causing a java.IllegalStateException error, No Activity, only when navigating to Fragment for the SECOND time
I am getting a very puzzling bug that I have no idea how to even begin working through.

I have a simple app with one activity, the views are implemented with Fragments.  One of the fragments has a ViewPager inside of it; so I decided I that I wanted to use the getChildFragmentManager class of the v4 support library.  I also had to use ActionBarSherlock, which caused a problem, because it does not ship with the v11 of the v4 library.

I fixed this by replacing the v4 support library in ABS with the v11 library, and everything compiled and appeared to be working, including the ViewPager.

Here is the strange part:

The first time the fragment with the ViewPager opens, it works properly; but the SECOND time it is navigated to, the app crashes, giving a useless stack trace.  From debugging, I discovered that the problem was with the FragmentManager returned by getChildFragmentManager; it throws the No Activity error.

Does anybody have any idea what could be causing this?

I will post code that you think is relevant.

Thank you,
David

答:
I am stuck with the same bug using BottomNavigationView switch and replacement of fragment causing App crash. With normal speed it was working perfectly fine, if the user do fast switch it used to crash saying

IllegalStateException No Activity

in Logs

Before I have

```<code>fragmentA = new FragmentA();
fragmentB = new FragmentB();
fragmentC = new FragmentC();

mBottomNavigationView.setOnNavigationItemSelectedListener(item -> {
        switch (item.getItemId()) {
   case R.id.fragmentA:
         replaceFragment(fragmentA);
   case R.id.fragmentB:
        repalceFragment(fragmentB);
   case R.id.fragmentC:
        repalceFragment(fragmentC);
   }
};
</code>```

I think this pre-creation of fragment and using them was for replace is creating the issue, now I made it to re-create everytime. It started working fine

```<code>mBottomNavigationView.setOnNavigationItemSelectedListener(item -> {
        switch (item.getItemId()) {
   case R.id.fragmentA:
        fragment = new FragmentA();
         replaceFragment(fragment);
   case R.id.fragmentB:
        fragment = new FragmentB();
        repalceFragment(fragment);
   case R.id.fragmentC:
        fragment = new FragmentC();
        repalceFragment(fragment);
   }
};

 public void repalceFragment(Fragment fragment) {
    if (!this.isFinishing()) {
        if (!fragment.isAdded()) {
            if (!this.mDisplayedFragment.isRemoving()) {
                getFragmentManager().beginTransaction().replace(R.id.layout_fragment_container, fragment).commit();
                this.mDisplayedFragment = fragment;
            }
        }
    }
}
</code>```

Hope its helpful for some, I did too much of defensive coding but it solved my issue of fast switching of fragments

Body:
I am stuck with the same bug using BottomNavigationView switch and replacement of fragment causing App crash. With normal speed it was working perfectly fine, if the user do fast switch it used to crash saying

IllegalStateException No Activity

in Logs

Before I have

fragmentA = new FragmentA();
fragmentB = new FragmentB();
fragmentC = new FragmentC();

mBottomNavigationView.setOnNavigationItemSelectedListener(item -> {
        switch (item.getItemId()) {
   case R.id.fragmentA:
         replaceFragment(fragmentA);
   case R.id.fragmentB:
        repalceFragment(fragmentB);
   case R.id.fragmentC:
        repalceFragment(fragmentC);
   }
};

I think this pre-creation of fragment and using them was for replace is creating the issue, now I made it to re-create everytime. It started working fine

mBottomNavigationView.setOnNavigationItemSelectedListener(item -> {
        switch (item.getItemId()) {
   case R.id.fragmentA:
        fragment = new FragmentA();
         replaceFragment(fragment);
   case R.id.fragmentB:
        fragment = new FragmentB();
        repalceFragment(fragment);
   case R.id.fragmentC:
        fragment = new FragmentC();
        repalceFragment(fragment);
   }
};

 public void repalceFragment(Fragment fragment) {
    if (!this.isFinishing()) {
        if (!fragment.isAdded()) {
            if (!this.mDisplayedFragment.isRemoving()) {
                getFragmentManager().beginTransaction().replace(R.id.layout_fragment_container, fragment).commit();
                this.mDisplayedFragment = fragment;
            }
        }
    }
}

Hope its helpful for some, I did too much of defensive coding but it solved my issue of fast switching of fragments


问:
How to use webp image format in HTML
I know this is a new format for images, but I don't know how to show it in HTML.

Does anyone know how I can do that? Which browsers can show this image format besides chrome?

sample-webp-image.webp

答:
You use webp like any image:

```<code><img src="img.webp" />
</code>```

However since it's not always supported (see http://caniuse.com/#feat=webp), you can use this to set a fallback:

```<code><picture>
  <source srcset="img.webp" type="image/webp">
  <source srcset="img.jpg" type="image/jpeg">
  <img src="img.jpg">
</picture>
</code>```

Title: How to use webp image format in HTML

Body:
You use webp like any image:

<img src="img.webp" />

However since it's not always supported (see http://caniuse.com/#feat=webp), you can use this to set a fallback:

<picture>
  <source srcset="img.webp" type="image/webp">
  <source srcset="img.jpg" type="image/jpeg">
  <img src="img.jpg">
</picture>


问:
Send html table in outlook mail via Python
I have a code which uses win32com to open Outlook and send mail.
I am trying to send a table which is in myexample.html file to a recipient.
However when I use

```<code>msg.body=open('myexample.html').read()
</code>```

This is what comes in the mail that I've sent

```<code>table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th>DG Lead</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Krishnamurthy Ramamurthy</td>
      <td>324</td>
>
    <tr>
</code>```

But I want a table view of this.
How can I get that?

答:
Figured out the answer to it.
Just need to alter </p>

```<code>msg.body = body
</code>```

<p>to </p>

```<code>msg.HTMLBody  = body
</code>```

Body:
I have a code which uses win32com to open Outlook and send mail.
I am trying to send a table which is in myexample.html file to a recipient.
However when I use

msg.body=open('myexample.html').read()

This is what comes in the mail that I've sent

table border="1" class="dataframe">

      DG Lead

      Krishnamurthy Ramamurthy
      324
>

But I want a table view of this.
How can I get that?

Body:
Figured out the answer to it.
Just need to alter

msg.body = body

to

msg.HTMLBody  = body


问:
SQL Select SQL Statement output + ( )
Table Name: aa_company

```<code>Column_A    Column_B    Column_C
ABC         0001        abc@gmail.com

BCD         0002        bcd@gmail.com

CDE         0003        cde@gmail.com

Select Column_A, Column_B, Column_C
FROM aa_company;
</code>```

if I want the output result add one more column, how can i do it?

```<code>Column_A    Column_B    Column_C          Column_D
ABC         0001        abc@gmail.com     ABC (0001)

BCD         0002        bcd@gmail.com     BCD (0002)

CDE         0003        cde@gmail.com     CDE (0003)
</code>```

答:
Using the concat funcation you can achieve the required result.</p>

```<code>Select Column_A, Column_B, Column_C,
concat(column_A,' ('+column_B+')') as Column_D
from aa_company
</code>```

Title: SQL Select SQL Statement output + ( )

Body:
Table Name: aa_company

Column_A    Column_B    Column_C
ABC         0001        abc@gmail.com

BCD         0002        bcd@gmail.com

CDE         0003        cde@gmail.com

Select Column_A, Column_B, Column_C
FROM aa_company;

if I want the output result add one more column, how can i do it?

Column_A    Column_B    Column_C          Column_D
ABC         0001        abc@gmail.com     ABC (0001)

BCD         0002        bcd@gmail.com     BCD (0002)

CDE         0003        cde@gmail.com     CDE (0003)

Body:
Using the concat funcation you can achieve the required result.

Select Column_A, Column_B, Column_C,
concat(column_A,' ('+column_B+')') as Column_D
from aa_company


问:
Nested array error
I know this is a really newbie question but it has thrown me for days and I can't seem to find a solution that I actually understand.

I am trying to make a nested array to store latitude and longitude, however it Xcode/playground throws a EXC_BAD_INSTRUCTION error.

I want to declare, initialise and print the contents of an array. What am I doing wrong?

```<code>var arrayLocations:[[Float]] = []

arrayLocations[0] = [27.1750199, 78.0399665]

print("\(arrayLocations[0][0]) and \(arrayLocations[0][1])")
</code>```

答:
You cannot assign value into 0 position because index 0 is empty.

You can do this in following ways -

With initial value -

```<code>var arrayLocations:[[Float]] = [[0.00,0.00]]

arrayLocations[0] = [27.1750199, 78.0399665]

print("\(arrayLocations[0][0]) and \(arrayLocations[0][1])")
</code>```

Otherwise you can do this using append or insert as vadian's answer.

Title: Nested array error

Body:
I know this is a really newbie question but it has thrown me for days and I can't seem to find a solution that I actually understand.

I am trying to make a nested array to store latitude and longitude, however it Xcode/playground throws a EXC_BAD_INSTRUCTION error.

I want to declare, initialise and print the contents of an array. What am I doing wrong?

var arrayLocations:[[Float]] = []

arrayLocations[0] = [27.1750199, 78.0399665]

print("\(arrayLocations[0][0]) and \(arrayLocations[0][1])")

Body:
You cannot assign value into 0 position because index 0 is empty.

You can do this in following ways -

With initial value -

var arrayLocations:[[Float]] = [[0.00,0.00]]

arrayLocations[0] = [27.1750199, 78.0399665]

print("\(arrayLocations[0][0]) and \(arrayLocations[0][1])")

Otherwise you can do this using append or insert as vadian's answer.


问:
CSS 3 : Image doesn't get 100% of div
I have a div in which I am displaying an image. The image is bigger than its contained div.

somehow I get space to top and bottom of the image.

.image_contain_div {
  height: 130px;
  padding: 5px;
  width: 180px;
  border: thin black solid;
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}
.image_contain_div .image_div {
  background: #000;
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
  height: 100%;
  width: 100%;
  position: relative;
}
.image_contain_div .image_div .custom_website_default_image_div {
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}
.image_contain_div .image_div .custom_website_default_image_div svg {
  width: 26px;
  height: 26px;
}
.image_contain_div .image_div img {
  max-width: 100%;
  max-height: 100%;
}
.image_contain_div .image_div .custom_website_image_overlay_div {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
}
.image_contain_div .image_div .custom_website_image_overlay_div svg {
  width: 30px;
  height: 30px;
}
.image_contain_div .image_div:hover .custom_website_image_overlay_div {
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="image_contain_div b">
    <div class="image_div ">

        <img src="https://d28hsb6vkzynsw.cloudfront.net/banner/2877/500/99041_banner_testfile.jpeg" alt="">

        <div class="custom_website_image_overlay_div">
            <span class="cursor_pointer">
                <svg  class="v-middle" style="enable-background:new 0 0 33.004 33.004;" viewBox="0 0 33.004 33.004"  x="0px" xmlns="http://www.w3.org/2000/svg" y="0px">
                    <path  d="M33.004,15.414H17.59V0h-2.176v15.414H0v2.176h15.414v15.414h2.176V17.59h15.414V15.414z" style="fill:#fff;"></path>
                </svg>
            </span>
        </div>

    </div>
</div></code>```

I want to cover the image to the black background div.

Note : If image is smaller than the div then it should be in the middle of the div.

Any help would be great.

Thank You.

答:
.image_contain_div {
  height: 130px;
  padding: 5px;
  width: 180px;
  border: thin black solid;
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}
.image_contain_div .image_div {
  background: #000;
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
  height: 100%;
  width: 100%;
  position: relative;
}
.image_contain_div .image_div .custom_website_default_image_div {
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}
.image_contain_div .image_div .custom_website_default_image_div svg {
  width: 100%;
  height: 100%;
}
.image_contain_div .image_div img {
  width: 100%;
  height: 100%;
}
.image_contain_div .image_div .custom_website_image_overlay_div {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
}
.image_contain_div .image_div .custom_website_image_overlay_div svg {
  width: 30px;
  height: 30px;
}
.image_contain_div .image_div:hover .custom_website_image_overlay_div {
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="image_contain_div b">
                                        <div class="image_div ">

                                          <img src="https://d28hsb6vkzynsw.cloudfront.net/banner/2877/500/99041_banner_testfile.jpeg" alt="">

                                          <div class="custom_website_image_overlay_div">
                                            <span class="cursor_pointer">
                                              <svg  class="v-middle" style="enable-background:new 0 0 33.004 33.004;" viewBox="0 0 33.004 33.004"  x="0px" xmlns="http://www.w3.org/2000/svg" y="0px">
                                                <path  d="M33.004,15.414H17.59V0h-2.176v15.414H0v2.176h15.414v15.414h2.176V17.59h15.414V15.414z" style="fill:#fff;"></path>
                                              </svg>
                                            </span>

                                          </div>

                                        </div>
                                      </div></code>```

Title: CSS 3 : Image doesn't get 100% of div

Body:
I have a div in which I am displaying an image. The image is bigger than its contained div.

somehow I get space to top and bottom of the image.

.image_contain_div {
  height: 130px;
  padding: 5px;
  width: 180px;
  border: thin black solid;
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}
.image_contain_div .image_div {
  background: #000;
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
  height: 100%;
  width: 100%;
  position: relative;
}
.image_contain_div .image_div .custom_website_default_image_div {
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}
.image_contain_div .image_div .custom_website_default_image_div svg {
  width: 26px;
  height: 26px;
}
.image_contain_div .image_div img {
  max-width: 100%;
  max-height: 100%;
}
.image_contain_div .image_div .custom_website_image_overlay_div {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
}
.image_contain_div .image_div .custom_website_image_overlay_div svg {
  width: 30px;
  height: 30px;
}
.image_contain_div .image_div:hover .custom_website_image_overlay_div {
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}

                <svg  class="v-middle" style="enable-background:new 0 0 33.004 33.004;" viewBox="0 0 33.004 33.004"  x="0px" xmlns="http://www.w3.org/2000/svg" y="0px">
                    <path  d="M33.004,15.414H17.59V0h-2.176v15.414H0v2.176h15.414v15.414h2.176V17.59h15.414V15.414z" style="fill:#fff;"></path>
                </svg>

I want to cover the image to the black background div.

Note : If image is smaller than the div then it should be in the middle of the div.

Any help would be great.

Thank You.

Body:
.image_contain_div {
  height: 130px;
  padding: 5px;
  width: 180px;
  border: thin black solid;
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}
.image_contain_div .image_div {
  background: #000;
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
  height: 100%;
  width: 100%;
  position: relative;
}
.image_contain_div .image_div .custom_website_default_image_div {
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}
.image_contain_div .image_div .custom_website_default_image_div svg {
  width: 100%;
  height: 100%;
}
.image_contain_div .image_div img {
  width: 100%;
  height: 100%;
}
.image_contain_div .image_div .custom_website_image_overlay_div {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
}
.image_contain_div .image_div .custom_website_image_overlay_div svg {
  width: 30px;
  height: 30px;
}
.image_contain_div .image_div:hover .custom_website_image_overlay_div {
  /* Firefox */
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-pack: center;
  -moz-box-align: center;
  /* Safari and Chrome */
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  /* W3C */
  display: box;
  box-orient: horizontal;
  box-pack: center;
  box-align: center;
  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient: horizontal;
}

<div class="image_contain_div b">
                                        <div class="image_div ">

                                          <img src="https://d28hsb6vkzynsw.cloudfront.net/banner/2877/500/99041_banner_testfile.jpeg" alt="">

                                          <div class="custom_website_image_overlay_div">
                                            <span class="cursor_pointer">
                                              <svg  class="v-middle" style="enable-background:new 0 0 33.004 33.004;" viewBox="0 0 33.004 33.004"  x="0px" xmlns="http://www.w3.org/2000/svg" y="0px">
                                                <path  d="M33.004,15.414H17.59V0h-2.176v15.414H0v2.176h15.414v15.414h2.176V17.59h15.414V15.414z" style="fill:#fff;"></path>
                                              </svg>
                                            </span>

                                          </div>

                                        </div>
                                      </div>


问:
C++ all AT command's for SMS return's ERROR | PC<->Mobile connection via bluetooth & winsocket
I'm creating windows application in C++, which connect's PC with mobile via bluetooth and winsock. Allow's you to call and send messages from mobile via computer.

I'm using AT command's to tell mobile what i want to do. Pair with mobile device and force a call with At command

```<code>ATD+420******;
</code>```

works perfect, but all commands for handling SMS like

```<code>AT+CMGL, AT+CMGF, AT+CMGS etc.
</code>```

return's ERROR.

Here is code which connects PC with mobile via bluetooth and socket:

```<code>SOCKADDR_BTH RemoteEndPoint;
RemoteEndPoint.port = 0;
RemoteEndPoint.addressFamily = AF_BTH;
RemoteEndPoint.btAddr = m_foundDevices[m_deviceIndex].Address.ullLong;
RemoteEndPoint.serviceClassId = HandsfreeServiceClass_UUID;
int BTHAddrLength = sizeof(RemoteEndPoint);

// Create the socket.
if ((m_localSocket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM)) == INVALID_SOCKET)
{
    // handle error.
}

// Connect the socket.
if ((iResult = connect(m_localSocket, (SOCKADDR *)&RemoteEndPoint, sizeof(RemoteEndPoint))) == INVALID_SOCKET)
{
    // handle error.
}
</code>```

Notice line

```<code>RemoteEndPoint.serviceClassId = HandsfreeServiceClass_UUID
</code>```

I think the problem is here, becouse u cant send sms from Handsfree, but when i use another UUID, it doesnt even pair with mobile.

=== Here is just for info, how am i sending and receiving data from mobile ===

```<code>char recvbuf[DEFAULT_BUFLEN] = "";
const char *sendbuf = "AT+CMGL\r";
int len = (int)strlen(sendbuf);
if ((iResult = send(m_localSocket, sendbuf, len, MSG_OOB)) == SOCKET_ERROR)
{
    // handle error. return ~0
}

if ((iResult = recv(m_localSocket, recvbuf, recvbuflen, 0)) == SOCKET_ERROR)
{
    // handle error. return ~0
}
// Here recvbuf == "\r\nERROR\r\n"
</code>```

Thank you for any advices! If you have any question's about problem, i'll kindly explain.
Regards,
Filip.

答:
I found out, that the problem is in specifying UUID for connection.

I used RemoteEndPoint.serviceClassId = HandsfreeServiceClass_UUID;

and that's the thing, u can't send SMS from Handsfree, you can just call, so any advice which UUID should i use, so SMS AT commands should work ?

Thank you.

Body:
I'm creating windows application in C++, which connect's PC with mobile via bluetooth and winsock. Allow's you to call and send messages from mobile via computer.

I'm using AT command's to tell mobile what i want to do. Pair with mobile device and force a call with At command

ATD+420******;

works perfect, but all commands for handling SMS like

AT+CMGL, AT+CMGF, AT+CMGS etc.

return's ERROR.

Here is code which connects PC with mobile via bluetooth and socket:

SOCKADDR_BTH RemoteEndPoint;
RemoteEndPoint.port = 0;
RemoteEndPoint.addressFamily = AF_BTH;
RemoteEndPoint.btAddr = m_foundDevices[m_deviceIndex].Address.ullLong;
RemoteEndPoint.serviceClassId = HandsfreeServiceClass_UUID;
int BTHAddrLength = sizeof(RemoteEndPoint);

// Create the socket.
if ((m_localSocket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM)) == INVALID_SOCKET)
{
    // handle error.
}

// Connect the socket.
if ((iResult = connect(m_localSocket, (SOCKADDR *)&RemoteEndPoint, sizeof(RemoteEndPoint))) == INVALID_SOCKET)
{
    // handle error.
}

Notice line

RemoteEndPoint.serviceClassId = HandsfreeServiceClass_UUID

I think the problem is here, becouse u cant send sms from Handsfree, but when i use another UUID, it doesnt even pair with mobile.

=== Here is just for info, how am i sending and receiving data from mobile ===

char recvbuf[DEFAULT_BUFLEN] = "";
const char *sendbuf = "AT+CMGL\r";
int len = (int)strlen(sendbuf);
if ((iResult = send(m_localSocket, sendbuf, len, MSG_OOB)) == SOCKET_ERROR)
{
    // handle error. return ~0
}

if ((iResult = recv(m_localSocket, recvbuf, recvbuflen, 0)) == SOCKET_ERROR)
{
    // handle error. return ~0
}
// Here recvbuf == "\r\nERROR\r\n"

Thank you for any advices! If you have any question's about problem, i'll kindly explain.
Regards,
Filip.


问:
Can a signal observer get access to the last emitted value of a ReactiveCocoa signal?
I'm starting using ReactiveCocoa and I'm still struggling with some basic concepts:

My app starts listening for geolocation data (init in my view model)

My app emits a signal with my current location (didFindCurrentPosition is called)

My view controller showing a map loads (viewDidLoad in my view controller)

My view controller starts observing the current location signal (still viewDidLoad)

My problem is: after step 2 is achieved, if no other event is sent on the signal, my view controller doesn't get notified.

How can my view controller get access to the last value from the signal? (ie how to get access at step 3 to a value emitted at step 2?)

Thanks for your help.

PS: ReactiveCocoa looks like a great library but I'm puzzled by the state of the documentation. IMHO, it is not very clear and lacks some clear guides on how to use it.

The Code

The view model:

```<code>class MyViewModel: LocationManagerDelegate {
    let locationManager: LocationManager
    let geolocationDataProperty = MutableProperty<Geolocation?>(nil)
    let geolocationData: Signal<Geolocation?, NoError>

    init() {
        geolocationData = geolocationDataProperty.signal

        // Location Management
        locationManager = LocationManager()
        locationManager.delegate = self
        locationManager.requestLocation()
    }

    // MARK: - LocationManagerDelegate

    func didFindCurrentPosition(location: CLLocation) {
        geolocationDataProperty.value = Geolocation(location: location)
    }
}
</code>```

The view controller:

```<code>class MyViewController: UIViewController {
    let viewModel = MyViewModel()

    init() {
        super.init(nibName: nil, bundle: nil)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        viewModel.geolocationData
            .observe(on: UIScheduler())
            .observeValues { geolocation in
                debugPrint("GOT GEOLOCATION")
        }
    }
}
</code>```

答:
You already have a Property that holds the latest value emitted. Instead of using the property's signal use the producer. That way when you start the producer you will get the current value first (in none was sent you will get nil).

Cf. the documentation:

The current value of a property can be obtained from the value getter. The producer getter returns a signal producer that will send the property’s current value, followed by all changes over time. The signal getter returns a signal that will send all changes over time, but not the initial value.

So, regarding the code in the question, the viewDidLoad method should do something like the following:

```<code>viewModel.geolocationDataProperty
        .producer
        .start(on: UIScheduler())
        .startWithValues { geolocation in
            debugPrint("GOT GEOLOCATION")
    }
</code>```

Body:
I'm starting using ReactiveCocoa and I'm still struggling with some basic concepts:

My app starts listening for geolocation data (init in my view model)

My app emits a signal with my current location (didFindCurrentPosition is called)

My view controller showing a map loads (viewDidLoad in my view controller)

My view controller starts observing the current location signal (still viewDidLoad)

My problem is: after step 2 is achieved, if no other event is sent on the signal, my view controller doesn't get notified.

How can my view controller get access to the last value from the signal? (ie how to get access at step 3 to a value emitted at step 2?)

Thanks for your help.

PS: ReactiveCocoa looks like a great library but I'm puzzled by the state of the documentation. IMHO, it is not very clear and lacks some clear guides on how to use it.

The Code

The view model:

class MyViewModel: LocationManagerDelegate {
    let locationManager: LocationManager
    let geolocationDataProperty = MutableProperty<Geolocation?>(nil)
    let geolocationData: Signal<Geolocation?, NoError>

    init() {
        geolocationData = geolocationDataProperty.signal

        // Location Management
        locationManager = LocationManager()
        locationManager.delegate = self
        locationManager.requestLocation()
    }

    // MARK: - LocationManagerDelegate

    func didFindCurrentPosition(location: CLLocation) {
        geolocationDataProperty.value = Geolocation(location: location)
    }
}

The view controller:

class MyViewController: UIViewController {
    let viewModel = MyViewModel()

    init() {
        super.init(nibName: nil, bundle: nil)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        viewModel.geolocationData
            .observe(on: UIScheduler())
            .observeValues { geolocation in
                debugPrint("GOT GEOLOCATION")
        }
    }
}

Body:
You already have a Property that holds the latest value emitted. Instead of using the property's signal use the producer. That way when you start the producer you will get the current value first (in none was sent you will get nil).

Cf. the documentation:

The current value of a property can be obtained from the value getter. The producer getter returns a signal producer that will send the property’s current value, followed by all changes over time. The signal getter returns a signal that will send all changes over time, but not the initial value.

So, regarding the code in the question, the viewDidLoad method should do something like the following:

viewModel.geolocationDataProperty
        .producer
        .start(on: UIScheduler())
        .startWithValues { geolocation in
            debugPrint("GOT GEOLOCATION")
    }


问:
WP Woocommerce Add widget beside Review
So we all know that in wordpress woocommerce, there is a product detail tab and review tab in the Single Product page.

I am trying to change the content/comment in the review tab to 70% and have a widget next to the comment. But I don't see to be able to do it. My review form is using WP Advanced comment plugin. https://wordpress.org/plugins/wp-advance-comment/

答:
It can be changed in the woocommerce/single-product/tabs/tabs.php

```<code><div class="wc_reviewbox">
    <div class="woocommerce-tabs wc-tabs-wrapper">
        <ul class="tabs wc-tabs" role="tablist">
            <?php foreach ( $tabs as $key => $tab ) : ?>
                <li class="<?php echo esc_attr( $key ); ?>_tab" id="tab-title-<?php echo esc_attr( $key ); ?>" role="tab" aria-controls="tab-<?php echo esc_attr( $key ); ?>">
                    <a href="#tab-<?php echo esc_attr( $key ); ?>"><?php echo apply_filters( 'woocommerce_product_' . $key . '_tab_title', esc_html( $tab['title'] ), $key ); ?></a>
                </li>
            <?php endforeach; ?>
        </ul>
        <?php foreach ( $tabs as $key => $tab ) :
            echo print_r($tab);
            ?>
            <div class="woocommerce-Tabs-panel woocommerce-Tabs-panel--<?php echo esc_attr( $key ); ?> panel entry-content wc-tab" id="tab-<?php echo esc_attr( $key ); ?>" role="tabpanel" aria-labelledby="tab-title-<?php echo esc_attr( $key ); ?>">
                <?php call_user_func( $tab['callback'], $key, $tab ); ?>
            </div>
        <?php endforeach; ?>
    </div>
</div>

<div class="wc_adbox">
    [PUT WIDGET CODE HERE]
</div>
</code>```

Do some css manipulation.

```<code>.wc_reviewbox {
width:72%;float:left;
}

.wc_adbox {
width:25%;float:right;
}
</code>```

Title: WP Woocommerce Add widget beside Review

Body:
It can be changed in the woocommerce/single-product/tabs/tabs.php

<div class="wc_reviewbox">
    <div class="woocommerce-tabs wc-tabs-wrapper">
        <ul class="tabs wc-tabs" role="tablist">
            <?php foreach ( $tabs as $key => $tab ) : ?>
                <li class="<?php echo esc_attr( $key ); ?>_tab" id="tab-title-<?php echo esc_attr( $key ); ?>" role="tab" aria-controls="tab-<?php echo esc_attr( $key ); ?>">
                    <a href="#tab-<?php echo esc_attr( $key ); ?>"><?php echo apply_filters( 'woocommerce_product_' . $key . '_tab_title', esc_html( $tab['title'] ), $key ); ?></a>
                </li>
            <?php endforeach; ?>
        </ul>
        <?php foreach ( $tabs as $key => $tab ) :
            echo print_r($tab);
            ?>
            <div class="woocommerce-Tabs-panel woocommerce-Tabs-panel--<?php echo esc_attr( $key ); ?> panel entry-content wc-tab" id="tab-<?php echo esc_attr( $key ); ?>" role="tabpanel" aria-labelledby="tab-title-<?php echo esc_attr( $key ); ?>">
                <?php call_user_func( $tab['callback'], $key, $tab ); ?>
            </div>
        <?php endforeach; ?>
    </div>
</div>

<div class="wc_adbox">
    [PUT WIDGET CODE HERE]
</div>

Do some css manipulation.

.wc_reviewbox {
width:72%;float:left;
}

.wc_adbox {
width:25%;float:right;
}


问:
how to insert variable's value in SQlite Database in Qt cpp
i am using Qt and i have written c++ code,i have already connected with sqlite database.i want to insert name in database

```<code>std::string name="Hello";
qry.prepare( "INSERT INTO s_no (Name,Status) VALUES ('name','1' )");
if( !qry.exec() )
    qDebug() << qry.lastError();
else
    qDebug( "Inserted!" );
</code>```

but in db i am finding name only , not hello;

please help me..thank you so much in advance

答: Try making name a QString. You can change std::string to QString by using: QString name2 = QString::fromStdString(name);. Don't forget to include: #include <QString>.

Body:
i am using Qt and i have written c++ code,i have already connected with sqlite database.i want to insert name in database

std::string name="Hello";
qry.prepare( "INSERT INTO s_no (Name,Status) VALUES ('name','1' )");
if( !qry.exec() )
    qDebug() << qry.lastError();
else
    qDebug( "Inserted!" );

but in db i am finding name only , not hello;

please help me..thank you so much in advance


问:
evaluating else if after an if condition is true
Consider this snippet:

```<code>private void button1_Click(object sender, EventArgs e)
{
    if (textBox1.MaxLength > 0)
    {
        textBox2.Text = Convert.ToBoolean(Math.Sqrt(textBox1.MaxLength)).ToString();
    }
    else if (textBox1.MaxLength < 32768)
    {
        textBox2.Text = Convert.ToBoolean(Math.Sqrt(textBox1.MaxLength)).ToString();
    }
}
</code>```

Why is it not evaluating the second condition (the lesser than condition)? It's also true, isn't it?

If I have to make the second one to work in the same condition, what minor change must be made?

答:
Think of else if as actually being written this way:

```<code>private void button1_Click(object sender, EventArgs e)
{
    //textBox2.Text += Convert.ToString (textBox1.Text + "garment");
    if (textBox1.MaxLength > 0)
    {
        textBox2.Text = Convert.ToBoolean(Math.Sqrt(textBox1.MaxLength)).ToString();
    }
    else
    {
        if (textBox1.MaxLength < 32768)
        {
            textBox2.Text = Convert.ToBoolean(Math.Sqrt(textBox1.MaxLength)).ToString();
        }
    }
}
</code>```

It's the same thing. Note that the second if sstatement is only executed when the first is false.

Body:
Consider this snippet:

private void button1_Click(object sender, EventArgs e)
{
    if (textBox1.MaxLength > 0)
    {
        textBox2.Text = Convert.ToBoolean(Math.Sqrt(textBox1.MaxLength)).ToString();
    }
    else if (textBox1.MaxLength < 32768)
    {
        textBox2.Text = Convert.ToBoolean(Math.Sqrt(textBox1.MaxLength)).ToString();
    }
}

Why is it not evaluating the second condition (the lesser than condition)? It's also true, isn't it?

If I have to make the second one to work in the same condition, what minor change must be made?

Body:
Think of else if as actually being written this way:

private void button1_Click(object sender, EventArgs e)
{
    //textBox2.Text += Convert.ToString (textBox1.Text + "garment");
    if (textBox1.MaxLength > 0)
    {
        textBox2.Text = Convert.ToBoolean(Math.Sqrt(textBox1.MaxLength)).ToString();
    }
    else
    {
        if (textBox1.MaxLength < 32768)
        {
            textBox2.Text = Convert.ToBoolean(Math.Sqrt(textBox1.MaxLength)).ToString();
        }
    }
}

It's the same thing. Note that the second if sstatement is only executed when the first is false.