1 cindyrae Jan 12, 2008 00:58
3 cindyrae Jan 12, 2008 03:00
I need to know how to query the database for the existing post types (not create new post types from the back office)
4 afwas Jan 12, 2008 03:29
For posts
SELECT *
FROM `evo_items__item`
WHERE `post_ptyp_ID = 1`
for links
SELECT *
FROM `evo_items__item`
WHERE `post_ptyp_ID = 2`
5 cindyrae Jan 17, 2008 18:14
Actually, this is kinda what I wanted:
function query_types()
{
global $DB;
$this->ItemQuery->where_types( ' 1, 2, 5001, 5002, 5003 ' );
$this->request = 'SELECT * FROM ' . $this->dbtable . $this->ItemQuery->get_where();
$this->result = $DB->get_results( $this->request, ARRAY_A );
$this->result_num_rows = $DB->num_rows;
if ( isset( $GLOBALS[$this->id_param] ) )
{
$this->curr_type = $GLOBALS[$this->id_param];
}
else
{
$this->curr_type = 0;
}
}
Ideally, I wouldn't have to specify the types, but just query for all and screen out the "Reserved" types. However, that proved difficult based on the current core code.
- Cindy Rae
6 yabba Jan 17, 2008 19:20
<?php
$sql = 'select ptyp_ID from T_items__type where not( ptyp_name == \'Reserved\' )';
$all_types = $DB->get_results( $sql, ARRAY_A);
?>
¥
7 cindyrae Jan 17, 2008 19:55
Update thanks to the blonde bimbo's reply:
function query_types()
{
global $DB;
$this->request = "select * from " . $this->dbtable . " where not( " . $this->dbNameName . " = 'Reserved' ) AND not ( " . $this->dbNameName . " = 'Page' )";
$this->result = $DB->get_results( $this->request, ARRAY_A );
$this->result_num_rows = $DB->num_rows;
if ( isset( $GLOBALS[$this->url_param_name] ) )
{
$this->curr_type = $GLOBALS[$this->url_param_name];
}
else
{
$this->curr_type = 0;
}
}
Blog settings -> Post types -> New element