Basic Question - How to run select query?

28 views
Skip to first unread message

Jacky

unread,
Jul 18, 2010, 5:21:40 AM7/18/10
to Outlet ORM
Hi All,

I'm newbie of Outlet ORM. May I ask I simple question -- how can I
select the results by using different criteria?

I know I can run the below command for getting the value of primary
key = 1 in table - Account
$account = $outlet -> load('Account',1);

But if I would like to search the result in table - Account which the
name is "jacky", how should I do?


Thanks & Regards,
Jacky

Alvaro Carrasco

unread,
Jul 23, 2010, 7:54:24 PM7/23/10
to outle...@googlegroups.com
Hi Jacky,

I'm very sorry that your email was stuck on moderation for a few days,
it got lost among some spam and I just barely saw it.

This answer is probably too late, but here it is. Selecting is documented here:
http://www.outlet-orm.org/manual/ch05.html

Alvaro

Jacky Wong

unread,
Jul 25, 2010, 4:20:49 AM7/25/10
to outle...@googlegroups.com
Hi Alvaro,

Thanks for your response in advance.
Actually I don't know how to pass array information into the select statement, below is the example from the offical document
$bugs = $outlet->select("Bug", "WHERE {Bug.StatusID} = ?", array(1));
What does array(1) means? Would you please give me some idea by providing some example?
Many thanks

Regards,
Jacky


--
You received this message because you are subscribed to the Google Groups "Outlet ORM" group.
To post to this group, send email to outle...@googlegroups.com.
To unsubscribe from this group, send email to outlet-orm+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/outlet-orm?hl=en.


alvaro

unread,
Jul 25, 2010, 12:57:53 PM7/25/10
to Outlet ORM
The first parameter is the query with place holders (?) for the
values, the second is an array of values to replace the place holders.
It is the way you do *prepare statements* using outlet. Here is an
example:
$accounts = $outlet->select('Account a', 'WHERE {a.Name} = ?',
array('jacky'));

You can also select the first one (probably the only one) by using -
>selectOne

Prepare statements in outlet are based on how they are implemented on
PDO. Take a look at example 2 in this page:
http://us2.php.net/manual/en/pdo.prepare.php

You don't have to use prepared statements, but it's recommended to
prevent SQL injection. Here is an example that just uses string
concatenation:
$accounts = $outlet->select('Account a', 'WHERE {a.Name} = ' . $outlet-
>quote('jacky'));

Alvaro

On Jul 25, 2:20 am, Jacky Wong <jacky...@gmail.com> wrote:
> Hi Alvaro,
>
> Thanks for your response in advance.
> Actually I don't know how to pass *array *information into the select
> statement, below is the example from the offical document
>
> $bugs = $outlet->select(*"Bug"*, *"WHERE {Bug.StatusID} = ?"*, *array*(1));
>
> What does array(1) means? Would you please give me some idea by providing
> some example?
> Many thanks
>
> Regards,
> Jacky
>
> On Sat, Jul 24, 2010 at 7:54 AM, Alvaro Carrasco <simple...@gmail.com>wrote:
>
> > Hi Jacky,
>
> > I'm very sorry that your email was stuck on moderation for a few days,
> > it got lost among some spam and I just barely saw it.
>
> > This answer is probably too late, but here it is. Selecting is documented
> > here:
> >http://www.outlet-orm.org/manual/ch05.html
>
> > Alvaro
>
> > On Sun, Jul 18, 2010 at 3:21 AM, Jacky <jacky...@gmail.com> wrote:
> > > Hi All,
>
> > > I'm newbie of Outlet ORM. May I ask I simple question -- how can I
> > > select the results by using different criteria?
>
> > > I know I can run the below command for getting the value of primary
> > > key = 1 in table - Account
> > > $account = $outlet -> load('Account',1);
>
> > > But if I would like to search the result in table - Account which the
> > > name is "jacky", how should I do?
>
> > > Thanks & Regards,
> > > Jacky
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Outlet ORM" group.
> > To post to this group, send email to outle...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > outlet-orm+...@googlegroups.com<outlet-orm%2Bunsu...@googlegroups.com>
> > .

Jacky Wong

unread,
Jul 27, 2010, 7:48:39 AM7/27/10
to outle...@googlegroups.com
Hi Alvaro,

I tried to follow your step, but there is fatal error as below
Do you have any idea? Any steps I have missed?

Fatal error: Call to undefined method OutletEntityConfig::getClass() in /var/www/html/sendMovSys/WEB-INF/Lib/ORM/classes/OutletConfig.php on line 341

Below is my source code

Outlet::init(require_once dirname(__FILE__).'/../../config/outlet-config.php');

$outlet = Outlet::getInstance();
$outlet->createProxies();

echo $outlet->select('SchemaAreapointdefine s','WHERE {s.fromareacode} = ?',array('853'));


Thanks & Regards,
Jacky



To unsubscribe from this group, send email to outlet-orm+...@googlegroups.com.

Alvaro Carrasco

unread,
Jul 27, 2010, 11:08:22 PM7/27/10
to outle...@googlegroups.com
I think you are using an old version of Outlet... have you tried the 1.0rc1?

Alvaro

Reply all
Reply to author
Forward
0 new messages