小编nkc*_*dra的帖子

如何在Zend\Db\TableGateway中使用SQL_CALC_FOUND_ROWS

如何获得SQL_CALC_FOUND_ROWSZend\Db\TableGateway不使用直接低水平的查询与原始的SQL?

class ProductTable {
    protected $tableGateway;

    /**
     * Set database gateway
     *
     * @param TableGateway $tableGateway - database connection
     * @return void
     */
    public function __construct(TableGateway $tableGateway) {
        $this->tableGateway = $tableGateway;
    }


    /**
     * Fetch all products
     *
     * @param integer $page - page of records
     * @param integer $perpage - records per page
     * @return void
     */
    public function fetchAll($page = 1, $perpage = 18) {
        return $this->tableGateway->select(function (Select $select) use ($page, $perpage) {
            $select …
Run Code Online (Sandbox Code Playgroud)

mysql zend-framework2

6
推荐指数
1
解决办法
2855
查看次数

我们可以使用对象访问私有变量吗

我们不能从在类外部创建的对象访问类的私有变量,但是当在类内部创建相同的对象时可以访问它。为什么??

class Program
{
    private int i;

    public void method1()
    {            
        Program p = new Program();
        p.i = 5;        // OK when accessed within the class
    }

}

class AnotherClass
{

    void method2()
    {
        Program p = new Program();
        p.i = 5; //error because private variables cannot be accessed with an object which is created out side the class
    }

}
Run Code Online (Sandbox Code Playgroud)

现在我想每个人都明白我的意思了??

在上述两种情况下,我们都通过对象“p”访问私有变量“i”。但课内允许,课外不允许。谁能告诉我这背后的原因??

.net c# oop

4
推荐指数
1
解决办法
9287
查看次数

Windows Phone 8等待不等待

我正在编写一个示例windows phone 8应用程序.我还安装了Async for .NET Framework 4,Silverlight 4和5以及Windows Phone的框架.

但是,等待一个方法不等待,我的mainpage.xaml加载试图访问尚未填充的属性.

这是我的代码.

public static ObservableCollection<Model.CatalogCategory> Products { get; set; } 
private async void Application_Launching(object sender, LaunchingEventArgs e)
    {
        ApplicationViewModel vm = new ApplicationViewModel();
        Products = await vm.LoadLocalDataAsync();

    }
Run Code Online (Sandbox Code Playgroud)

在此方法之后,加载mainpage.xaml,它尝试访问"Products"并抛出空引用异常.

我需要采取不同的方法吗?

windows-phone-7 .net-4.5 windows-phone-8

3
推荐指数
1
解决办法
673
查看次数

Win8 C#Metro调度程序和RPC_E_WRONG_THREAD

我正在尝试使用非官方的Google音乐API在Windows 8 metro界面中为.net构建一个应用程序.我正在加载整个播放列表

foreach (GoogleMusicPlaylist p in pls.UserPlaylists)
                lbPlaylists.Items.Add(p.Title);
Run Code Online (Sandbox Code Playgroud)

它出现了这个错误

HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
Run Code Online (Sandbox Code Playgroud)

我在互联网上阅读,也许我必须使用调度员或其他我一般都很困惑的东西.

c# microsoft-metro windows-8

2
推荐指数
1
解决办法
2385
查看次数