Skip to content

Commit

Permalink
Rewriting dataSeek in Zephir
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutierrez committed May 22, 2016
1 parent d0844c8 commit fa01f63
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 36 deletions.
38 changes: 6 additions & 32 deletions phalcon/db/result/pdo.zep
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ class Pdo implements ResultInterface
* $row = $result->fetch(); // Fetch third row
*</code>
*/
public function dataSeek(long number)
public function dataSeek(long number) -> void
{
var connection, pdo, sqlStatement, bindParams, statement;
%{ { pdo_stmt_t *stmt; long n; }%
long n;

let connection = this->_connection,
pdo = connection->getInternalHandler(),
Expand All @@ -265,37 +265,11 @@ class Pdo implements ResultInterface

let this->_pdoStatement = statement;

%{

/**
* This a fetch scroll to reach the desired position, however with a big number of records
* maybe it may be very slow
*/
#if PHP_VERSION_ID >= 70000
stmt = php_pdo_stmt_fetch_object(Z_OBJ_P((&statement)));
#else
stmt = (pdo_stmt_t*) zend_object_store_get_object(statement TSRMLS_CC);
#endif
if (!stmt->dbh) {
ZEPHIR_MM_RESTORE();
RETURN_FALSE;
let n = -1, number--;
while n != number {
statement->$fetch();
let n++;
}

n = -1;
number--;
while (n != number) {

if (!stmt->methods->fetcher(stmt, PDO_FETCH_ORI_NEXT, 0 TSRMLS_CC)) {
ZEPHIR_MM_RESTORE();
RETURN_NULL();
}

n++;
}

}

}%
}

/**
Expand Down
7 changes: 4 additions & 3 deletions phalcon/mvc/model.zep
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

/*
+------------------------------------------------------------------------+
| Phalcon Framework |
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
Expand Down Expand Up @@ -43,6 +43,7 @@ use Phalcon\Mvc\Model\Exception;
use Phalcon\Mvc\Model\MessageInterface;
use Phalcon\Mvc\Model\Message;
use Phalcon\ValidationInterface;
use Phalcon\Validation\Message\Group;
use Phalcon\Mvc\Model\ValidationFailed;
use Phalcon\Events\ManagerInterface as EventsManagerInterface;
use Phalcon\Validation\Message\Group as ValidationMessageGroup;
Expand Down Expand Up @@ -1396,7 +1397,7 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface

messages->rewind();

//for message in iterator(messages) {
// for message in iterator(messages) {
while messages->valid() {

let message = messages->current();
Expand Down
2 changes: 1 addition & 1 deletion phalcon/security/random.zep
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Random
}
}

throw new Exception("No random device");
throw new Exception("No random device avaiable");

This comment has been minimized.

Copy link
@tembem

tembem May 24, 2016

Contributor

Typo avaiable. I think it should be available

This comment has been minimized.

Copy link
@sergeyklay

sergeyklay May 24, 2016

Contributor

Create PR

}

/**
Expand Down

0 comments on commit fa01f63

Please sign in to comment.