use version 1.3.4., Amazon RDS. This is the model class
class Products extends \Phalcon\Mvc\Model {
public $id;
public $name;
public function initialize(){
$this->setSource('products');
}
}
table status:
mysql> show columns from products;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | MUL | NULL | auto_increment |
| name | varchar(255) | YES | | NULL | |
+-------+--------------+------+-----+---------+----------------+
mysql> select * from `products`;
+----+--------+
| id | name |
+----+--------+
| 1 | value1 |
| 2 | value2 |
+----+--------+
If use Model
$products = Products::find();
var_export($products); // Bad : 0
$product = Products::findFirst();
var_export($product); // Bad : false
If use PDOConnection
$connection = $this->di->get('db');
$result = $connection->query('SELECT * from `products`');
$products = $result->fetchAll();
var_export(count($products)); // Good : 2
Is there something wrong? db setting is here.
$di->set('db', function(){
return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
"host" => "%AMAZON RDS HOST NAME%",
"username" => "%username%",
"password" => "%password%",
"dbname" => "% DB NAME %"
));
});