Commit aa349ecb authored by zYne's avatar zYne

--no commit message

--no commit message
parent 7b48189b
......@@ -321,6 +321,14 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
if(is_bool($item))
$item = (int) $item;
}
/**
* setParams
*
* @param array $params
*/
public function setParams(array $params = array()) {
$this->params = $params;
}
/**
* execute
* executes the dql query and populates all collections
......@@ -405,7 +413,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
if($prev[$name]->count() > 0) {
$record = $prev[$name]->getLast();
} else {
} else {
$record = new $component();
$prev[$name]->add($record);
}
......
......@@ -224,6 +224,9 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
if( ! empty($having))
$q .= ' HAVING ' . implode(' AND ',$having);
if( ! is_array($params))
$params = array($params);
$params = array_merge($this->params, $params);
$a = $this->getConnection()->execute($q, $params)->fetch(PDO::FETCH_NUM);
......@@ -533,6 +536,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
switch(strtolower($this->conn->getName())) {
case 'mysql':
// mysql doesn't support LIMIT in subqueries
$params = array_merge($this->params, $params);
$list = $this->conn->execute($subquery, $params)->fetchAll(PDO::FETCH_COLUMN);
$subquery = implode(', ', $list);
break;
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine::autoload("Doctrine_Query_Part");
/**
* Doctrine_Query_From
*
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Query_From extends Doctrine_Query_Part {
/**
......@@ -15,7 +44,7 @@ class Doctrine_Query_From extends Doctrine_Query_Part {
$parts = Doctrine_Query::bracketExplode($str, 'JOIN');
$operator = false;
switch(trim($parts[0])) {
case 'INNER':
$operator = ':';
......
......@@ -369,7 +369,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$value = unserialize($tmp[$name]);
if($value === false)
throw new Doctrine_Record_Exception("Unserialization of $name failed. ".var_dump(substr($tmp[$lower],0,30)."...",true));
throw new Doctrine_Record_Exception("Unserialization of $name failed.");
} else
$value = $tmp[$name];
......
......@@ -5,6 +5,6 @@
$users = $conn->query("SELECT u.*, COUNT(p.id) count FROM User u, u.Phonenumber p GROUP BY u.id");
foreach($users as $user) {
print $user->name . ' has ' . $user->Phonenumber->getAggregateValue('count') . ' phonenumbers';
print $user->name . ' has ' . $user->Phonenumber[0]->count . ' phonenumbers';
}
?>
<?php ?>
<ul>
<li \>The <i>CONCAT</i> function returns a string that is a concatenation of its arguments.
<li \>The <i>CONCAT</i> function returns a string that is a concatenation of its arguments. In the example above we
map the concatenation of users firstname and lastname to a value called name
<br \><br \><?php
renderCode("<?php
\$q = new Doctrine_Query();
\$users = \$q->select('CONCAT(u.firstname, u.lastname) name')->from('User u')->execute();
foreach(\$users as \$user) {
// here 'name' is not a property of \$user,
// its a mapped function value
print \$user->name;
}
?>");
?>
<br \><br \>
<li \>The second and third arguments of the <i>SUBSTRING</i> function denote the starting position and length of
the substring to be returned. These arguments are integers. The first position of a string is denoted by 1.
The <i>SUBSTRING</i> function returns a string.
<br \><br \>
The <i>SUBSTRING</i> function returns a string.
<br \><br \><?php
renderCode("<?php
\$q = new Doctrine_Query();
\$users = \$q->select('u.name')->from('User u')->where(\"SUBSTRING(u.name, 0, 1) = 'z'\")->execute();
foreach(\$users as \$user) {
print \$user->name;
}
?>");
?>
<br \><br \>
<li \>The <i>TRIM</i> function trims the specified character from a string. If the character to be trimmed is not
specified, it is assumed to be space (or blank). The optional trim_character is a single-character string
literal or a character-valued input parameter (i.e., char or Character)[30]. If a trim specification is
not provided, BOTH is assumed. The <i>TRIM</i> function returns the trimmed string.
<br \><br \>
<br \><br \><?php
renderCode("<?php
\$q = new Doctrine_Query();
\$users = \$q->select('u.name')->from('User u')->where(\"TRIM(u.name) = 'Someone'\")->execute();
foreach(\$users as \$user) {
print \$user->name;
}
?>");
?> <br \><br \>
<li \>The <i>LOWER</i> and <i>UPPER</i> functions convert a string to lower and upper case, respectively. They return a
string. <br \><br \>
<?php
renderCode("<?php
\$q = new Doctrine_Query();
\$users = \$q->select('u.name')->from('User u')->where(\"LOWER(u.name) = 'someone'\")->execute();
foreach(\$users as \$user) {
print \$user->name;
}
?>");
?> <br \><br \>
<li \>
The <i>LOCATE</i> function returns the position of a given string within a string, starting the search at a specified
position. It returns the first position at which the string was found as an integer. The first argument
is the string to be located; the second argument is the string to be searched; the optional third argument
is an integer that represents the string position at which the search is started (by default, the beginning of
the string to be searched). The first position in a string is denoted by 1. If the string is not found, 0 is
returned.[31]
returned.
<br \><br \>
<li \>The <i>LENGTH</i> function returns the length of the string in characters as an integer.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment