Русское сообщество разработки на PHP-фреймворке Laravel.
Ты не вошёл. Вход тут.
Страницы 1
Подскажите как победить проблему.
Laravel 3.2
Модель City
class City extends Eloquent {
public static $table = 'geo_populations';
}
Контроллер
public function get_city5() {
$city = City::select(array('id','name'))->find(92390);
die('<pre>'.print_r($city,true).'</pre>');
}
Получаю на локалке (Open-Server):
City Object
(
[attributes] => Array
(
[id] => 92390
[name] => Казань
)
[original] => Array
(
[id] => 92390
[name] => Казань
)
[relationships] => Array
(
)
[exists] => 1
[includes] => Array
(
)
)
Получаю на боевом сервере:
Laravel\Database\Eloquent\Query Object
(
[model] => City Object
(
[attributes] => Array
(
)
[original] => Array
(
)
[relationships] => Array
(
)
[exists] =>
[includes] => Array
(
)
)
[table] => Laravel\Database\Query Object
(
[connection] => Laravel\Database\Connection Object
(
[pdo] => PDO Object
(
)
[config] => Array
(
[driver] => mysql
[host] => %хост%
[database] => %база%
[username] => %логин%
[password] => %пароль%
[charset] => utf8
[prefix] =>
)
[grammar:protected] => Laravel\Database\Query\Grammars\MySQL Object
(
[wrapper:protected] => `%s`
[datetime] => Y-m-d H:i:s
[components:protected] => Array
(
[0] => aggregate
[1] => selects
[2] => from
[3] => joins
[4] => wheres
[5] => groupings
[6] => havings
[7] => orderings
[8] => limit
[9] => offset
)
[connection:protected] => Laravel\Database\Connection Object
*RECURSION*
)
)
[grammar] => Laravel\Database\Query\Grammars\MySQL Object
(
[wrapper:protected] => `%s`
[datetime] => Y-m-d H:i:s
[components:protected] => Array
(
[0] => aggregate
[1] => selects
[2] => from
[3] => joins
[4] => wheres
[5] => groupings
[6] => havings
[7] => orderings
[8] => limit
[9] => offset
)
[connection:protected] => Laravel\Database\Connection Object
(
[pdo] => PDO Object
(
)
[config] => Array
(
[driver] => mysql
[host] => %хост%
[database] => %база%
[username] => %логин%
[password] => %пароль%
[charset] => utf8
[prefix] =>
)
[grammar:protected] => Laravel\Database\Query\Grammars\MySQL Object
*RECURSION*
)
)
[selects] =>
[aggregate] =>
[distinct] =>
[from] => geo_populations
[joins] =>
[wheres] => Array
(
[0] => Array
(
[type] => where
[column] => id
[operator] => =
[value] => 92390
[connector] => AND
)
)
[groupings] =>
[havings] =>
[orderings] =>
[limit] => 1
[offset] =>
[bindings] => Array
(
[0] => 92390
)
)
[includes] => Array
(
)
[passthru] => Array
(
[0] => lists
[1] => only
[2] => insert
[3] => insert_get_id
[4] => update
[5] => increment
[6] => delete
[7] => decrement
[8] => count
[9] => min
[10] => max
[11] => avg
[12] => sum
)
)
Интересно. Не могу ничего сказать — попробуй отладчиком пройти по вызовам в первой строчке кода контроллера или поставь debugBreak(); (для php_dbg) внутри find() в laravel/database/query.php. По идее последний как раз и должен возвращать саму модель.
Ещё можешь посмотреть в профайлер — выполняется ли сам SQL после вызова find()?
Не в сети
Извиняюсь, что долго не было. Спасибо за ответ.
debug пока не осилил.
решил проблему так
City::select(array('id','name'))->where('id','=',92390)->first();
Страницы 1