how to use zend create 'with (nolock)' select query??

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

how to use zend create 'with (nolock)' select query??

vtsuper
hi, could some one teach me how to do the following query in SQL server by ZF 1 ????
SELECT userID FROM EMPLOYEE WITH (NOLOCK)

if ZF 1 doesn't provide it , how to create this method by myself in Zend_DB?
Reply | Threaded
Open this post in threaded view
|

Re: how to use zend create 'with (nolock)' select query??

vtsuper
I believe select_db haven't handle this case, so would someone teach me how to extend select_db and create my own method to handle 'nolock'?

SELECT userID FROM EMPLOYEE WITH (NOLOCK)
$select=$this->getAdapter()->select()->from(array('EMPLOYEE '), array('userID '));
Reply | Threaded
Open this post in threaded view
|

Re: how to use zend create 'with (nolock)' select query??

Enrico Zimuel-2
Hi,

you can use the query() function for Zend_Db (ZF1) and write your custom
query:

$stmt = $db->query("SELECT userID FROM EMPLOYEE WITH (NOLOCK)");

NOLOCK is a Table Hints of SQL Server and should be used only as last
option in particular cases.
You can also use transactions with READUNCOMMITTED.
In Zend_Db we offer the setTransactionIsolationLevel() with the flag
SQLSRV_TXN_READ_UNCOMMITTED.

For more information about transtactions in Zend_Db:
http://framework.zend.com/manual/1.12/en/zend.db.adapter.html#zend.db.adapter.transactions

Regards,
Enrico Zimuel

On Thu, Sep 17, 2015 at 5:05 AM, vtsuper <[hidden email]> wrote:

> I believe select_db haven't handle this case, so would someone teach me how
> to extend select_db and create my own method to handle 'nolock'?
>
> SELECT userID FROM EMPLOYEE WITH (NOLOCK)
> $select=$this->getAdapter()->select()->from(array('EMPLOYEE '),
> array('userID '));
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-create-with-nolock-select-query-tp4662676p4662677.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>


--

Enrico Zimuel
Senior Software Engineer | [hidden email] Team           |
http://apigility.orgZend Framework Team      |
http://framework.zend.comZend Technologies Ltd.http://www.zend.com
Reply | Threaded
Open this post in threaded view
|

Re: how to use zend create 'with (nolock)' select query??

vtsuper
But whats wrong with this statement, it always return error
$this->getAdapter()->setTransactionIsolationLevel(SQLSRV_TXN_READ_UNCOMMITTED);

 Fatal error: Call to undefined method Zend_Db_Adapter_Pdo_Sqlsrv::setTransactionIsolationLevel() in C:\wamp\www\project\application\modules\report\models\Item.php on line
Reply | Threaded
Open this post in threaded view
|

Re: how to use zend create 'with (nolock)' select query??

Enrico Zimuel-2
Hi,

the setTransactionIsolationLevel() function is available only for Sqlsrv
adapter (Zend_Db_Adapter_Sqlsrv).
This function is not supported by PDO adapters, that is your case.
I see that you are using Windows, if you are running the PHP application on
a Microsoft environment, I suggest to use the Sqlsrv native adapter of
Microsoft.

Regards,
Enrico Zimuel




On Thu, Sep 17, 2015 at 12:42 PM, vtsuper <[hidden email]> wrote:

> But whats wrong with this statement, it always return error
>
> $this->getAdapter()->setTransactionIsolationLevel(SQLSRV_TXN_READ_UNCOMMITTED);
>
>  Fatal error: Call to undefined method
> Zend_Db_Adapter_Pdo_Sqlsrv::setTransactionIsolationLevel() in
> C:\wamp\www\project\application\modules\report\models\Item.php on line
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-create-with-nolock-select-query-tp4662676p4662679.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>


--

Enrico Zimuel
Senior Software Engineer | [hidden email] Team           |
http://apigility.orgZend Framework Team      |
http://framework.zend.comZend Technologies Ltd.http://www.zend.com
Reply | Threaded
Open this post in threaded view
|

Re: how to use zend create 'with (nolock)' select query??

vtsuper
what is the pros and cons on using Zend_Db_Adapter_Sqlsrv rather than Zend_Db_Adapter_PDO_Sqlsrv?

when I using pure php(no zend framework), most of the developer will prefer PDO rather then other drivers.
Reply | Threaded
Open this post in threaded view
|

Re: how to use zend create 'with (nolock)' select query??

Enrico Zimuel-2
Hi,

the Sqlsrv driver is official supported by Microsoft, and it contains some
extra features compared with PDO_Mssql.
Here you can find a good article that compare Sqlsrv vs. PDO:
http://blogs.msdn.com/b/brian_swan/archive/2010/03/08/mssql-vs-sqlsrv-what-s-the-difference-part-1.aspx

Generally speaking, if you need to execute your application on different
environments Windows and Linux, maybe the use of PDO is better for portable
reason.
If you only use Windows and you are interested in some extra features of MS
SQL Server you can use Sqlsrv.
Anyway, the choice is really related to your use case.

Regards,
Enrico Zimuel


On Fri, Sep 18, 2015 at 10:37 AM, vtsuper <[hidden email]> wrote:

> what is the pros and cons on using Zend_Db_Adapter_Sqlsrv rather than
> Zend_Db_Adapter_PDO_Sqlsrv?
>
> when I using pure php(no zend framework), most of the developer will prefer
> PDO rather then other drivers.
>
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-create-with-nolock-select-query-tp4662676p4662681.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>


--

Enrico Zimuel
Senior Software Engineer | [hidden email] Team           |
http://apigility.orgZend Framework Team      |
http://framework.zend.comZend Technologies Ltd.http://www.zend.com